Skip to content

Commit

Permalink
feat: recovery email settings structure
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacook committed Nov 22, 2023
1 parent 01a20a0 commit 02d1dd7
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 2 deletions.
48 changes: 48 additions & 0 deletions src/components/settings/RecoveryEmail/AddEmailDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogContentText,
DialogTitle,
IconButton,
TextField,
} from '@mui/material'
import type { ReactElement } from 'react'

import CloseIcon from '@/public/images/common/close.svg'

import css from './styles.module.css'

export default function AddEmailDialog({ open, onClose }: { open: boolean; onClose: () => void }): ReactElement {
const onConfirm = () => {
// TODO: Implement
onClose()
}

return (
<Dialog open={open} onClose={onClose} className={css.dialog}>
<DialogTitle className={css.title}>
Add email address
<IconButton onClick={onClose} className={css.close}>
<CloseIcon />
</IconButton>
</DialogTitle>

<DialogContent dividers className={css.content}>
<DialogContentText color="text.primary" mb={3}>
You will need to sign a message to verify that you are the owner of this Safe Account.
</DialogContentText>

<TextField type="email" label="Email address" variant="outlined" fullWidth InputLabelProps={{ shrink: true }} />
</DialogContent>

<DialogActions className={css.actions}>
<Button onClick={onClose}>Cancel</Button>
<Button variant="contained" onClick={onConfirm}>
Continue
</Button>
</DialogActions>
</Dialog>
)
}
89 changes: 89 additions & 0 deletions src/components/settings/RecoveryEmail/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { Button, Grid, Paper, SvgIcon, Typography } from '@mui/material'
import { VisibilityOutlined } from '@mui/icons-material'
import { useState } from 'react'
import type { ReactElement } from 'react'

import ExternalLink from '@/components/common/ExternalLink'
import AddEmailDialog from './AddEmailDialog'
import EditIcon from '@/public/images/common/edit.svg'

import css from './styles.module.css'

export function RecoveryEmail(): ReactElement {
const [addEmail, setAddEmail] = useState(false)

const onAdd = () => {
setAddEmail(true)
}

const onReveal = () => {
// TODO: Implement
}

const onChange = () => {}

const onClose = () => {}

const randomString = Math.random().toString(36)

return (
<>
<Paper sx={{ p: 4, mb: 2 }}>
<Grid container spacing={3}>
<Grid item sm={4} xs={12}>
<Typography variant="h4" fontWeight={700}>
Recovery email
</Typography>
</Grid>

<Grid item xs>
<Typography mb={2}>
Receive important notifications about recovery attempts and their status. No spam. We promise!{' '}
{/* TODO: Add link */}
<ExternalLink href="#">Learn more</ExternalLink>
</Typography>

<div className={css.display}>
<div className={css.email}>
<VisibilityOutlined fontSize="small" />
<Typography variant="body2" fontWeight={700}>
{randomString + randomString}
</Typography>
<div className={css.blur} />
</div>

<div className={css.buttons}>
<Button
onClick={onReveal}
variant="contained"
size="small"
startIcon={<VisibilityOutlined />}
className={css.button}
disableElevation
>
Reveal
</Button>
<Button
onClick={onChange}
variant="contained"
size="small"
startIcon={<SvgIcon component={EditIcon} inheritViewBox />}
className={css.button}
disableElevation
>
Change
</Button>
</div>
</div>

<Button variant="contained" onClick={onAdd}>
Add email address
</Button>
</Grid>
</Grid>
</Paper>

<AddEmailDialog open={addEmail} onClose={onClose} />
</>
)
}
72 changes: 72 additions & 0 deletions src/components/settings/RecoveryEmail/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* Settings */

.display {
display: flex;
justify-content: space-between;
align-items: center;
background-color: var(--color-background-main);
border: 1px solid var(--color-border-light);
border-radius: 6px;
padding: var(--space-1);
padding-left: var(--space-2);
margin-bottom: var(--space-2);
}

.email {
display: flex;
align-items: center;
gap: var(--space-1);
position: relative;
}

.blur {
backdrop-filter: blur(6px);
border-radius: 6px;
position: absolute;
top: 0;
left: 0;
height: calc(100% + var(--space-3));
width: calc(100% + var(--space-6));
transform: translate(calc(var(--space-2) * -1), calc(calc(var(--space-1) * 1.5) * -1));
}

.buttons {
display: flex;
gap: var(--space-1);
}

.button {
color: var(--color-text-main);
border: 1px solid var(--color-border-light);
background-color: var(--color-background-paper);
padding-left: var(--space-2);
padding-right: var(--space-2);
}

/* Dialog */

.dialog :global(.MuiDialog-paper) {
max-width: 500px;
}

.title {
display: flex;
align-items: center;
font-weight: 700;
padding-top: var(--space-3);
}

.close {
color: var(--color-text-secondary);
margin-left: auto;
}

.content {
padding: var(--space-2) var(--space-3) var(--space-4);
}

.actions {
display: flex;
justify-content: space-between;
padding: var(--space-3);
}
8 changes: 6 additions & 2 deletions src/pages/settings/notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import SettingsHeader from '@/components/settings/SettingsHeader'
import { PushNotifications } from '@/components/settings/PushNotifications'
import { useHasFeature } from '@/hooks/useChains'
import { FEATURES } from '@/utils/chains'
import { RecoveryEmail } from '@/components/settings/RecoveryEmail'

const NotificationsPage: NextPage = () => {
const isNotificationFeatureEnabled = useHasFeature(FEATURES.PUSH_NOTIFICATIONS)
const isRecoveryEnabled = useHasFeature(FEATURES.RECOVERY)

if (!isNotificationFeatureEnabled) {
if (!isNotificationFeatureEnabled || !isRecoveryEnabled) {
return null
}

Expand All @@ -22,7 +24,9 @@ const NotificationsPage: NextPage = () => {
<SettingsHeader />

<main>
<PushNotifications />
{isRecoveryEnabled && <RecoveryEmail />}

{isNotificationFeatureEnabled && <PushNotifications />}
</main>
</>
)
Expand Down

0 comments on commit 02d1dd7

Please sign in to comment.