Path: blob/master/src/packages/next/components/landing/sign-in.tsx
5996 views
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Button } from "antd";6import { useRouter } from "next/router";7import { join } from "path";8import { CSSProperties, ReactNode } from "react";910import { Icon } from "@cocalc/frontend/components/icon";11import SSO from "components/auth/sso";12import { Paragraph } from "components/misc";13import basePath from "lib/base-path";14import { useCustomize } from "lib/customize";1516interface Props {17startup?: ReactNode; // customize the button, e.g. "Start Jupyter Now".18hideFree?: boolean;19style?: React.CSSProperties;20emphasize?: boolean;21}2223const STYLE: CSSProperties = {24textAlign: "center",25padding: "30px 15px",26marginBottom: "0",27} as const;2829export default function SignIn({ startup, hideFree, style, emphasize }: Props) {30const { anonymousSignup, siteName, account, emailSignup } = useCustomize();31style = { ...STYLE, ...style };32const router = useRouter();3334if (account != null) {35return (36<Paragraph style={style}>37<Button38size="large"39onClick={() => (window.location.href = join(basePath, "projects"))}40title={`Open the ${siteName} app and view your projects.`}41type="primary"42icon={<Icon name="edit" />}43>44Your {siteName} Projects45</Button>46</Paragraph>47);48}4950// if email signup is not allowed, we show all SSO options -- #755751function renderAccountRegistration() {52if (emailSignup) {53return (54<>55<Button56size="large"57style={{ margin: "10px" }}58title={"Create a new account."}59onClick={() => router.push("/auth/sign-up")}60type={emphasize ? "primary" : undefined}61>62Sign Up63</Button>64<Button65size="large"66style={{ margin: "10px" }}67title={68"Either create a new account or sign into an existing account."69}70onClick={() => router.push("/auth/sign-in")}71type={emphasize ? "primary" : undefined}72>73Sign In74</Button>75</>76);77} else {78return (79<SSO80header={81<Paragraph style={{ fontSize: "18px", fontWeight: "bold" }}>82Sign in83</Paragraph>84}85showAll={true}86showName={true}87/>88);89}90}9192return (93<Paragraph style={style}>94{anonymousSignup && (95<Button96size="large"97type="primary"98style={{ margin: "10px" }}99title={"Try now without creating an account!"}100onClick={() => router.push("/auth/try")}101>102Try {startup ?? siteName} Now103</Button>104)}105{renderAccountRegistration()}106{!hideFree ? (107<div style={{ padding: "15px 0 0 0" }}>108Start free today. Upgrade later.109</div>110) : undefined}111</Paragraph>112);113}114115116