-
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 email verification functionality
- Loading branch information
Showing
13 changed files
with
79 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { reducer, actions, name, selectors, AuthUser } from './slice'; | ||
import saga from './saga'; | ||
import useLoggedUser from './useLoggedUser'; | ||
import { useResendVerificationEmail } from './hooks'; | ||
import { useEmailVerification, useResendVerificationEmail } from './hooks'; | ||
|
||
export { reducer, actions, name, saga, selectors, useLoggedUser, useResendVerificationEmail }; | ||
export { reducer, actions, name, saga, selectors, useLoggedUser, useResendVerificationEmail, useEmailVerification }; | ||
|
||
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
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,5 +1,6 @@ | ||
import { RoutingPath } from './routingPath'; | ||
import PrivateRoute from './PrivateRoute'; | ||
import useNavigateOnCondition from './useNavigateOnCondition'; | ||
import { useQueryParams } from './useQueryParams'; | ||
|
||
export { RoutingPath, PrivateRoute, useNavigateOnCondition }; | ||
export { RoutingPath, PrivateRoute, useNavigateOnCondition, useQueryParams }; |
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,9 @@ | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
/** | ||
* Hook to parse query params and get them as object | ||
*/ | ||
export function useQueryParams<T = any>() { | ||
const { search } = useLocation(); | ||
return (Object.fromEntries(new URLSearchParams(search).entries()) as unknown) as T; | ||
} |
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
34 changes: 34 additions & 0 deletions
34
packages/game-app/src/signup/components/VerifyEmail/VerifyEmail.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,34 @@ | ||
import React, { useEffect } from 'react'; | ||
import { VerifyEmailParams } from '../../types/emailValidationParams'; | ||
import { RoutingPath, useNavigateOnCondition, useQueryParams } from '@pipeline/routing'; | ||
import { useEmailVerification, useLoggedUser } from '@pipeline/auth'; | ||
|
||
type Props = {}; | ||
|
||
const VerifyEmail: React.FC<Props> = () => { | ||
let params = useQueryParams<VerifyEmailParams>(); | ||
|
||
const { call, success, translatedError } = useEmailVerification(); | ||
const loggedUser = useLoggedUser(); | ||
|
||
useEffect(() => { | ||
call({ code: params.oobCode }); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
useNavigateOnCondition(success, loggedUser ? RoutingPath.Dashboard : RoutingPath.Login); | ||
|
||
return ( | ||
<div> | ||
{translatedError ? ( | ||
<div> | ||
<span className="error-message">{translatedError}</span> | ||
</div> | ||
) : null} | ||
</div> | ||
); | ||
}; | ||
|
||
VerifyEmail.displayName = 'VerifyEmail'; | ||
|
||
export default VerifyEmail; |
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 VerifyEmail from './VerifyEmail'; | ||
|
||
export default VerifyEmail; |
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,6 @@ | ||
export interface VerifyEmailParams { | ||
mode: string; | ||
lang: string; | ||
oobCode: string; | ||
apiKey: string; | ||
} |