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/frontend/billing/util.tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import { Rendered } from "../app-framework";
7
import { Icon } from "../components/icon";
8
import { PROJECT_UPGRADES } from "@cocalc/util/schema";
9
import { Tip } from "../components/tip";
10
import { Gap } from "../components/gap";
11
import { round1, plural } from "@cocalc/util/misc";
12
import { stripeAmount } from "@cocalc/util/misc";
13
14
export function powered_by_stripe(): Rendered {
15
return (
16
<span>
17
Powered by{" "}
18
<a
19
href="https://stripe.com/"
20
rel="noopener"
21
target="_blank"
22
style={{ top: "7px", position: "relative", fontSize: "23pt" }}
23
>
24
<Icon name="cc-stripe" />
25
</a>
26
</span>
27
);
28
}
29
30
export function render_project_quota(name: string, value: number): Rendered {
31
const data = PROJECT_UPGRADES.params[name];
32
if (data == null) {
33
throw Error(`unknown quota ${name}`);
34
}
35
let amount: number = value * data.pricing_factor;
36
let unit: string = data.pricing_unit;
37
if (unit === "day" && amount < 2) {
38
amount = 24 * amount;
39
unit = "hour";
40
}
41
return (
42
<div key={name} style={{ marginBottom: "5px", marginLeft: "10px" }}>
43
<Tip title={data.display} tip={data.desc}>
44
<span style={{ fontWeight: "bold", color: "#666" }}>
45
{round1(amount)} {plural(amount, unit)}
46
</span>
47
<Gap />
48
<span style={{ color: "#999" }}>{data.display}</span>
49
</Tip>
50
</div>
51
);
52
}
53
54
export function render_amount(amount: number, currency: string) {
55
return (
56
<div style={{ float: "right" }}>{stripeAmount(amount, currency)}</div>
57
);
58
}
59
60