11import { Input } from './Styles' ;
22import styles from '@/styles/Auth.module.css' ;
3- import { createUpdatePasswordSchema , CreateUpdatePasswordInput } from '@/types/client/updatePassword' ;
3+ import {
4+ createUpdatePasswordSchema ,
5+ CreateUpdatePasswordInput ,
6+ } from '@/types/client/updatePassword' ;
47import { useForm } from 'react-hook-form' ;
58import { zodResolver } from '@hookform/resolvers/zod' ;
69import { Database } from '@/types/database.supabase' ;
@@ -10,7 +13,11 @@ import { toast } from 'react-toastify';
1013import { useRouter } from 'next/router' ;
1114import PasswordIcon from '../icons/PasswordIcon' ;
1215
13- export default function UpdatePassword ( { setServerError} : { setServerError : Dispatch < SetStateAction < string | null > > ; } ) {
16+ export default function UpdatePassword ( {
17+ setServerError,
18+ } : {
19+ setServerError : Dispatch < SetStateAction < string | null > > ;
20+ } ) {
1421 const router = useRouter ( ) ;
1522 const supabase = useSupabaseClient < Database > ( ) ;
1623
@@ -20,12 +27,12 @@ export default function UpdatePassword({setServerError} : {setServerError: Dispa
2027 formState : { errors, isSubmitting } ,
2128 } = useForm < CreateUpdatePasswordInput > ( {
2229 resolver : zodResolver ( createUpdatePasswordSchema ) ,
23- mode : 'onChange'
30+ mode : 'onChange' ,
2431 } ) ;
2532
2633 const onSubmit = async ( formData : CreateUpdatePasswordInput ) => {
2734 const { data, error } = await supabase . auth . updateUser ( {
28- password : formData . password
35+ password : formData . password ,
2936 } ) ;
3037
3138 if ( error ) {
@@ -37,25 +44,24 @@ export default function UpdatePassword({setServerError} : {setServerError: Dispa
3744 if ( data && ! error ) {
3845 toast . success ( 'Password successfully updated' , {
3946 position : 'top-center' ,
40- autoClose : 3000
47+ autoClose : 3000 ,
4148 } ) ;
4249 router . push ( '/' ) ;
4350 }
4451 } ;
4552
46-
4753 return (
48- < form className = "flex flex-col mt-7" onSubmit = { handleSubmit ( onSubmit ) } >
54+ < form className = "flex flex-col mt-7" onSubmit = { handleSubmit ( onSubmit ) } >
4955 < label htmlFor = "email" className = "mt-6" >
5056 New Password:
5157 </ label >
52- < div className = ' mt-3 relative' >
58+ < div className = " mt-3 relative" >
5359 < div className = { `${ errors . password ? styles . iconError : styles . icon } ` } >
54- < PasswordIcon />
60+ < PasswordIcon />
5561 </ div >
5662 < input
5763 type = "password"
58- className = { `${ Input } ${ styles . input } ` }
64+ className = { `${ Input ( ) } ${ styles . input } ` }
5965 placeholder = "Enter password"
6066 { ...register ( 'password' ) }
6167 > </ input >
@@ -72,11 +78,11 @@ export default function UpdatePassword({setServerError} : {setServerError: Dispa
7278 errors . passwordConfirmation ? styles . iconError : styles . icon
7379 } `}
7480 >
75- < PasswordIcon />
81+ < PasswordIcon />
7682 </ div >
7783 < input
7884 type = "password"
79- className = { `${ Input } ${ styles . input } ` }
85+ className = { `${ Input ( ) } ${ styles . input } ` }
8086 placeholder = "Confirm password"
8187 { ...register ( 'passwordConfirmation' ) }
8288 > </ input >
0 commit comments