diff --git a/src/Pages/ManageCMS/AboutUs/AboutUs.tsx b/src/Pages/ManageCMS/AboutUs/AboutUs.tsx
index cc44cd9..2275af0 100644
--- a/src/Pages/ManageCMS/AboutUs/AboutUs.tsx
+++ b/src/Pages/ManageCMS/AboutUs/AboutUs.tsx
@@ -1,31 +1,19 @@
-import { Box, HStack, Text } from "@chakra-ui/react";
+import { Box, HStack, Skeleton, Text } from "@chakra-ui/react";
import MainFrame from "../../../components/MainFrame"
-import { p } from "framer-motion/client";
import AboutUsAddModel from "../../ManageCMS/AboutUs/AboutUsAddModel";
import { useGetAboutUsQuery } from "../../../Redux/Service/manage.aboutus.service";
-interface AboutUsContent {
- id: number;
- content: string;
-}
-
-interface ApiResponse {
- data: AboutUsContent[];
-}
-
const AboutUs = () => {
- // const {
- // data: data
- // } = useGetAboutUsQuery()
- const { data: response } = useGetAboutUsQuery<{ data: ApiResponse }>();
+ const { data, isLoading } = useGetAboutUsQuery();
+
+ const content = data?.data?.[0]?.content
console.log('====================================');
- console.log(response);
+ // console.log(response);
console.log('====================================');
- const content = response?.data?.[0]?.content || "No content available";
return (
@@ -47,9 +35,35 @@ const AboutUs = () => {
-
+ {/* Show Skeleton until content is available */}
+ {isLoading || !content ? (
+
+
+
+
+
+
+
+
+
+
+
+ ) : (
+
+ {content}
+
+ )}
+ {/*
{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?
*/}
diff --git a/src/Pages/ManageCMS/AboutUs/AboutUsAddModel.tsx b/src/Pages/ManageCMS/AboutUs/AboutUsAddModel.tsx
index 75b9c73..301c0de 100644
--- a/src/Pages/ManageCMS/AboutUs/AboutUsAddModel.tsx
+++ b/src/Pages/ManageCMS/AboutUs/AboutUsAddModel.tsx
@@ -1,53 +1,189 @@
-import { FaRegEdit } from "react-icons/fa"
-import { DialogBody, DialogCloseTrigger, DialogContent, DialogFooter, DialogHeader, DialogRoot, DialogTitle, DialogTrigger } from "../../../components/ui/dialog"
-import { Field, Stack, Text, Textarea } from "@chakra-ui/react"
-import { Button } from "../../../components/ui/button"
+// import { FaRegEdit } from "react-icons/fa"
+// import { DialogBody, DialogCloseTrigger, DialogContent, DialogFooter, DialogHeader, DialogRoot, DialogTitle, DialogTrigger } from "../../../components/ui/dialog"
+// import { Field, Stack, Text, Textarea } from "@chakra-ui/react"
+// import { Button } from "../../../components/ui/button"
+// import { useUpdateAboutUsMutation } from "../../../Redux/Service/manage.aboutus.service"
+
+// function AboutUsAddModel() {
+
+// const [ updateAboutUs ] = useUpdateAboutUsMutation()
+
+
+// try {
+// const res = updateAboutUs({id:2, updatedData:''})
+// console.log(res);
+
+
+// } catch (error) {
+
+// }
+
+
+
+
+// return (
+
+//
+//
+// {/* */}
+//
+
+//
+
+//
+//
+// Edit
+//
+
+//
+//
+
+//
+// AboutUs
+//
+//
+//
+//
+//
+//
+//
+
+//
+//
+//
+
+// )
+// }
+
+// export default AboutUsAddModel
+
+
+import React, { useState } from "react";
+import { FaRegEdit } from "react-icons/fa";
+import {
+ DialogBody,
+ DialogCloseTrigger,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogRoot,
+ DialogTitle,
+ DialogTrigger,
+} from "../../../components/ui/dialog";
+import { Field, Stack, Text, Textarea } from "@chakra-ui/react";
+import { Button } from "../../../components/ui/button";
+import { useUpdateAboutUsMutation } from "../../../Redux/Service/manage.aboutus.service";
function AboutUsAddModel() {
- return (
+ const [content, setContent] = useState(""); // State for the textarea input
+ const [updateAboutUs, { isLoading }] = useUpdateAboutUsMutation(); // Mutation for updating About Us
+ // const toast = useToast(); // Toast for feedback
+ // Handle form submission
+ const handleSubmit = async (e: any) => {
+ e.preventDefault(); // Prevent default form submission
+
+ try {
+ // Call the updateAboutUs mutation
+ const res = await updateAboutUs({ id: 2, updatedData: content }).unwrap();
+ console.log(res);
+
+ // Show success toast
+ // toast({
+ // title: "Success",
+ // description: "About Us content updated successfully",
+ // status: "success",
+ // duration: 5000,
+ // isClosable: true,
+ // });
+
+ // Clear the input field after successful submission
+ setContent("");
+ } catch (error) {
+ // Show error toast
+ // toast({
+ // title: "Error",
+ // description: "Failed to update About Us content",
+ // status: "error",
+ // duration: 5000,
+ // isClosable: true,
+ // });
+ }
+ };
+
+ return (
- {/* */}
-
-
+
-
- Edit
+
+
+ Edit
+
-
-
+
- AboutUs
-
+
+ AboutUs
+
+
-
-
-
-
- )
+
+ );
}
-export default AboutUsAddModel
\ No newline at end of file
+export default AboutUsAddModel;
\ No newline at end of file
diff --git a/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx b/src/Pages/ManageCMS/PrivacyPolicy/PrivacyPolicy.tsx
index 07fe9ea..12a4e46 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();
diff --git a/src/Redux/Service/manage.aboutus.service.ts b/src/Redux/Service/manage.aboutus.service.ts
index 6b82556..428eb61 100644
--- a/src/Redux/Service/manage.aboutus.service.ts
+++ b/src/Redux/Service/manage.aboutus.service.ts
@@ -9,7 +9,7 @@ export const aboutUs = createApi({
// 🔹 GET: Fetch all posts
- getAboutUs: builder.query({
+ getAboutUs: builder.query({
query: () => "/about-us",
}),
@@ -24,18 +24,18 @@ export const aboutUs = createApi({
// 🔹 POST: Create a new post
createPost: builder.mutation>({
- query: (newPost) => ({
+ query: (data) => ({
url: "/posts",
method: "POST",
- body: newPost,
+ body: data,
}),
}),
// 🔹 PUT: Update an existing post
- updatePost: builder.mutation }>({
+ updateAboutUs: builder.mutation({
query: ({ id, updatedData }) => ({
url: `/posts/${id}`,
- method: "PUT",
+ method: "POST",
body: updatedData,
}),
}),
@@ -52,9 +52,20 @@ export const aboutUs = createApi({
export const {
useGetAboutUsQuery,
+ useUpdateAboutUsMutation,
+
+
+
+
+
+
+
+
+
+
+
useGetPostByIdQuery,
- useCreatePostMutation,
- useUpdatePostMutation,
+ useCreatePostMutation,
useDeletePostMutation
} = aboutUs;
@@ -66,9 +77,27 @@ export type Post = {
};
+export type UpdateAboutUsRequest={
+ id: number; updatedData: string
+}
+
+
+export type UpdateAboutUsResponse={
+ id: number; updatedData: string
+}
+
+
export type AboutUs = {
id: number;
language_master_xid: number;
content: string;
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/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