-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-signup): add send verification email and verification requir…
…ed page
- Loading branch information
Showing
15 changed files
with
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createRequestHook } from '@pipeline/requests-status'; | ||
import { actions } from './slice'; | ||
|
||
export const useResendVerificationEmail = createRequestHook( | ||
'auth.resendVerificationEmail', | ||
actions.resendEmailVerification, | ||
); |
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import { reducer, actions, name, selectors } from './slice'; | ||
import { reducer, actions, name, selectors, AuthUser } from './slice'; | ||
import saga from './saga'; | ||
import useLoggedUser from './useLoggedUser'; | ||
import { useResendVerificationEmail } from './hooks'; | ||
|
||
export { reducer, actions, name, saga, selectors }; | ||
export { reducer, actions, name, saga, selectors, useLoggedUser, useResendVerificationEmail }; | ||
|
||
export type { AuthUser }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useSelector } from 'react-redux'; | ||
import { selectors } from './slice'; | ||
|
||
/** | ||
* Get current logged user info. null if not logged. | ||
*/ | ||
export default function useLoggedUser() { | ||
const loggedUser = useSelector(selectors.getCurrentUser); | ||
return loggedUser; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { RoutingPath } from './routingPath'; | ||
import PrivateRoute from './PrivateRoute'; | ||
import useNavigateOnCondition from './useNavigateOnCondition'; | ||
|
||
export { RoutingPath, PrivateRoute }; | ||
export { RoutingPath, PrivateRoute, useNavigateOnCondition }; |
23 changes: 23 additions & 0 deletions
23
packages/game-app/src/_shared/routing/useNavigateOnCondition.ts
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,23 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { RoutingPath } from './routingPath'; | ||
|
||
/** | ||
* | ||
* Conditionally navigate to the provided route once the condition becomes true | ||
* | ||
* @param condition the condition to check | ||
* @param route the route to go | ||
*/ | ||
export default function useNavigateOnCondition(condition: boolean, route: RoutingPath) { | ||
const [alreadyNavigated, setAlreadyNavigated] = useState<boolean>(false); | ||
|
||
const history = useHistory(); | ||
|
||
useEffect(() => { | ||
if (condition && !alreadyNavigated) { | ||
history.push(route); | ||
setAlreadyNavigated(true); | ||
} | ||
}, [condition, history, route, alreadyNavigated]); | ||
} |
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
24 changes: 24 additions & 0 deletions
24
...es/game-app/src/signup/components/EmailVerificationRequired/EmailVerificationRequired.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,24 @@ | ||
import React from 'react'; | ||
import { useTranslate } from '@pipeline/i18n'; | ||
import { useResendVerificationEmail } from '@pipeline/auth'; | ||
|
||
type Props = {}; | ||
|
||
const EmailVerificationRequired: React.FC<Props> = () => { | ||
const t = useTranslate(); | ||
|
||
const { call: resendEmail, success, loading, translatedError } = useResendVerificationEmail(); | ||
|
||
return ( | ||
<div> | ||
{t('signup.verificationRequired.message')} | ||
|
||
<button onClick={resendEmail}>{t('signup.verificationRequired.resend')}</button> | ||
{success ? t('signup.verificationRequired.resendSuccess') : null} | ||
</div> | ||
); | ||
}; | ||
|
||
EmailVerificationRequired.displayName = 'EmailVerificationRequired'; | ||
|
||
export default EmailVerificationRequired; |
3 changes: 3 additions & 0 deletions
3
packages/game-app/src/signup/components/EmailVerificationRequired/index.ts
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,3 @@ | ||
import EmailVerificationRequired from './EmailVerificationRequired'; | ||
|
||
export default EmailVerificationRequired; |
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