[ forget modal ]

This commit is contained in:
YasinShaikh123
2025-02-11 19:48:41 +05:30
parent 8908bacc8a
commit 90792de1ac
3 changed files with 59 additions and 14 deletions

View File

@@ -1,4 +1,12 @@
import { Box, Center, HStack, Image, Input, Text, VStack } from "@chakra-ui/react";
import {
Box,
Center,
HStack,
Image,
Input,
Text,
VStack,
} from "@chakra-ui/react";
import axios from "axios";
import { useContext, useState } from "react";
import { useForm } from "react-hook-form";
@@ -8,7 +16,7 @@ import { setToken } from "../Redux/Service/authSlice";
import logo from "../assets/logo.svg";
import { Button } from "../components/ui/button";
import { Field } from "../components/ui/field";
import { Toaster } from "../components/ui/toaster";
import { toaster, Toaster } from "../components/ui/toaster";
import { PasswordInput } from "../components/ui/password-input";
import { useNavigate } from "react-router-dom";
import ForgetPassword from "./ForgetPassword";
@@ -35,7 +43,6 @@ const Login = () => {
const onSubmit = handleSubmit(async (data) => {
setIsLoading(true);
// Encode Basic Auth Credentials
const username = import.meta.env.VITE_USER_NAME || ""; // Replace with actual username
const password = import.meta.env.VITE_PASSWORD || ""; // Replace with actual password
@@ -53,16 +60,17 @@ const Login = () => {
Authorization: `Basic ${basicAuth}`,
"Content-Type": "application/json",
},
}
);
console.log("============",res);
if (res.data) {
setIsAuthenticate(true);
console.log("====================================");
console.log(res.data?.data);
console.log('====================================');
navigate('/dashboard')
console.log("====================================");
navigate("/dashboard");
dispatch(setToken(String(res.data?.data["access-token"])));
} else {
console.log("====================================");
@@ -71,16 +79,17 @@ const Login = () => {
}
} catch (error) {
if (error) {
console.error("Login failed", error);
setIsLoading(false)
toaster.create({
// title: error?.response?.data?.message,
title: "Something Went Wrong",
type: "info",
})
// console.log("Login failed", error?.response?.data?.message);
setIsLoading(false);
}
}
});
return (
<VStack w={"100%"} h={"100vh"} bg={"#ffffff"}>
<HStack
@@ -138,7 +147,7 @@ const Login = () => {
required: "Mobile Number address is required",
})}
placeholder="Mobile Number Address"
/>
/>
{/* <Text as={'span'} w={'100%'} fontSize={'xs'} fontWeight={'normal'} color={'#686677'}>Forget password</Text> */}
</Field>
<Field

View File

@@ -0,0 +1,36 @@
import { createApi } from "@reduxjs/toolkit/query/react";
import { baseQueryWithReauth } from "./apiSlice";
export const forgetPassword = createApi({
reducerPath: "aboutUs",
baseQuery: baseQueryWithReauth, // Use enhanced baseQuery with error handling
endpoints: (builder) => ({
// 🔹 GET: Fetch all posts
getAboutUs: builder.query<AboutUs[], void>({
query: () => "/send-otp",
}),
}),
});
export const {
useGetAboutUsQuery,
} = forgetPassword;
// Define Post type
export type Post = {
id: number;
title: string;
body: string;
};
export type AboutUs = {
id: number;
language_master_xid: number;
content: string;
is_active: boolean;
};

View File

@@ -27,7 +27,7 @@ export const Toaster = () => {
<Toast.Indicator />
)}
<Stack rounded={'full'} gap="1" flex="1" maxWidth="100%">
{toast.title && <Toast.Title>{toast.title}</Toast.Title>}
{toast.title && <Toast.Title p={2} color="#02A0A0">{toast.title}</Toast.Title>}
{toast.description && (
<Toast.Description>{toast.description}</Toast.Description>
)}