Skip to content

Commit

Permalink
fix: Close accordion on form submit
Browse files Browse the repository at this point in the history
  • Loading branch information
usame-algan committed Oct 26, 2023
1 parent 9b77c84 commit d8775d1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions public/images/common/bar-chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ const ExportMPCAccountModal = ({ onClose, open }: { onClose: () => void; open: b
)}
{error && <ErrorMessage className={css.modalError}>{error}</ErrorMessage>}

<Box display="flex" flexDirection="row" justifyContent="space-between" alignItems="center" width="100%">
<Box
display="flex"
flexDirection="row"
justifyContent="space-between"
alignItems="center"
width="100%"
mt={2}
>
<Button variant="outlined" onClick={handleClose}>
Close
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const SocialSignerMFA = () => {
const mpcCoreKit = useMPC()
const [passwordStrength, setPasswordStrength] = useState<PasswordStrength>()
const [submitError, setSubmitError] = useState<string>()
const [open, setOpen] = useState<boolean>(false)

Check warning on line 86 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

const formMethods = useForm<PasswordFormData>({
mode: 'all',
Expand All @@ -107,6 +108,8 @@ const SocialSignerMFA = () => {

try {
await enableMFA(mpcCoreKit, data)
onReset()

Check warning on line 111 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
setOpen(false)

Check warning on line 112 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
} catch (e) {
setSubmitError('The password you entered is incorrect. Please try again.')
}

Check warning on line 115 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
Expand All @@ -118,6 +121,10 @@ const SocialSignerMFA = () => {
setSubmitError(undefined)
}

const toggleAccordion = () => {

Check warning on line 124 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
setOpen((prev) => !prev)

Check warning on line 125 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 125 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 125 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
}

Check warning on line 126 in src/components/settings/SecurityLogin/SocialSignerMFA/index.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

const confirmPassword = watch(PasswordFieldNames.confirmPassword)
const newPassword = watch(PasswordFieldNames.newPassword)
const passwordsEmpty = confirmPassword === '' && newPassword === ''
Expand All @@ -137,7 +144,7 @@ const SocialSignerMFA = () => {
Protect your social login signer with a password. It will be used to restore access in another browser or on
another device.
</Typography>
<Accordion>
<Accordion expanded={open} defaultExpanded={false} onChange={toggleAccordion}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<Box display="flex" alignItems="center" gap={1}>
<SvgIcon component={CheckIcon} sx={{ color: isPasswordSet ? 'success.main' : 'border.light' }} />
Expand Down
4 changes: 4 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ input[type='number'] {
stroke: var(--color-border-main);
}

.illustration-very-light-stroke {
stroke: var(--color-border-light);
}

.illustration-background-stroke {
stroke: var(--color-logo-background);
}
Expand Down

0 comments on commit d8775d1

Please sign in to comment.