From cd586ddf1bf133f5c551b8188262ad150a7b8a8e Mon Sep 17 00:00:00 2001 From: "Siddhesh.More" Date: Wed, 12 Feb 2025 16:27:49 +0530 Subject: [PATCH] update --- src/Contexts/GlobalStateContext.tsx | 7 ++++--- src/Contexts/GlobalStateProvider.tsx | 15 +++++++++++---- src/Layouts/DefaultLayout.tsx | 4 ++-- .../ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx | 11 +++++++++++ src/Pages/Profile/Profile.tsx | 18 ++++++++---------- src/components/MainFrame.tsx | 6 +++--- 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/Contexts/GlobalStateContext.tsx b/src/Contexts/GlobalStateContext.tsx index 8c7e0cd..6015cbb 100644 --- a/src/Contexts/GlobalStateContext.tsx +++ b/src/Contexts/GlobalStateContext.tsx @@ -2,11 +2,12 @@ import { createContext, Dispatch, SetStateAction } from 'react'; // Define the shape of your context value -type GlobalStateContextType = { +export interface GlobalStateContextType { isAuthenticate: boolean; setIsAuthenticate: Dispatch>; -}; - + isBarLoading: boolean; + setIsBarLoading: Dispatch>; +} // Create the context with a default value of `undefined` const GlobalStateContext = createContext(undefined); diff --git a/src/Contexts/GlobalStateProvider.tsx b/src/Contexts/GlobalStateProvider.tsx index 105a8cb..82b7d9a 100644 --- a/src/Contexts/GlobalStateProvider.tsx +++ b/src/Contexts/GlobalStateProvider.tsx @@ -1,14 +1,21 @@ -import { ReactNode, useState } from 'react'; -import GlobalStateContext from './GlobalStateContext'; - +import { ReactNode, useState } from "react"; +import GlobalStateContext from "./GlobalStateContext"; const GlobalStateProvider = ({ children }: { children: ReactNode }) => { const [isAuthenticate, setIsAuthenticate] = useState(true); + const [isBarLoading, setIsBarLoading] = useState(false); // ✅ Fixed typo + + return ( - + {children} ); diff --git a/src/Layouts/DefaultLayout.tsx b/src/Layouts/DefaultLayout.tsx index 19aca88..7dd0c7d 100644 --- a/src/Layouts/DefaultLayout.tsx +++ b/src/Layouts/DefaultLayout.tsx @@ -24,7 +24,7 @@ const DefaultLayout: FC<{ children: React.ReactNode }> = ({ children }) => { if (!context) { throw new Error('App must be used within a GlobalStateProvider'); } - const { setIsAuthenticate } = context; + const { setIsAuthenticate, isBarLoading } = context; const [ logOutAdmin ] = useLogOutMutation() @@ -48,7 +48,7 @@ const DefaultLayout: FC<{ children: React.ReactNode }> = ({ children }) => { return ( - + diff --git a/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx b/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx index 23ddda3..869f02e 100644 --- a/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx +++ b/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx @@ -3,10 +3,21 @@ import { useGetPrivacyPolicyQuery } from "../../../Redux/Service/privacy.policy. import MainFrame from "../../../components/MainFrame"; import { Spinner } from "../../../components/Sipnner/Spinner"; import PrivacyPolicyAddModel from "./PrivacyPolicyAddModel"; +import GlobalStateContext from "../../../Contexts/GlobalStateContext"; +import { useContext, useEffect } from "react"; const PrivacyPolicy = () => { const { data, isLoading, isFetching } = useGetPrivacyPolicyQuery(); + + const context = useContext(GlobalStateContext); + if (!context) throw new Error('App must be used within a GlobalStateProvider'); + + const { setIsBarLoading } = context; + useEffect(() => { + setIsBarLoading(isFetching) + }, [data]) + return ( diff --git a/src/Pages/Profile/Profile.tsx b/src/Pages/Profile/Profile.tsx index 858216a..b32b9a0 100644 --- a/src/Pages/Profile/Profile.tsx +++ b/src/Pages/Profile/Profile.tsx @@ -1,7 +1,6 @@ -import { Avatar, Box, Field, Input, SimpleGrid, Stack, Text } from "@chakra-ui/react" -import MainFrame from "../../components/MainFrame" +import { Avatar, Box, Field, Input, SimpleGrid, Stack, Text } from "@chakra-ui/react"; import { FaCamera } from "react-icons/fa"; -import { Button } from "../../components/ui/button"; +import MainFrame from "../../components/MainFrame"; import Changepassword from "./ChangePassword"; const Profile = () => { @@ -10,13 +9,11 @@ const Profile = () => { alert("Avatar clicked!")}> - { {`Jackson Da`.slice(0, 10) + '...'} - {/* Employee ID: #1245679 */} Employee ID: #1245679 @@ -35,14 +31,16 @@ const Profile = () => { First Name - + + last Name - + + Phone Number - - + + Update password {/*