From f08f6ca0a9d337efff280d4d1669a41b5d9c31c2 Mon Sep 17 00:00:00 2001 From: piotrruss Date: Thu, 2 Sep 2021 22:28:11 +0200 Subject: finish translations, force maximize --- pages/verify.js | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'pages/verify.js') diff --git a/pages/verify.js b/pages/verify.js index 5991035..2f7c863 100644 --- a/pages/verify.js +++ b/pages/verify.js @@ -1,18 +1,21 @@ import styles from 'styles/Main.module.scss' import {useState} from 'react' -import useUser from 'lib/useUser' -import fetchJson from 'lib/fetchJson' +import useUser from 'hooks/useUser' +import useSettings from 'hooks/useSettings' +import fetchJson from 'helpers/fetchJson' import {Layout} from 'components' import Splash from 'components/Splash' const Verify = () => { + const {t} = useSettings() + const [errorMsg, setErrorMsg] = useState('') + const [loading, setLoading] = useState(false) + const [sending, setSending] = useState(false) + const [resent, setResent] = useState(false) const {user, mutateUser} = useUser({ redirectToLogin: true, redirectToApps: true, }) - const [errorMsg, setErrorMsg] = useState('') - const [sending, setSending] = useState(false) - const [resent, setResent] = useState(false) const handleSendMail = async e => { e.preventDefault() @@ -22,7 +25,7 @@ const Verify = () => { await fetch('/api/verify') setResent(true) } catch (error) { - setErrorMsg('Could not send verification email') + setErrorMsg(t('verification_mail_error')) } finally { setSending(false) } @@ -30,6 +33,7 @@ const Verify = () => { const handleKey = async e => { e.preventDefault() + setLoading(true) const key = e.currentTarget.key.value try { mutateUser( @@ -40,36 +44,36 @@ const Verify = () => { }) ) } catch (err) { - setErrorMsg('Could not verify user') + setErrorMsg(t('verification_error')) + } finally { + setLoading(false) } } return ( - {!user + {!user || loading ? ( -
- -
+ ) : (
-

One last step missing

-

{`To start using Notes App type the verification code we sent to your email (${user.email}):`}

+

{t('verification_title')}

+

{`${t('verification_text')} ${user.email}`}

- - + +
{ sending ? ( -

Sending...

+

{t('sending')}

) : ( resent ? ( -

Mail was successfully sent again, check your mailbox!

+

{t('verification_sent_again')}

) : ( -

If you didn't get verification email  - send it again. +

{t('verification_not_received')}  + {t('verification_send_again')}.

) ) -- cgit v1.2.3