From 0bd8cc6434f6cfe1d8e571f80c54215bbb1af1bf Mon Sep 17 00:00:00 2001 From: "Siddhesh.More" Date: Wed, 12 Feb 2025 12:27:53 +0530 Subject: [PATCH] update types folder --- .../ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx | 12 +--- src/Redux/Service/privacy.policy.service.ts | 66 ++----------------- src/Types/privacyPolicyTypes.tsx | 12 ++++ 3 files changed, 20 insertions(+), 70 deletions(-) create mode 100644 src/Types/privacyPolicyTypes.tsx diff --git a/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx b/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx index f33ba9c..94b6f41 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/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/privacyPolicyTypes.tsx b/src/Types/privacyPolicyTypes.tsx new file mode 100644 index 0000000..d5a8493 --- /dev/null +++ b/src/Types/privacyPolicyTypes.tsx @@ -0,0 +1,12 @@ +export type PrivacyPolicy = { + success: boolean; + message: string; + data: T; +}; + +export interface PrivacyPolicyContent { + id: number; + content: string; +} + +export type PrivacyPolicyResponse = PrivacyPolicy; // Fix here