-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
auth and icons #895
Open
gerouvi
wants to merge
4
commits into
develop
Choose a base branch
from
b/auth-and-icons
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
auth and icons #895
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import { Button, Flex, Text, useToast } from '@chakra-ui/react' | ||
import { Button, Flex, Link, Text, useToast } from '@chakra-ui/react' | ||
import { useMutation } from '@tanstack/react-query' | ||
import { useState } from 'react' | ||
import { useEffect, useState } from 'react' | ||
import { FormProvider, useForm } from 'react-hook-form' | ||
import { useTranslation } from 'react-i18next' | ||
import { NavLink, useNavigate } from 'react-router-dom' | ||
import { NavLink, useNavigate, useOutletContext } from 'react-router-dom' | ||
import { api, ApiEndpoints, UnverifiedApiError } from '~components/Auth/api' | ||
import { ILoginParams } from '~components/Auth/authQueries' | ||
import { useAuth } from '~components/Auth/useAuth' | ||
import { VerificationPending } from '~components/Auth/Verify' | ||
import FormSubmitMessage from '~components/Layout/FormSubmitMessage' | ||
import InputPassword from '~components/Layout/InputPassword' | ||
import { AuthOutletContextType } from '~elements/LayoutAuth' | ||
import { Routes } from '~src/router/routes' | ||
import CustomCheckbox from '../Layout/CheckboxCustom' | ||
import InputBasic from '../Layout/InputBasic' | ||
|
@@ -42,9 +43,12 @@ const SignIn = ({ email: emailProp }: { email?: string }) => { | |
const { t } = useTranslation() | ||
const toast = useToast() | ||
const navigate = useNavigate() | ||
const { setTitle, setSubTitle } = useOutletContext<AuthOutletContextType>() | ||
const methods = useForm<FormData>({ | ||
defaultValues: { email: emailProp }, | ||
}) | ||
const [isErrorA, setIsErrorA] = useState(false) | ||
const [isComponentMounted, setIsComponentMounted] = useState(false) | ||
const { handleSubmit, watch } = methods | ||
const email = watch('email', emailProp) | ||
|
||
|
@@ -55,6 +59,20 @@ const SignIn = ({ email: emailProp }: { email?: string }) => { | |
const { mutateAsync: checkVerificationCodeStatus } = useVerificationCodeStatus() | ||
const { mutateAsync: resendVerificationCode } = useResendVerificationCode() | ||
|
||
useEffect(() => { | ||
setTitle(t('signin_title')) | ||
setSubTitle(t('signin_subtitle')) | ||
setIsComponentMounted(true) | ||
}, []) | ||
|
||
useEffect(() => { | ||
if (isComponentMounted && isError) { | ||
setIsErrorA(true) | ||
} | ||
|
||
return () => setIsErrorA(false) | ||
}, [isError]) | ||
|
||
const onSubmit = async (data: FormData) => { | ||
await login(data) | ||
.then(() => navigate(Routes.dashboard.base)) | ||
|
@@ -111,7 +129,6 @@ const SignIn = ({ email: emailProp }: { email?: string }) => { | |
label={t('email')} | ||
placeholder={t('email_placeholder', { defaultValue: '[email protected]' })} | ||
type='email' | ||
required | ||
/> | ||
<InputPassword | ||
formValue='password' | ||
|
@@ -123,7 +140,7 @@ const SignIn = ({ email: emailProp }: { email?: string }) => { | |
<CustomCheckbox formValue='keepLogedIn' label={t('keep_me_logged', { defaultValue: 'Keep me logged' })} /> | ||
|
||
<NavLink to={Routes.auth.recovery}> | ||
<Text color={'account.link'} fontSize='sm' fontWeight='500' whiteSpace='nowrap'> | ||
<Text fontSize='sm' fontWeight='500' whiteSpace='nowrap'> | ||
{t('forgot_password')} | ||
</Text> | ||
</NavLink> | ||
|
@@ -137,14 +154,12 @@ const SignIn = ({ email: emailProp }: { email?: string }) => { | |
<Flex flexDirection='column' justifyContent='center' alignItems='start' maxW='100%' mt={0}> | ||
<Text fontWeight='400' fontSize='sm'> | ||
{t('not_registred_yet')} | ||
<NavLink to={Routes.auth.signUp}> | ||
<Text color={'account.link'} as='span' ms={1} fontWeight='500'> | ||
{t('create_account')} | ||
</Text> | ||
</NavLink> | ||
<Link as={NavLink} to={Routes.auth.signUp} ml={1} fontWeight={500}> | ||
{t('create_account')} | ||
</Link> | ||
</Text> | ||
</Flex> | ||
<FormSubmitMessage isError={isError} error={error} /> | ||
<FormSubmitMessage isError={isErrorA} error={error} /> | ||
</> | ||
) | ||
} | ||
|
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,12 +1,14 @@ | ||
import { Button, Flex, Link, Text } from '@chakra-ui/react' | ||
import { useEffect } from 'react' | ||
import { FormProvider, useForm } from 'react-hook-form' | ||
import { Trans, useTranslation } from 'react-i18next' | ||
import { Navigate, NavLink, Link as ReactRouterLink } from 'react-router-dom' | ||
import { Navigate, NavLink, Link as ReactRouterLink, useOutletContext } from 'react-router-dom' | ||
import { IRegisterParams } from '~components/Auth/authQueries' | ||
import { useAuth } from '~components/Auth/useAuth' | ||
import { VerificationPending } from '~components/Auth/Verify' | ||
import FormSubmitMessage from '~components/Layout/FormSubmitMessage' | ||
import InputPassword from '~components/Layout/InputPassword' | ||
import { AuthOutletContextType } from '~elements/LayoutAuth' | ||
import { useSignupFromInvite } from '~src/queries/account' | ||
import { Routes } from '~src/router/routes' | ||
import CustomCheckbox from '../Layout/CheckboxCustom' | ||
|
@@ -32,6 +34,8 @@ const SignUp = ({ invite }: SignupProps) => { | |
const { t } = useTranslation() | ||
const { register } = useAuth() | ||
const inviteSignup = useSignupFromInvite(invite?.address) | ||
const { setTitle, setSubTitle } = useOutletContext<AuthOutletContextType>() | ||
|
||
const methods = useForm<FormData>({ | ||
defaultValues: { | ||
terms: false, | ||
|
@@ -45,6 +49,11 @@ const SignUp = ({ invite }: SignupProps) => { | |
const isError = register.isError || inviteSignup.isError | ||
const error = register.error || inviteSignup.error | ||
|
||
useEffect(() => { | ||
setTitle(t('signup_title')) | ||
setSubTitle(t('signup_subtitle')) | ||
}, []) | ||
|
||
const onSubmit = (user: FormData) => { | ||
if (!invite) { | ||
return register.mutate(user) | ||
|
@@ -87,16 +96,20 @@ const SignUp = ({ invite }: SignupProps) => { | |
formValue='email' | ||
label={t('email')} | ||
placeholder={t('email_placeholder', { defaultValue: '[email protected]' })} | ||
type='email' | ||
required | ||
validation={{ | ||
required: t('form.error.field_is_required'), | ||
pattern: { | ||
value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/, // Regex para validar emails | ||
message: t('form.error.email_invalid', { defaultValue: 'Invalid email address' }), | ||
}, | ||
}} | ||
isDisabled={!!invite} | ||
/> | ||
<InputPassword | ||
formValue='password' | ||
label={t('password')} | ||
placeholder={t('password_placeholder')} | ||
type='password' | ||
required | ||
validation={{ | ||
required: t('form.error.field_is_required'), | ||
minLength: { | ||
|
@@ -129,11 +142,9 @@ const SignUp = ({ invite }: SignupProps) => { | |
<Flex flexDirection='column' justifyContent='center' alignItems='start' maxW='100%'> | ||
<Text color='account.description' fontWeight='400' fontSize='sm'> | ||
{t('already_member')} | ||
<NavLink to={Routes.auth.signIn}> | ||
<Text color={'account.link'} as='span' ms={1} fontWeight='500'> | ||
{t('signin')} | ||
</Text> | ||
</NavLink> | ||
<Link as={NavLink} to={Routes.auth.signIn} ml={1} fontWeight={500}> | ||
{t('signin')} | ||
</Link> | ||
</Text> | ||
</Flex> | ||
{isError && <FormSubmitMessage isError={isError} error={error} />} | ||
|
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
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 |
---|---|---|
|
@@ -17,7 +17,7 @@ const AuthBanner = ({ children, ...props }: AuthBannerProps) => { | |
flex={{ base: '1 1 100%', xl: '1 1 50%' }} | ||
background='linear-gradient(to bottom, #B5F492, #338B93)' | ||
borderBottomLeftRadius={{ xl: '200px' }} | ||
pt={14} | ||
pt={{ base: 20, xl: 0 }} | ||
pb={{ xl: 5 }} | ||
> | ||
<ColorModeSwitcher position='absolute' top={3.5} right={2.5} /> | ||
|
@@ -29,25 +29,30 @@ const AuthBanner = ({ children, ...props }: AuthBannerProps) => { | |
}} | ||
textAlign='center' | ||
h='100%' | ||
maxW='600px' | ||
mx='auto' | ||
{...props} | ||
> | ||
{children} | ||
<Flex mt='auto' flexDirection='column' alignItems='center' justifyContent='center' color='white'> | ||
<Flex mt='auto' flexDirection='column' alignItems='center' justifyContent='center'> | ||
<List display='flex' gap={5}> | ||
<ListItem> | ||
<Link as={ReactRouterLink} fontWeight='500' to='mailto:[email protected]'> | ||
<Link as={ReactRouterLink} fontWeight='500' to='mailto:[email protected]' color={'banner_link'}> | ||
{t('support', { defaultValue: 'Support' })} | ||
</Link> | ||
</ListItem> | ||
<ListItem> | ||
<Link as={ReactRouterLink} fontWeight='500' to={Routes.terms}> | ||
<Link as={ReactRouterLink} fontWeight='500' to={Routes.terms} isExternal color={'banner_link'}> | ||
{t('terms_of_use', { defaultValue: 'Terms of use' })} | ||
</Link> | ||
</ListItem> | ||
<ListItem> | ||
<Link as={ReactRouterLink} fontWeight='500' to='https://blog.vocdoni.io/' isExternal> | ||
<Link | ||
as={ReactRouterLink} | ||
fontWeight='500' | ||
to='https://blog.vocdoni.io/' | ||
isExternal | ||
color={'banner_link'} | ||
> | ||
{t('blog', { defaultValue: 'Blog' })} | ||
</Link> | ||
</ListItem> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What? What are you trying with this state? Also, terrible naming.