1
1
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" ;
5
4
import { useLocation } from "react-router-dom" ;
6
5
import type { AuthMethods , BuildInfoResponse } from "api/typesGenerated" ;
7
6
import { CoderIcon } from "components/Icons/CoderIcon" ;
8
7
import { Loader } from "components/Loader/Loader" ;
9
8
import { getApplicationName , getLogoURL } from "utils/appearance" ;
10
9
import { retrieveRedirect } from "utils/redirect" ;
11
10
import { SignInForm } from "./SignInForm" ;
11
+ import { TermsOfServiceLink } from "./TermsOfServiceLink" ;
12
12
13
13
export interface LoginPageViewProps {
14
14
authMethods : AuthMethods | undefined ;
@@ -51,12 +51,21 @@ export const LoginPageView: FC<LoginPageViewProps> = ({
51
51
< CoderIcon fill = "white" opacity = { 1 } css = { styles . icon } />
52
52
) ;
53
53
54
+ const [ tosAccepted , setTosAccepted ] = useState ( false ) ;
55
+ const tosAcceptanceRequired =
56
+ authMethods ?. terms_of_service_url && ! tosAccepted ;
57
+
54
58
return (
55
59
< div css = { styles . root } >
56
60
< div css = { styles . container } >
57
61
{ applicationLogo }
58
62
{ isLoading ? (
59
63
< Loader />
64
+ ) : tosAcceptanceRequired ? (
65
+ < >
66
+ < TermsOfServiceLink url = { authMethods . terms_of_service_url } />
67
+ < Button onClick = { ( ) => setTosAccepted ( true ) } > I agree</ Button >
68
+ </ >
60
69
) : (
61
70
< SignInForm
62
71
authMethods = { authMethods }
@@ -72,20 +81,11 @@ export const LoginPageView: FC<LoginPageViewProps> = ({
72
81
Copyright © { new Date ( ) . getFullYear ( ) } Coder Technologies, Inc.
73
82
</ div >
74
83
< 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
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
+ />
89
89
) }
90
90
</ footer >
91
91
</ div >
0 commit comments