Skip to content

Commit 345c94f

Browse files
authored
Merge pull request #33 from syscoin/terms-and-conditions
feat: add welcome modal
2 parents 8e78b4f + 475ea9a commit 345c94f

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

components/Bridge/v3/Steps/ConnectValidate.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const BridgeV3ConnectValidateStep: React.FC<
220220
}
221221
label={
222222
<Typography variant="body1">
223-
I agree the{" "}
223+
I agree to the{" "}
224224
<Typography
225225
component={Link}
226226
color="primary"

components/WelcomeModal.tsx

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { Check } from "@mui/icons-material";
2+
import {
3+
Box,
4+
Button,
5+
Link,
6+
List,
7+
ListItem,
8+
ListItemIcon,
9+
Modal,
10+
Typography,
11+
} from "@mui/material";
12+
import React, { useEffect, useState } from "react";
13+
14+
const LOCAL_STORAGE_KEY = "agreeToTerms";
15+
16+
type LinkToNewTabProps = {
17+
link: string;
18+
label?: string;
19+
};
20+
21+
const LinkToNewTab: React.FC<LinkToNewTabProps> = ({ label, link }) => {
22+
return (
23+
<Typography component={Link} color="primary" target="_blank" href={link}>
24+
{label ?? link}
25+
</Typography>
26+
);
27+
};
28+
29+
const terms: (string | React.ReactNode)[] = [
30+
"We will NEVER ask you for your private keys or seed phrase.",
31+
"This software is subject to change.",
32+
<>
33+
Technical support is available only via the ticket system in Syscoin&apos;s
34+
official Discord server at{" "}
35+
<LinkToNewTab link="https://discord.gg/syscoin" />
36+
</>,
37+
"Technical support for an incomplete bridge session must be sought within 75 days from when the session began.",
38+
];
39+
40+
const WelcomeModal = () => {
41+
const [open, setOpen] = useState(false);
42+
43+
const agreeToTerms = () => {
44+
localStorage.setItem(LOCAL_STORAGE_KEY, "true");
45+
setOpen(false);
46+
};
47+
useEffect(() => {
48+
if (localStorage.getItem(LOCAL_STORAGE_KEY) !== "true") {
49+
setOpen(true);
50+
}
51+
}, []);
52+
return (
53+
<Modal open={open}>
54+
<Box
55+
sx={{
56+
position: "absolute",
57+
top: "50%",
58+
left: "50%",
59+
transform: "translate(-50%, -50%)",
60+
width: 500,
61+
bgcolor: "background.paper",
62+
border: "2px solid #000",
63+
boxShadow: 24,
64+
borderRadius: 4,
65+
p: 4,
66+
}}
67+
>
68+
<Typography variant="h5">Welcome to the Syscoin Bridge</Typography>
69+
<List dense sx={{ my: 2 }}>
70+
{terms.map((term, i) => (
71+
<ListItem key={i}>
72+
<ListItemIcon>
73+
<Check />
74+
</ListItemIcon>
75+
<Typography variant="body1">{term}</Typography>
76+
</ListItem>
77+
))}
78+
</List>
79+
<Typography variant="body1">
80+
By clicking the button below, you agree to our{" "}
81+
<LinkToNewTab
82+
link={"/Syscoin Terms and Conditions.pdf"}
83+
label={"Terms and Conditions."}
84+
/>
85+
</Typography>
86+
<Button
87+
variant="contained"
88+
sx={{ mt: 2 }}
89+
fullWidth
90+
onClick={agreeToTerms}
91+
>
92+
Agree to terms
93+
</Button>
94+
</Box>
95+
</Modal>
96+
);
97+
};
98+
99+
export default WelcomeModal;

pages/_app.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import ConnectedWalletProvider from "../contexts/ConnectedWallet/Provider";
77
import MetamaskProvider from "../contexts/Metamask/Provider";
88
import "../styles/globals.css";
99
import NEVMProvider from "@contexts/ConnectedWallet/NEVMProvider";
10+
import WelcomeModal from "components/WelcomeModal";
1011

1112
const queryClient = new QueryClient();
1213

1314
function MyApp({ Component, pageProps, router }: AppProps) {
1415
if (router.pathname.includes("/bridge/v3/")) {
1516
return (
1617
<ThemeProvider theme={theme}>
18+
<WelcomeModal />
1719
<Component {...pageProps} />
1820
</ThemeProvider>
1921
);
@@ -25,6 +27,7 @@ function MyApp({ Component, pageProps, router }: AppProps) {
2527
<NEVMProvider>
2628
<ConnectedWalletProvider>
2729
<ThemeProvider theme={theme}>
30+
<WelcomeModal />
2831
<Component {...pageProps} />
2932
</ThemeProvider>
3033
</ConnectedWalletProvider>

0 commit comments

Comments
 (0)