"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApplyLicenseToProject = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
/*
 *  This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
const icon_1 = require("@cocalc/frontend/components/icon");
const antd_1 = require("antd");
const util_1 = require("./util");
const ApplyLicenseToProject = (props) => {
    const { router } = props;
    const { upgradeProjectId, upgradeProjectDelete } = (0, util_1.useLicenseProject)(router);
    function body() {
        if (!upgradeProjectId)
            throw new Error("should never happen");
        return ((0, jsx_runtime_1.jsxs)("div", { children: ["After purchase, this license will applied to project", " ", (0, jsx_runtime_1.jsx)("code", { children: upgradeProjectId }), " automatically."] }));
    }
    if (!upgradeProjectId)
        return null;
    return ((0, jsx_runtime_1.jsx)(antd_1.Alert, { type: "info", message: body(), style: { marginBottom: "20px" }, action: (0, jsx_runtime_1.jsx)(antd_1.Popconfirm, { placement: "bottomRight", title: (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: "400px" }, children: "Are you sure you want to cancel automatically applying the license to the project after purchasing it? Don't forget to apply the license manually." }), onConfirm: upgradeProjectDelete, okText: "Yes, cancel", cancelText: "No", children: (0, jsx_runtime_1.jsx)(antd_1.Button, { size: "small", type: "link", children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { name: "times" }) }) }) }));
};
exports.ApplyLicenseToProject = ApplyLicenseToProject;
//# sourceMappingURL=apply-license-to-project.js.map