diff --git a/src/Pages/ManageCMS/AboutUs/AboutUs.tsx b/src/Pages/ManageCMS/AboutUs/AboutUs.tsx index 2275af0..7eba327 100644 --- a/src/Pages/ManageCMS/AboutUs/AboutUs.tsx +++ b/src/Pages/ManageCMS/AboutUs/AboutUs.tsx @@ -11,7 +11,7 @@ const AboutUs = () => { const content = data?.data?.[0]?.content console.log('===================================='); - // console.log(response); + console.log(data); console.log('===================================='); diff --git a/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx b/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx index 2d3f305..f40d471 100644 --- a/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx +++ b/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx @@ -3,20 +3,10 @@ import MainFrame from "../../../components/MainFrame"; import PrivacyPolicyAddModel from "./PrivacyPolicyAddModel"; import { useGetPrivacyPolicyQuery } from "../../../Redux/Service/privacy.policy.service"; -// Define interfaces -interface PrivacyPolicyContent { - id: number; - content: string; -} - -interface ApiResponse { - data: { data: PrivacyPolicyContent[] }; - isLoading: boolean -} const PrivacyPolicy = () => { // Fetch data using RTK Query with type annotations - const { data, isLoading } = useGetPrivacyPolicyQuery(); + const { data, isLoading } = useGetPrivacyPolicyQuery(); console.log(isLoading); diff --git a/src/Redux/Service/manage.aboutus.service.ts b/src/Redux/Service/manage.aboutus.service.ts index 428eb61..1465b2f 100644 --- a/src/Redux/Service/manage.aboutus.service.ts +++ b/src/Redux/Service/manage.aboutus.service.ts @@ -1,6 +1,6 @@ import { createApi } from "@reduxjs/toolkit/query/react"; import { baseQueryWithReauth } from "./apiSlice"; - +import { AboutUsResponse } from "../../Types/aboutUsType"; export const aboutUs = createApi({ reducerPath: "aboutUs", baseQuery: baseQueryWithReauth, // Use enhanced baseQuery with error handling @@ -94,10 +94,3 @@ export type AboutUs = { is_active: boolean; }; -// First define your interface -interface AboutUsResponse { - data: { - content: string; - // other fields... - }[]; -} \ No newline at end of file diff --git a/src/Redux/Service/privacy.policy.service.ts b/src/Redux/Service/privacy.policy.service.ts index b2e0bbb..52ba4d8 100644 --- a/src/Redux/Service/privacy.policy.service.ts +++ b/src/Redux/Service/privacy.policy.service.ts @@ -1,68 +1,16 @@ -import { createApi } from "@reduxjs/toolkit/query/react"; // Fix import -import { baseQueryWithReauth } from "./apiSlice"; - - - +import { createApi } from "@reduxjs/toolkit/query/react"; +import { baseQueryWithReauth } from "./apiSlice"; // Ensure this is correctly configured +import { PrivacyPolicyResponse } from "../../Types/privacyPolicyTypes"; export const privacyPolicy = createApi({ reducerPath: "privacyPolicy", - baseQuery: baseQueryWithReauth, // Use enhanced baseQuery with error handling + baseQuery: baseQueryWithReauth, // Ensure this returns a valid `BaseQueryFn` endpoints: (builder) => ({ - // 🔹 GET: Fetch all privacy policies - getPrivacyPolicy: builder.query({ + getPrivacyPolicy: builder.query({ // Fix types here query: () => "/privacy-policy", }), - - // 🔹 GET: Fetch a single post by ID - // getPostById: builder.query({ - // query: (id) => `/posts/${id}`, - // }), - - // 🔹 POST: Create a new post - // createPost: builder.mutation>({ - // query: (newPost) => ({ - // url: "/posts", - // method: "POST", - // body: newPost, - // }), - // }), - - // 🔹 PUT: Update an existing post - // updatePost: builder.mutation }>({ - // query: ({ id, updatedData }) => ({ - // url: `/posts/${id}`, - // method: "PUT", - // body: updatedData, - // }), - // }), - - // 🔹 DELETE: Remove a post by ID - // deletePost: builder.mutation<{ success: boolean }, number>({ - // query: (id) => ({ - // url: `/posts/${id}`, - // method: "DELETE", - // }), - // }), }), }); -// Export hooks for usage in components -export const { - useGetPrivacyPolicyQuery, // Export the correct hook - -} = privacyPolicy; - - -// Define types at the top for better readability -export type Post = { - id: number; - title: string; - body: string; -}; - -export type PrivacyPolicy = { - id: number; - language_master_xid: number; - content: string; - is_active: boolean; -}; \ No newline at end of file +// Export hook +export const { useGetPrivacyPolicyQuery } = privacyPolicy; diff --git a/src/Types/aboutUsType.tsx b/src/Types/aboutUsType.tsx new file mode 100644 index 0000000..0a99393 --- /dev/null +++ b/src/Types/aboutUsType.tsx @@ -0,0 +1,22 @@ +// First define your interface +// export interface AboutUsResponse { +// data: { +// content: string; +// // other fields... +// }[]; +// } + + +export interface AboutUsContent { + id: number; + language_master_xid: number; + content: string; + is_active: boolean; +} + +export interface AboutUsResponse { + status: "success" | "error"; // Assuming it can be "success" or "error" + status_code: number; + message: string; + data: AboutUsContent[]; +} \ No newline at end of file diff --git a/src/Types/privacyPolicyTypes.tsx b/src/Types/privacyPolicyTypes.tsx new file mode 100644 index 0000000..fce8cb3 --- /dev/null +++ b/src/Types/privacyPolicyTypes.tsx @@ -0,0 +1,13 @@ +export interface PrivacyPolicyContent { + id: number; + language_master_xid: number; + content: string; + is_active: boolean; +} + +export interface PrivacyPolicyResponse { + status: "success" | "error"; // Assuming it can be "success" or "error" + status_code: number; + message: string; + data: PrivacyPolicyContent[]; +} \ No newline at end of file