Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/store/apply-license-to-project.tsx
1450 views
1
/*
2
* This file is part of CoCalc: Copyright © 2022 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Icon } from "@cocalc/frontend/components/icon";
7
import { Alert, Button, Popconfirm } from "antd";
8
import { NextRouter } from "next/router";
9
import { useLicenseProject } from "./util";
10
import Project from "components/project/link";
11
12
import type { JSX } from "react";
13
14
interface ApplyLicenseToProjectProps {
15
router: NextRouter;
16
}
17
18
export const ApplyLicenseToProject: React.FC<ApplyLicenseToProjectProps> = (
19
props: ApplyLicenseToProjectProps
20
) => {
21
const { router } = props;
22
const { upgradeProjectId, upgradeProjectDelete } = useLicenseProject(router);
23
24
function body(): JSX.Element {
25
if (!upgradeProjectId) throw new Error("should never happen");
26
return (
27
<div>
28
After purchase, this license will applied to project{" "}
29
<Project project_id={upgradeProjectId} /> automatically.
30
</div>
31
);
32
}
33
34
if (!upgradeProjectId) return null;
35
36
return (
37
<Alert
38
type="info"
39
message={body()}
40
style={{ marginBottom: "20px" }}
41
action={
42
<Popconfirm
43
placement="bottomRight"
44
title={
45
<div style={{ maxWidth: "400px" }}>
46
Are you sure you want to cancel automatically applying the license
47
to the project after purchasing it? Don't forget to apply the
48
license manually.
49
</div>
50
}
51
onConfirm={upgradeProjectDelete}
52
okText="Yes, cancel"
53
cancelText="No"
54
>
55
<Button size="small" type="link">
56
<Icon name="times" />
57
</Button>
58
</Popconfirm>
59
}
60
/>
61
);
62
};
63
64