File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,21 @@ export const ResetPassword = ({ email }: { email: IGetUser['email'] }) => {
3636 toast . success ( 'Password changed successfully.' ) ;
3737 setState ( initialState ) ;
3838 } ,
39- onError : ( error ) => toast . error ( `Something went wrong: ${ error . message } ` ) ,
39+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40+ onError : ( error : any ) => {
41+ // Try to extract and display password validation errors from the response
42+ const apiErrors = error ?. response ?. data ;
43+ if ( apiErrors && typeof apiErrors === 'object' ) {
44+ const messages = Object . values ( apiErrors ) . flat ( ) . join ( '\n' ) ;
45+ toast . error ( messages , {
46+ style : { whiteSpace : 'pre-line' , minWidth : 560 } ,
47+ duration : 7000 ,
48+ } ) ;
49+ } else {
50+ toast . error ( `Something went wrong: ${ error . message } ` ) ;
51+ }
52+ return ;
53+ } ,
4054 } ) ;
4155
4256 const handleOnChange = ( event : ChangeEvent < HTMLTextAreaElement > ) =>
@@ -58,7 +72,10 @@ export const ResetPassword = ({ email }: { email: IGetUser['email'] }) => {
5872 }
5973
6074 if ( password !== confirmPassword ) {
61- toast . error ( 'The new password does not match the confirmed password.' ) ;
75+ toast . error ( 'The new password does not match the confirmed password.' , {
76+ style : { whiteSpace : 'pre-line' , minWidth : 530 } ,
77+ duration : 7000 ,
78+ } ) ;
6279 return ;
6380 }
6481
You can’t perform that action at this time.
0 commit comments