@@ -4,6 +4,7 @@ import { Link } from "raviger";
4
4
import { useEffect , useState } from "react" ;
5
5
import ReCaptcha from "react-google-recaptcha" ;
6
6
import { useTranslation } from "react-i18next" ;
7
+ import { toast } from "sonner" ;
7
8
8
9
import { cn } from "@/lib/utils" ;
9
10
@@ -98,20 +99,10 @@ const Login = (props: { forgot?: boolean }) => {
98
99
} ) ;
99
100
100
101
// Forgot Password Mutation
101
- const forgotPasswordMutation = useMutation ( {
102
- mutationFn : async ( data : { username : string } ) => {
103
- const response = await request ( routes . forgotPassword , {
104
- body : data ,
105
- } ) ;
106
- return response ;
107
- } ,
102
+ const { mutate : submitForgetPassword } = useMutation ( {
103
+ mutationFn : mutate ( routes . forgotPassword ) ,
108
104
onSuccess : ( ) => {
109
- Notification . Success ( {
110
- msg : t ( "password_sent" ) ,
111
- } ) ;
112
- } ,
113
- onError : ( error : any ) => {
114
- setErrors ( error ) ;
105
+ toast . success ( t ( "password_sent" ) ) ;
115
106
} ,
116
107
} ) ;
117
108
@@ -292,7 +283,7 @@ const Login = (props: { forgot?: boolean }) => {
292
283
const valid = validateForgetData ( ) ;
293
284
if ( ! valid ) return ;
294
285
295
- forgotPasswordMutation . mutate ( valid ) ;
286
+ submitForgetPassword ( valid ) ;
296
287
} ;
297
288
298
289
const onCaptchaChange = ( value : any ) => {
@@ -322,10 +313,7 @@ const Login = (props: { forgot?: boolean }) => {
322
313
323
314
// Loading state derived from mutations
324
315
const isLoading =
325
- staffLoginMutation . isPending ||
326
- forgotPasswordMutation . isPending ||
327
- sendOtpPending ||
328
- verifyOtpPending ;
316
+ staffLoginMutation . isPending || sendOtpPending || verifyOtpPending ;
329
317
330
318
const logos = [ stateLogo , customLogo ] . filter (
331
319
( logo ) => logo ?. light || logo ?. dark ,
0 commit comments