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/link.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 { Button } from "antd";
7
import { useRouter } from "next/router";
8
9
import { Icon } from "@cocalc/frontend/components/icon";
10
import { Uptime } from "@cocalc/util/consts/site-license";
11
12
export interface StoreConf {
13
run_limit: number;
14
disk: number;
15
ram: number;
16
cpu: number;
17
user: "academic" | "business";
18
start?: Date;
19
end?: Date;
20
uptime: Uptime;
21
period?: "monthly" | "yearly" | "range";
22
}
23
24
interface Props {
25
conf?: StoreConf;
26
}
27
28
const STYLE: React.CSSProperties = {
29
fontSize: "150%",
30
fontWeight: "bold",
31
textAlign: "center",
32
marginTop: "30px",
33
} as const;
34
35
export function LinkToStore(props: Props) {
36
const { conf } = props;
37
38
const router = useRouter();
39
40
const params =
41
conf != null
42
? Object.entries(conf)
43
.map(([key, value]) => `${key}=${value}`)
44
.join("&")
45
: "";
46
47
const url = `/store/site-license?${params}`;
48
49
const label = conf != null ? "Select" : `Store`;
50
51
return (
52
<div style={STYLE}>
53
<Button
54
size={"large"}
55
type={"primary"}
56
onClick={() => router.push(url)}
57
icon={<Icon name="shopping-cart" />}
58
>
59
{label}
60
</Button>
61
</div>
62
);
63
}
64
65