From a80163d589c7aa1d54a380c577c7c204736c4bdf Mon Sep 17 00:00:00 2001 From: YasinShaikh123 <123150391+YasinShaikh123@users.noreply.github.com> Date: Tue, 11 Feb 2025 14:47:33 +0530 Subject: [PATCH 1/4] 'Login chnges' --- src/Pages/Login.tsx | 179 ++++++++++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 72 deletions(-) diff --git a/src/Pages/Login.tsx b/src/Pages/Login.tsx index 9db1596..4253c8f 100644 --- a/src/Pages/Login.tsx +++ b/src/Pages/Login.tsx @@ -1,45 +1,45 @@ -import { 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" -import { useDispatch } from "react-redux" -import GlobalStateContext from "../Contexts/GlobalStateContext" -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 { PasswordInput } from "../components/ui/password-input" -import { useNavigate } from "react-router-dom" +import { 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"; +import { useDispatch } from "react-redux"; +import GlobalStateContext from "../Contexts/GlobalStateContext"; +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 { PasswordInput } from "../components/ui/password-input"; +import { useNavigate } from "react-router-dom"; interface FormValues { - mobileNumber: number - password: string + mobileNumber: number; + password: string; } const Login = () => { - const navigate = useNavigate() - const dispatch = useDispatch() - const [isLoading, setIsLoading] = useState(false) + const navigate = useNavigate(); + const dispatch = useDispatch(); + const [isLoading, setIsLoading] = useState(false); const context = useContext(GlobalStateContext); if (!context) { - throw new Error('App must be used within a GlobalStateProvider'); + throw new Error("App must be used within a GlobalStateProvider"); } const { setIsAuthenticate } = context; const { register, handleSubmit, formState: { errors }, - } = useForm() + } = useForm(); 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 + const username = import.meta.env.VITE_USER_NAME || ""; // Replace with actual username + const password = import.meta.env.VITE_PASSWORD || ""; // Replace with actual password const basicAuth = `${username} : ${password}`; // Encode to Base64 - + try { const res = await axios.post( `${import.meta.env.VITE_API_URL}/login`, @@ -56,84 +56,119 @@ const Login = () => { ); if (res.data) { - setIsAuthenticate(true) - console.log('===================================='); + setIsAuthenticate(true); + console.log("===================================="); console.log(res.data?.data); - console.log('===================================='); - navigate('/') + console.log("===================================="); + navigate("/"); dispatch(setToken(String(res.data?.data["access-token"]))); } else { - console.log("===================================="); console.log(res); console.log("===================================="); - } - } catch (error) { if (error) { - console.error("Login failed", error); - setIsLoading(false) - + setIsLoading(false); } } }); - - - return ( - - - - - + + - - - - - - - -
+ +
+
+ + + LOGIN + - - - -
- - LOGIN - - - - - {/* Forget password */} + + + + {/* Forget password */} - - - {/* Forget password */} + + + {/* Forget password */} - + Forgot password - -
- ) -} + ); +}; -export default Login \ No newline at end of file +export default Login; From bc1d1923d21ac063f1096d709408895b7efc73f9 Mon Sep 17 00:00:00 2001 From: "parth.ramani" Date: Tue, 11 Feb 2025 17:18:28 +0530 Subject: [PATCH 2/4] get called in aboutus --- src/Pages/ManageCMS/AboutUs/AboutUs.tsx | 36 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Pages/ManageCMS/AboutUs/AboutUs.tsx b/src/Pages/ManageCMS/AboutUs/AboutUs.tsx index c704868..0d73b52 100644 --- a/src/Pages/ManageCMS/AboutUs/AboutUs.tsx +++ b/src/Pages/ManageCMS/AboutUs/AboutUs.tsx @@ -5,15 +5,27 @@ import AboutUsAddModel from "../../ManageCMS/AboutUs/AboutUsAddModel"; import { useGetAboutUsQuery } from "../../../Redux/Service/manage.aboutus.service"; +interface AboutUsContent { + content: string; +} + +interface ApiResponse { + data: AboutUsContent[]; +} + + const AboutUs = () => { - const { - data - } = useGetAboutUsQuery() + // const { + // data: data + // } = useGetAboutUsQuery() + const { data: response } = useGetAboutUsQuery<{ data: ApiResponse }>(); + console.log('===================================='); + console.log(response); + console.log('===================================='); + + const content = response?.data?.[0]?.content || "No content available"; - console.log('===================================='); - console.log(data); - console.log('===================================='); return ( @@ -26,21 +38,21 @@ const AboutUs = () => { px={3} > - AboutUs + AboutUs - + - Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam soluta doloremque quibusdam facilis quas, unde hic eaque doloribus sed perferendis atque, eos dolores eius consectetur iure sint adipisci itaque tempora fugit quidem culpa provident possimus. Ullam, vitae in voluptatum dignissimos, quos blanditiis sequi aut repellat error eaque veritatis unde quam temporibus adipisci consectetur neque vero exercitationem dolor cum numquam maiores alias, totam minima quas. Possimus, ratione harum. Alias laboriosam nesciunt esse fugit deserunt pariatur corporis tempora quia veniam laborum aliquid enim voluptatibus asperiores minima tempore repudiandae vero quo porro, doloribus explicabo sit beatae et hic natus. Non earum nisi reiciendis? + {content} - + {/* Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam soluta doloremque quibusdam facilis quas, unde hic eaque doloribus sed perferendis atque, eos dolores eius consectetur iure sint adipisci itaque tempora fugit quidem culpa provident possimus. Ullam, vitae in voluptatum dignissimos, quos blanditiis sequi aut repellat error eaque veritatis unde quam temporibus adipisci consectetur neque vero exercitationem dolor cum numquam maiores alias, totam minima quas. Possimus, ratione harum. Alias laboriosam nesciunt esse fugit deserunt pariatur corporis tempora quia veniam laborum aliquid enim voluptatibus asperiores minima tempore repudiandae vero quo porro, doloribus explicabo sit beatae et hic natus. Non earum nisi reiciendis? - - + */} + ) } From e36c343cbfa34a055ec84eb699809e671b7d4eb4 Mon Sep 17 00:00:00 2001 From: YasinShaikh123 <123150391+YasinShaikh123@users.noreply.github.com> Date: Tue, 11 Feb 2025 17:19:32 +0530 Subject: [PATCH 3/4] [ forget modal ] --- src/Layouts/DefaultLayout.tsx | 2 +- src/Pages/ForgetPassword.tsx | 65 ++++++++++++++++++++++++++++ src/Pages/Login.tsx | 17 +++++--- src/components/MainFrame.tsx | 2 +- src/components/ui/password-input.tsx | 2 +- 5 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 src/Pages/ForgetPassword.tsx diff --git a/src/Layouts/DefaultLayout.tsx b/src/Layouts/DefaultLayout.tsx index 2e63eae..3d2e95e 100644 --- a/src/Layouts/DefaultLayout.tsx +++ b/src/Layouts/DefaultLayout.tsx @@ -43,7 +43,7 @@ const DefaultLayout: FC<{ children: React.ReactNode }> = ({ children }) => { - + navigate('/profile')} > diff --git a/src/Pages/ForgetPassword.tsx b/src/Pages/ForgetPassword.tsx new file mode 100644 index 0000000..e0be6bc --- /dev/null +++ b/src/Pages/ForgetPassword.tsx @@ -0,0 +1,65 @@ +import { Field, Input, Stack, Text } from "@chakra-ui/react"; +import { Button } from "../components/ui/button"; +import { + DialogBody, + DialogContent, + DialogFooter, + DialogHeader, + DialogRoot, + DialogTitle, + DialogTrigger, +} from "../components/ui/dialog"; +function ForgetPassword() { + return ( + + + + Forgot password? + + + + + + + Forgot Password + + + + + + + + Please Enter Email Address + + + + + + + + + + + ); +} + +export default ForgetPassword; diff --git a/src/Pages/Login.tsx b/src/Pages/Login.tsx index 541ec13..0287d06 100644 --- a/src/Pages/Login.tsx +++ b/src/Pages/Login.tsx @@ -1,4 +1,4 @@ -import { 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"; @@ -11,6 +11,7 @@ import { Field } from "../components/ui/field"; import { Toaster } from "../components/ui/toaster"; import { PasswordInput } from "../components/ui/password-input"; import { useNavigate } from "react-router-dom"; +import ForgetPassword from "./ForgetPassword"; interface FormValues { mobileNumber: number; @@ -103,14 +104,14 @@ const Login = () => {
-
- + { LOGIN - + { w={"100%"} invalid={!!errors.password} errorText={errors.password?.message} + mb={2} > { Login - Forgot password - + + -
+
diff --git a/src/components/MainFrame.tsx b/src/components/MainFrame.tsx index 2646c63..285d3b9 100644 --- a/src/components/MainFrame.tsx +++ b/src/components/MainFrame.tsx @@ -13,7 +13,7 @@ interface MainFrameProps { const MainFrame: FC = ({ children }) => { return ( - + ( Date: Tue, 11 Feb 2025 19:48:41 +0530 Subject: [PATCH 4/4] [ forget modal ] --- src/Pages/Login.tsx | 35 ++++++++++++------- src/Redux/Service/forget.password.service.ts | 36 ++++++++++++++++++++ src/components/ui/toaster.tsx | 2 +- 3 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 src/Redux/Service/forget.password.service.ts diff --git a/src/Pages/Login.tsx b/src/Pages/Login.tsx index 487ded4..23f08c8 100644 --- a/src/Pages/Login.tsx +++ b/src/Pages/Login.tsx @@ -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 ( { required: "Mobile Number address is required", })} placeholder="Mobile Number Address" - /> + /> {/* Forget password */} ({ + + + + // 🔹 GET: Fetch all posts + getAboutUs: builder.query({ + 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; +}; diff --git a/src/components/ui/toaster.tsx b/src/components/ui/toaster.tsx index 7503ff7..a4251eb 100644 --- a/src/components/ui/toaster.tsx +++ b/src/components/ui/toaster.tsx @@ -27,7 +27,7 @@ export const Toaster = () => { )} - {toast.title && {toast.title}} + {toast.title && {toast.title}} {toast.description && ( {toast.description} )}