Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/components/landing/sign-in.tsx
5996 views
1
/*
2
* This file is part of CoCalc: Copyright © 2021 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
import { join } from "path";
9
import { CSSProperties, ReactNode } from "react";
10
11
import { Icon } from "@cocalc/frontend/components/icon";
12
import SSO from "components/auth/sso";
13
import { Paragraph } from "components/misc";
14
import basePath from "lib/base-path";
15
import { useCustomize } from "lib/customize";
16
17
interface Props {
18
startup?: ReactNode; // customize the button, e.g. "Start Jupyter Now".
19
hideFree?: boolean;
20
style?: React.CSSProperties;
21
emphasize?: boolean;
22
}
23
24
const STYLE: CSSProperties = {
25
textAlign: "center",
26
padding: "30px 15px",
27
marginBottom: "0",
28
} as const;
29
30
export default function SignIn({ startup, hideFree, style, emphasize }: Props) {
31
const { anonymousSignup, siteName, account, emailSignup } = useCustomize();
32
style = { ...STYLE, ...style };
33
const router = useRouter();
34
35
if (account != null) {
36
return (
37
<Paragraph style={style}>
38
<Button
39
size="large"
40
onClick={() => (window.location.href = join(basePath, "projects"))}
41
title={`Open the ${siteName} app and view your projects.`}
42
type="primary"
43
icon={<Icon name="edit" />}
44
>
45
Your {siteName} Projects
46
</Button>
47
</Paragraph>
48
);
49
}
50
51
// if email signup is not allowed, we show all SSO options -- #7557
52
function renderAccountRegistration() {
53
if (emailSignup) {
54
return (
55
<>
56
<Button
57
size="large"
58
style={{ margin: "10px" }}
59
title={"Create a new account."}
60
onClick={() => router.push("/auth/sign-up")}
61
type={emphasize ? "primary" : undefined}
62
>
63
Sign Up
64
</Button>
65
<Button
66
size="large"
67
style={{ margin: "10px" }}
68
title={
69
"Either create a new account or sign into an existing account."
70
}
71
onClick={() => router.push("/auth/sign-in")}
72
type={emphasize ? "primary" : undefined}
73
>
74
Sign In
75
</Button>
76
</>
77
);
78
} else {
79
return (
80
<SSO
81
header={
82
<Paragraph style={{ fontSize: "18px", fontWeight: "bold" }}>
83
Sign in
84
</Paragraph>
85
}
86
showAll={true}
87
showName={true}
88
/>
89
);
90
}
91
}
92
93
return (
94
<Paragraph style={style}>
95
{anonymousSignup && (
96
<Button
97
size="large"
98
type="primary"
99
style={{ margin: "10px" }}
100
title={"Try now without creating an account!"}
101
onClick={() => router.push("/auth/try")}
102
>
103
Try&nbsp;{startup ?? siteName}&nbsp;Now
104
</Button>
105
)}
106
{renderAccountRegistration()}
107
{!hideFree ? (
108
<div style={{ padding: "15px 0 0 0" }}>
109
Start free today. Upgrade later.
110
</div>
111
) : undefined}
112
</Paragraph>
113
);
114
}
115
116