|
| 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'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; |
0 commit comments