-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Hugo Marques <[email protected]>
- Loading branch information
1 parent
123cccc
commit 6a12f54
Showing
7 changed files
with
150 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ module.exports = { | |
'no-underscore-dangle': 'off', | ||
'prefer-destructuring': 'off' | ||
} | ||
}; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,26 @@ | ||
import { ClientConfig } from '@prismicio/client'; | ||
import { GetStaticProps } from 'next'; | ||
import Prismic from '../libs/Prismic/Prismic'; | ||
import VerifyEmail from 'src/views/VerifyEmail'; | ||
|
||
export const getStaticProps: GetStaticProps = async ({ | ||
locale: lang, | ||
previewData | ||
}) => { | ||
const clientOptions = previewData as ClientConfig; | ||
const data = await Prismic.getByTypes({ | ||
clientOptions, | ||
lang, | ||
types: 'pwa-view-beneficiary' | ||
}); | ||
|
||
return { | ||
props: { | ||
data, | ||
view: 'beneficiary', | ||
withPreview: !!previewData | ||
} | ||
}; | ||
}; | ||
|
||
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
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,90 @@ | ||
import { Box, Button, Text, ViewContainer, toast } from '@impact-market/ui'; | ||
import { useVerifyEmailMutation } from 'src/api/user'; | ||
import CheckPermission from 'src/components/CheckPermission'; | ||
import React, { useEffect, useState } from 'react'; | ||
import useFilters from 'src/hooks/useFilters'; | ||
|
||
const VerifyEmail: React.FC<{ isLoading?: boolean }> = () => { | ||
const { getByKey, update } = useFilters(); | ||
const [isLoading, setIsLoading] = useState(false); | ||
const [emailConfirmed, setEmailConfirmed] = useState(false); | ||
const [verifyEmail] = useVerifyEmailMutation(); | ||
|
||
useEffect(() => { | ||
if (getByKey('verified')) { | ||
setEmailConfirmed(true); | ||
} | ||
}, [getByKey('verified')]); | ||
|
||
const confirmVerification = async () => { | ||
try { | ||
setIsLoading(true); | ||
|
||
await verifyEmail({ | ||
code: getByKey('code'), | ||
email: getByKey('email'), | ||
userId: getByKey('userId') | ||
}).unwrap(); | ||
|
||
update('verified', 1); | ||
setIsLoading(false); | ||
setEmailConfirmed(true); | ||
} catch (error) { | ||
console.log(error); | ||
toast.error('Something went wrong. Please try again later.'); | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
const showPage = | ||
!!getByKey('code') && !!getByKey('email') && !!getByKey('userId'); | ||
|
||
if (!showPage) { | ||
return <CheckPermission />; | ||
} | ||
|
||
return ( | ||
<ViewContainer {...({} as any)}> | ||
<Box | ||
column | ||
fLayout="start" | ||
flex | ||
style={{ gap: '2rem', margin: '0 auto', maxWidth: '500px' }} | ||
> | ||
<img | ||
alt="impactMarket logo" | ||
src="/img/logo.svg" | ||
width="125px" | ||
/> | ||
<div> | ||
<Text | ||
g900 | ||
semibold | ||
style={{ fontSize: '1.5rem', lineHeight: '2rem' }} | ||
> | ||
{emailConfirmed | ||
? 'Email Confirmed.' | ||
: 'Confirm your email.'} | ||
</Text> | ||
<Text g500 large mt="0.5rem"> | ||
{emailConfirmed | ||
? 'Thanks for confirming your email. You can now close this page and go back to claim your rewards.' | ||
: 'In order to be able to claim your rewards, please confirm your email by clicking the button below.'} | ||
</Text> | ||
</div> | ||
{!emailConfirmed && ( | ||
<Box flex> | ||
<Button | ||
isLoading={isLoading} | ||
onClick={confirmVerification} | ||
> | ||
<Text>Confirm Email Address</Text> | ||
</Button> | ||
</Box> | ||
)} | ||
</Box> | ||
</ViewContainer> | ||
); | ||
}; | ||
|
||
export default VerifyEmail; |