-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(user): add ability to add password to a social account
feat(user): add resend password reset email button
- Loading branch information
1 parent
0e92a58
commit b3aa739
Showing
10 changed files
with
227 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/components/DeleteAccountPasswordWarning/DeleteAccountPasswordWarning.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
@use 'src/styles/variables'; | ||
|
||
.formFeedback { | ||
margin-bottom: -24px; | ||
} | ||
|
||
.formContainer { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 15px; | ||
align-items: center; | ||
padding: 27px; | ||
} | ||
|
||
.passwordButtonsContainer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
gap: 8px; | ||
width: 100%; | ||
} | ||
|
||
.buttonsContainer { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
align-items: center; | ||
width: 100%; | ||
gap: 16px; | ||
} | ||
|
||
.heading { | ||
width: 50%; | ||
margin-bottom: 5px; | ||
color: variables.$gray-white; | ||
font-weight: 400; | ||
font-size: 30px; | ||
line-height: 28px; | ||
text-align: center; | ||
} | ||
|
||
.paragraph { | ||
width: 100%; | ||
margin: 0; | ||
padding: 0; | ||
color: variables.$gray-white; | ||
font-size: 16px; | ||
line-height: 20px; | ||
text-align: left; | ||
} | ||
|
||
.button { | ||
margin: auto; | ||
} |
59 changes: 59 additions & 0 deletions
59
src/components/DeleteAccountPasswordWarning/DeleteAccountPasswordWarning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
import { useNavigate, useLocation } from 'react-router'; | ||
import { useCallback, useState } from 'react'; | ||
|
||
import Button from '../Button/Button'; | ||
|
||
import styles from './DeleteAccountPasswordWarning.module.scss'; | ||
|
||
import { addQueryParam, removeQueryParam } from '#src/utils/location'; | ||
import { useAccountStore } from '#src/stores/AccountStore'; | ||
import { resetPassword } from '#src/stores/AccountController'; | ||
import FormFeedback from '#components/FormFeedback/FormFeedback'; | ||
|
||
const DeleteAccountPasswordWarning = () => { | ||
const { t } = useTranslation('user'); | ||
const email = useAccountStore((state) => state.user?.email); | ||
const [errorMessage, setErrorMessage] = useState<string>(); | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
|
||
const handleCancel = useCallback(() => { | ||
navigate(removeQueryParam(location, 'u'), { replace: true }); | ||
}, [location, navigate]); | ||
const proceedToAddPasswordClickHandler = async () => { | ||
try { | ||
if (email) { | ||
await resetPassword(email, ''); | ||
navigate(addQueryParam(location, 'u', 'add-password')); | ||
} | ||
} catch (error: unknown) { | ||
setErrorMessage(t('account.add_password_error')); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={styles.formContainer}> | ||
{errorMessage && ( | ||
<div className={styles.formFeedback}> | ||
<FormFeedback variant="error">{errorMessage}</FormFeedback> | ||
</div> | ||
)} | ||
<h2 className={styles.heading}>{t('account.delete_account_password_warning.title')}</h2> | ||
<p className={styles.paragraph}>{t('account.delete_account_password_warning.text')}</p> | ||
<div className={styles.passwordButtonsContainer}> | ||
<Button | ||
type="submit" | ||
onClick={proceedToAddPasswordClickHandler} | ||
className={styles.button} | ||
color="primary" | ||
fullWidth | ||
label={t('account.proceed_to_adding_a_password')} | ||
/> | ||
<Button type="button" onClick={handleCancel} className={styles.button} variant="text" fullWidth label={t('account.cancel')} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DeleteAccountPasswordWarning; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.