Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimanyurajeesh committed Jan 3, 2025
1 parent 42649b4 commit 3f03b58
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions src/components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Link } from "raviger";
import { useEffect, useState } from "react";
import ReCaptcha from "react-google-recaptcha";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";

import { cn } from "@/lib/utils";

Expand Down Expand Up @@ -98,24 +99,10 @@ const Login = (props: { forgot?: boolean }) => {
});

// Forgot Password Mutation
const forgotPasswordMutation = useMutation({
mutationFn: async (data: { username: string }) => {
const response = await request(routes.forgotPassword, {
body: data,
});
return response;
},
onSuccess: (response) => {
if (response.res && response.res.ok) {
Notification.Success({
msg: t("password_sent"),
});
}
},
onError: (error: any) => {
Notification.Error({
msg: error.message || t("password_reset_failure"),
});
const { mutate: submitForgetPassword } = useMutation({
mutationFn: mutate(routes.forgotPassword),
onSuccess: () => {
toast.success(t("password_sent"));
},
});

Expand Down Expand Up @@ -296,7 +283,7 @@ const Login = (props: { forgot?: boolean }) => {
const valid = validateForgetData();
if (!valid) return;

forgotPasswordMutation.mutate(valid);
submitForgetPassword(valid);
};

const onCaptchaChange = (value: any) => {
Expand Down Expand Up @@ -326,10 +313,7 @@ const Login = (props: { forgot?: boolean }) => {

// Loading state derived from mutations
const isLoading =
staffLoginMutation.isPending ||
forgotPasswordMutation.isPending ||
sendOtpPending ||
verifyOtpPending;
staffLoginMutation.isPending || sendOtpPending || verifyOtpPending;

const logos = [stateLogo, customLogo].filter(
(logo) => logo?.light || logo?.dark,
Expand Down

0 comments on commit 3f03b58

Please sign in to comment.