-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clerk-js): Create <ResetPasswordSuccess /> page
Display a success message after password was successfully changed.
- Loading branch information
1 parent
6155f5b
commit 3fbf8e7
Showing
8 changed files
with
95 additions
and
27 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
63 changes: 63 additions & 0 deletions
63
packages/clerk-js/src/ui/components/SignIn/ResetPasswordSuccess.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,63 @@ | ||
import { useEffect } from 'react'; | ||
|
||
import { withRedirectToHomeSingleSessionGuard } from '../../common'; | ||
import { useCoreClerk, useSignInContext } from '../../contexts'; | ||
import { Col, descriptors, localizationKeys, Text } from '../../customizables'; | ||
import { Card, CardAlert, Header, useCardState, withCardStateProvider } from '../../elements'; | ||
import { Flex, Spinner } from '../../primitives'; | ||
import { useRouter } from '../../router'; | ||
|
||
const useActivateSession = () => { | ||
const { queryString } = useRouter(); | ||
const { setActive } = useCoreClerk(); | ||
const { navigateAfterSignIn } = useSignInContext(); | ||
|
||
useEffect(() => { | ||
let timeoutId: ReturnType<typeof setTimeout>; | ||
if (new URLSearchParams(queryString).has('createdSessionId')) { | ||
const createdSessionId = new URLSearchParams(queryString).get('createdSessionId'); | ||
timeoutId = setTimeout(() => { | ||
void setActive({ session: createdSessionId, beforeEmit: navigateAfterSignIn }); | ||
}, 2000); | ||
} | ||
|
||
return () => { | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
}; | ||
}); | ||
}; | ||
export const _ResetPassword = () => { | ||
const card = useCardState(); | ||
useActivateSession(); | ||
return ( | ||
<Card> | ||
<CardAlert>{card.error}</CardAlert> | ||
<Header.Root> | ||
<Header.Title localizationKey={localizationKeys('signIn.resetPassword.title')} /> | ||
</Header.Root> | ||
<Col | ||
elementDescriptor={descriptors.main} | ||
gap={8} | ||
> | ||
<Text | ||
localizationKey={localizationKeys('signIn.resetPassword.successMessage')} | ||
variant='smallRegular' | ||
colorScheme='inherit' | ||
/> | ||
<Flex | ||
direction='row' | ||
center | ||
> | ||
<Spinner | ||
size='xl' | ||
colorScheme='primary' | ||
/> | ||
</Flex> | ||
</Col> | ||
</Card> | ||
); | ||
}; | ||
|
||
export const ResetPasswordSuccess = withRedirectToHomeSingleSessionGuard(withCardStateProvider(_ResetPassword)); |
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
12 changes: 11 additions & 1 deletion
12
packages/clerk-js/src/ui/components/SignIn/SignInFactorOneForgotPasswordCard.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
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