11import { Button } from '@/components/ui/button' ;
2- import { Card , CardContent , CardDescription , CardHeader , CardTitle } from '@/components/ui/card' ;
2+ import { Card , CardContent , CardHeader , CardTitle } from '@/components/ui/card' ;
33import { Form , FormControl , FormField , FormItem , FormLabel } from '@/components/ui/form' ;
44import { Input } from '@/components/ui/input' ;
55import { usePasswordResetStore } from '@/pages/account/public/stores/usePasswordResetStore' ;
66import PublicLayoutContainer from '@/shared/layout/PublicLayoutContainer' ;
77import { zodResolver } from '@hookform/resolvers/zod' ;
88import { CheckIcon , Eye , EyeOff , XIcon } from 'lucide-react' ;
9- import React , { useEffect , useState } from 'react' ;
9+ import React , { useState } from 'react' ;
1010import { useForm } from 'react-hook-form' ;
11- import { useNavigate , useSearchParams } from 'react-router-dom' ;
11+ import { useSearchParams } from 'react-router-dom' ;
1212import { twMerge } from 'tailwind-merge' ;
1313import { z } from 'zod' ;
1414
15+ import PasswordResetSuccessful from './PasswordResetSuccessful' ;
16+
1517const passwordLengthMessage = 'At least 8 characters' ;
1618const passwordContainsNumberMessage = 'At least 1 number' ;
1719const passwordContainsUppercaseMessage = 'At least 1 uppercase' ;
@@ -52,7 +54,7 @@ const formSchema = z
5254const PasswordResetFinish = ( ) => {
5355 const [ showPassword , setShowPassword ] = useState ( false ) ;
5456
55- const { reset , resetPasswordFailure , resetPasswordFinish, resetPasswordSuccess} = usePasswordResetStore ( ) ;
57+ const { resetPasswordFinish, resetPasswordSuccess} = usePasswordResetStore ( ) ;
5658
5759 const [ searchParams ] = useSearchParams ( ) ;
5860 const key = searchParams . get ( 'key' ) ;
@@ -109,7 +111,7 @@ const PasswordResetFinish = () => {
109111 </ div >
110112 </ FormControl >
111113
112- < ul >
114+ < ul className = "space-y-1" >
113115 { errors . newPassword ?. message &&
114116 getValues ( 'newPassword' ) !== '' &&
115117 Object . entries ( JSON . parse ( errors . newPassword . message ) ) . map ( ( [ key , value ] ) => {
@@ -121,12 +123,12 @@ const PasswordResetFinish = () => {
121123 return (
122124 < li
123125 className = { twMerge (
124- 'mt-2 flex items-center gap-1 text-base text-destructive' ,
126+ 'flex items-center gap-1 text-sm text-destructive' ,
125127 validationPass && 'text-success'
126128 ) }
127129 key = { key }
128130 >
129- { validationPass ? < CheckIcon size = { 20 } /> : < XIcon size = { 20 } /> }
131+ { validationPass ? < CheckIcon size = { 15 } /> : < XIcon size = { 15 } /> }
130132
131133 < p > { message } </ p >
132134 </ li >
@@ -135,20 +137,20 @@ const PasswordResetFinish = () => {
135137
136138 { getValues ( 'newPassword' ) === '' && (
137139 < >
138- < li className = "mt-2 flex items-center gap-1 text-base text-content-neutral-secondary" >
139- < XIcon size = { 20 } />
140+ < li className = "flex items-center gap-1 text-sm text-content-neutral-secondary" >
141+ < XIcon size = { 15 } />
140142
141143 < p > { passwordLengthMessage } </ p >
142144 </ li >
143145
144- < li className = "mt-2 flex items-center gap-1 text-base text-content-neutral-secondary" >
145- < XIcon size = { 20 } />
146+ < li className = "flex items-center gap-1 text-sm text-content-neutral-secondary" >
147+ < XIcon size = { 15 } />
146148
147149 < p > { passwordContainsNumberMessage } </ p >
148150 </ li >
149151
150- < li className = "mt-2 flex items-center gap-1 text-base text-content-neutral-secondary" >
151- < XIcon size = { 20 } />
152+ < li className = "flex items-center gap-1 text-sm text-content-neutral-secondary" >
153+ < XIcon size = { 15 } />
152154
153155 < p > { passwordContainsUppercaseMessage } </ p >
154156 </ li >
@@ -157,20 +159,20 @@ const PasswordResetFinish = () => {
157159
158160 { ! errors . newPassword && getValues ( 'newPassword' ) !== '' && (
159161 < >
160- < li className = "mt-2 flex items-center gap-1 text-base text-success" >
161- < CheckIcon size = { 20 } />
162+ < li className = "flex items-center gap-1 text-sm text-success" >
163+ < CheckIcon size = { 15 } />
162164
163165 < p > { passwordLengthMessage } </ p >
164166 </ li >
165167
166- < li className = "mt-2 flex items-center gap-1 text-base text-success" >
167- < CheckIcon size = { 20 } />
168+ < li className = "flex items-center gap-1 text-sm text-success" >
169+ < CheckIcon size = { 15 } />
168170
169171 < p > { passwordContainsNumberMessage } </ p >
170172 </ li >
171173
172- < li className = "mt-2 flex items-center gap-1 text-base text-success" >
173- < CheckIcon size = { 20 } />
174+ < li className = "flex items-center gap-1 text-sm text-success" >
175+ < CheckIcon size = { 15 } />
174176
175177 < p > { passwordContainsUppercaseMessage } </ p >
176178 </ li >
@@ -197,31 +199,17 @@ const PasswordResetFinish = () => {
197199 resetPasswordFinish ( key , newPassword ) ;
198200 }
199201
200- const navigate = useNavigate ( ) ;
201-
202- useEffect ( ( ) => {
203- if ( resetPasswordSuccess ) {
204- navigate ( '/password-reset/success' ) ;
205- }
206-
207- if ( resetPasswordFailure ) {
208- navigate ( '/account-error' , { state : { error : 'Something went wrong. Try again.' } } ) ;
209- }
210-
211- reset ( ) ;
212- } , [ navigate , reset , resetPasswordSuccess , resetPasswordFailure ] ) ;
202+ if ( resetPasswordSuccess ) {
203+ return < PasswordResetSuccessful /> ;
204+ }
213205
214206 return (
215207 < PublicLayoutContainer >
216208 < Card className = "mx-auto max-w-sm rounded-xl p-6 text-start shadow-none" >
217- < CardHeader className = "p-0 pb-10 text-center" >
209+ < CardHeader className = "p-0 pb-8 text-center" >
218210 < CardTitle className = "text-xl font-bold text-content-neutral-primary" >
219211 Create a new password
220212 </ CardTitle >
221-
222- < CardDescription className = "text-content-neutral-secondary" >
223- Your password needs to be different from previously used passwords.
224- </ CardDescription >
225213 </ CardHeader >
226214
227215 < CardContent className = "flex flex-col gap-6 p-0" >
0 commit comments