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 e4662bc
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit e4662bc

Please sign in to comment.