CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/store/apply-license-to-project.tsx
Views: 687
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
interface ApplyLicenseToProjectProps {
13
router: NextRouter;
14
}
15
16
export const ApplyLicenseToProject: React.FC<ApplyLicenseToProjectProps> = (
17
props: ApplyLicenseToProjectProps
18
) => {
19
const { router } = props;
20
const { upgradeProjectId, upgradeProjectDelete } = useLicenseProject(router);
21
22
function body(): JSX.Element {
23
if (!upgradeProjectId) throw new Error("should never happen");
24
return (
25
<div>
26
After purchase, this license will applied to project{" "}
27
<Project project_id={upgradeProjectId} /> automatically.
28
</div>
29
);
30
}
31
32
if (!upgradeProjectId) return null;
33
34
return (
35
<Alert
36
type="info"
37
message={body()}
38
style={{ marginBottom: "20px" }}
39
action={
40
<Popconfirm
41
placement="bottomRight"
42
title={
43
<div style={{ maxWidth: "400px" }}>
44
Are you sure you want to cancel automatically applying the license
45
to the project after purchasing it? Don't forget to apply the
46
license manually.
47
</div>
48
}
49
onConfirm={upgradeProjectDelete}
50
okText="Yes, cancel"
51
cancelText="No"
52
>
53
<Button size="small" type="link">
54
<Icon name="times" />
55
</Button>
56
</Popconfirm>
57
}
58
/>
59
);
60
};
61
62