Skip to content

Commit 43f20ea

Browse files
committed
i like
1 parent e8550dc commit 43f20ea

File tree

2 files changed

+45
-17
lines changed

2 files changed

+45
-17
lines changed

site/src/pages/LoginPage/LoginPageView.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import type { Interpolation, Theme } from "@emotion/react";
2-
import LaunchIcon from "@mui/icons-material/LaunchOutlined";
3-
import Link from "@mui/material/Link";
4-
import type { FC } from "react";
2+
import Button from "@mui/material/Button";
3+
import { type FC, useState } from "react";
54
import { useLocation } from "react-router-dom";
65
import type { AuthMethods, BuildInfoResponse } from "api/typesGenerated";
76
import { CoderIcon } from "components/Icons/CoderIcon";
87
import { Loader } from "components/Loader/Loader";
98
import { getApplicationName, getLogoURL } from "utils/appearance";
109
import { retrieveRedirect } from "utils/redirect";
1110
import { SignInForm } from "./SignInForm";
11+
import { TermsOfServiceLink } from "./TermsOfServiceLink";
1212

1313
export interface LoginPageViewProps {
1414
authMethods: AuthMethods | undefined;
@@ -51,12 +51,21 @@ export const LoginPageView: FC<LoginPageViewProps> = ({
5151
<CoderIcon fill="white" opacity={1} css={styles.icon} />
5252
);
5353

54+
const [tosAccepted, setTosAccepted] = useState(false);
55+
const tosAcceptanceRequired =
56+
authMethods?.terms_of_service_url && !tosAccepted;
57+
5458
return (
5559
<div css={styles.root}>
5660
<div css={styles.container}>
5761
{applicationLogo}
5862
{isLoading ? (
5963
<Loader />
64+
) : tosAcceptanceRequired ? (
65+
<>
66+
<TermsOfServiceLink url={authMethods.terms_of_service_url} />
67+
<Button onClick={() => setTosAccepted(true)}>I agree</Button>
68+
</>
6069
) : (
6170
<SignInForm
6271
authMethods={authMethods}
@@ -72,20 +81,11 @@ export const LoginPageView: FC<LoginPageViewProps> = ({
7281
Copyright &copy; {new Date().getFullYear()} Coder Technologies, Inc.
7382
</div>
7483
<div>{buildInfo?.version}</div>
75-
76-
{authMethods?.terms_of_service_url && (
77-
<div css={{ paddingTop: 12, fontSize: 12 }}>
78-
By continuing, you agree to the{" "}
79-
<Link
80-
css={{ fontWeight: 500 }}
81-
href={authMethods.terms_of_service_url}
82-
target="_blank"
83-
rel="noreferrer"
84-
>
85-
Terms of Service&nbsp;
86-
<LaunchIcon css={{ fontSize: 12 }} />
87-
</Link>
88-
</div>
84+
{tosAccepted && (
85+
<TermsOfServiceLink
86+
url={authMethods?.terms_of_service_url}
87+
css={{ fontSize: 12 }}
88+
/>
8989
)}
9090
</footer>
9191
</div>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import LaunchIcon from "@mui/icons-material/LaunchOutlined";
2+
import Link from "@mui/material/Link";
3+
import type { FC } from "react";
4+
5+
interface TermsOfServiceLinkProps {
6+
className?: string;
7+
url?: string;
8+
}
9+
10+
export const TermsOfServiceLink: FC<TermsOfServiceLinkProps> = ({
11+
className,
12+
url,
13+
}) => {
14+
return (
15+
<div css={{ paddingTop: 12, fontSize: 16 }} className={className}>
16+
By continuing, you agree to the{" "}
17+
<Link
18+
css={{ fontWeight: 500, textWrap: "nowrap" }}
19+
href={url}
20+
target="_blank"
21+
rel="noreferrer"
22+
>
23+
Terms of Service&nbsp;
24+
<LaunchIcon css={{ fontSize: 12 }} />
25+
</Link>
26+
</div>
27+
);
28+
};

0 commit comments

Comments
 (0)