diff --git a/src/components/Auth/SignIn.tsx b/src/components/Auth/SignIn.tsx index 53d0089d..c0f073a3 100644 --- a/src/components/Auth/SignIn.tsx +++ b/src/components/Auth/SignIn.tsx @@ -1,8 +1,8 @@ -import { Button, Flex, Link, Text, useToast } from '@chakra-ui/react' +import { Button, Checkbox, Flex, FormControl, FormErrorMessage, Link, Text, useToast } from '@chakra-ui/react' import { useMutation } from '@tanstack/react-query' import { useEffect, useState } from 'react' import { FormProvider, useForm } from 'react-hook-form' -import { useTranslation } from 'react-i18next' +import { Trans, useTranslation } from 'react-i18next' import { NavLink, useNavigate, useOutletContext } from 'react-router-dom' import { api, ApiEndpoints, UnverifiedApiError } from '~components/Auth/api' import { ILoginParams } from '~components/Auth/authQueries' @@ -12,7 +12,6 @@ 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' import GoogleAuth from './GoogleAuth' @@ -47,7 +46,12 @@ const SignIn = ({ email: emailProp }: { email?: string }) => { const methods = useForm({ defaultValues: { email: emailProp }, }) - const { handleSubmit, watch } = methods + const { + handleSubmit, + watch, + formState: { errors }, + register, + } = methods const email = watch('email', emailProp) const { @@ -130,7 +134,12 @@ const SignIn = ({ email: emailProp }: { email?: string }) => { required /> - + + + Keep me logged + + {errors?.keepLogedIn?.message.toString()} + diff --git a/src/components/Auth/SignUp.tsx b/src/components/Auth/SignUp.tsx index 18ffc079..cb9e9d17 100644 --- a/src/components/Auth/SignUp.tsx +++ b/src/components/Auth/SignUp.tsx @@ -1,4 +1,4 @@ -import { Button, Flex, Link, Text } from '@chakra-ui/react' +import { Button, Checkbox, Flex, FormControl, FormErrorMessage, Link, Text } from '@chakra-ui/react' import { useEffect } from 'react' import { FormProvider, useForm } from 'react-hook-form' import { Trans, useTranslation } from 'react-i18next' @@ -10,7 +10,6 @@ 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' import { default as InputBasic } from '../Layout/InputBasic' import GoogleAuth from './GoogleAuth' import { HSeparator } from './SignIn' @@ -31,7 +30,7 @@ type FormData = { const SignUp = ({ invite }: SignupProps) => { const { t } = useTranslation() - const { register } = useAuth() + const { register: signup } = useAuth() const inviteSignup = useSignupFromInvite(invite?.address) const { setTitle, setSubtitle } = useOutletContext() @@ -41,12 +40,17 @@ const SignUp = ({ invite }: SignupProps) => { email: invite?.email, }, }) - const { handleSubmit, watch } = methods + const { + handleSubmit, + watch, + register, + formState: { errors }, + } = methods const email = watch('email') - const isPending = register.isPending || inviteSignup.isPending - const isError = register.isError || inviteSignup.isError - const error = register.error || inviteSignup.error + const isPending = signup.isPending || inviteSignup.isPending + const isError = signup.isError || inviteSignup.isError + const error = signup.error || inviteSignup.error useEffect(() => { // set SignUp title and description @@ -56,7 +60,7 @@ const SignUp = ({ invite }: SignupProps) => { const onSubmit = (user: FormData) => { if (!invite) { - return register.mutate(user) + return signup.mutate(user) } // if there's an invite, the process' a bit different @@ -67,7 +71,7 @@ const SignUp = ({ invite }: SignupProps) => { } // normally registered accounts need verification - if (register.isSuccess) { + if (signup.isSuccess) { return } @@ -118,20 +122,20 @@ const SignUp = ({ invite }: SignupProps) => { }, }} /> - - + , privacyLink: , }} - /> - } - required - /> + > + Keep me logged + + + {errors?.terms?.message.toString()} +