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/course/pay-banner.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
/*
7
A banner across the top of a course that appears if the instructor is not paying
8
in any way, so they know they should.
9
10
This banner only shows up if commerical is set for hub configuration.
11
*/
12
13
import { CSS, useTypedRedux } from "../app-framework";
14
import { Alert } from "antd";
15
import { CourseSettingsRecord } from "./store";
16
import { Icon } from "../components";
17
18
interface PayBannerProps {
19
settings: CourseSettingsRecord;
20
num_students: number;
21
show_config: () => void;
22
}
23
24
export function PayBanner({
25
settings,
26
num_students,
27
show_config,
28
}: PayBannerProps) {
29
const is_commercial = useTypedRedux("customize", "is_commercial");
30
31
if (!is_commercial) {
32
return <></>;
33
}
34
35
function paid(): boolean {
36
if ((num_students != null ? num_students : 0) <= 3) {
37
// don't bother at first
38
return true;
39
}
40
if (settings.get("student_pay")) {
41
return true;
42
}
43
if (settings.get("institute_pay")) {
44
return true;
45
}
46
return false;
47
}
48
49
if (paid()) {
50
return <span />;
51
}
52
53
let style, linkStyle: CSS;
54
if ((num_students != null ? num_students : 0) >= 20) {
55
// Show a harsh error.
56
style = {
57
background: "red",
58
color: "white",
59
fontSize: "16pt",
60
fontWeight: "bold",
61
margin: "15px",
62
};
63
linkStyle = { color: "white" };
64
} else {
65
style = {
66
fontSize: "12pt",
67
color: "#666",
68
margin: "15px",
69
};
70
linkStyle = {};
71
}
72
73
return (
74
<Alert
75
type="warning"
76
style={style}
77
message={
78
<div style={{ display: "flex" }}>
79
<Icon name="exclamation-triangle" />
80
<div style={{ flex: 1, textAlign: "center" }}>
81
<a onClick={show_config} style={linkStyle}>
82
Configure either the student or institute pay option...
83
</a>
84
</div>
85
<Icon name="exclamation-triangle" />
86
</div>
87
}
88
/>
89
);
90
}
91
92