worked on aboutus

This commit is contained in:
2025-02-12 16:38:28 +05:30
7 changed files with 99 additions and 215 deletions

View File

@@ -1,15 +1,17 @@
import { Box, HStack, Skeleton, Text } from "@chakra-ui/react";
import { Box, HStack, Skeleton, Text, VStack } from "@chakra-ui/react";
import MainFrame from "../../../components/MainFrame"
import AboutUsAddModel from "../../ManageCMS/AboutUs/AboutUsAddModel";
import { useGetAboutUsQuery } from "../../../Redux/Service/manage.aboutus.service";
import { Spinner } from "../../../components/Sipnner/Spinner";
import PrivacyPolicySkeleton from "../PrivacyPolicy/PrivacyPolicySkeleton";
const AboutUs = () => {
const { data, isLoading } = useGetAboutUsQuery();
const { data, isLoading, isFetching } = useGetAboutUsQuery();
const content = data?.data?.[0]?.content
// const content = data?.data
console.log('====================================');
console.log(data);
console.log('====================================');
@@ -18,56 +20,41 @@ const AboutUs = () => {
return (
<MainFrame>
<Box>
<HStack
w={"100%"}
justifyContent={"space-between"}
mb={4}
py={0}
px={3}
>
<Text as={"span"} fontSize={"sm"} fontWeight={500} color={"#000"}>
AboutUs
</Text>
<HStack>
{isLoading ? <Spinner /> :
<VStack gap={4} pb={4}>
{data?.data?.map(({ id, content }, index) => <VStack bg={'#fff'}
boxShadow={'rgba(99, 99, 99, 0.2) 0px 2px 8px 0px'} rounded={'lg'} p={3} key={id}>
<HStack
w={"100%"}
justifyContent={"space-between"}
<AboutUsAddModel />
</HStack>
</HStack>
{/* Show Skeleton until content is available */}
{isLoading || !content ? (
<Box px={3} w="85%">
<Skeleton height="20px" mb="10px" />
<Skeleton height="20px" mb="10px" />
<Skeleton height="20px" mb="10px" />
<Skeleton height="20px" mb="10px" width="75%" />
<Skeleton height="20px" mb="15px" width="90%" />
<Skeleton height="20px" mb="10px" />
<Skeleton height="20px" mb="10px" width="85%" />
<Skeleton height="20px" mb="10px" />
<Skeleton height="20px" width="70%" />
</Box>
) : (
<Text
as="p"
fontSize="sm"
fontWeight={400}
color="#1D1D1D"
px={3}
w="85%"
mb="15px"
>
{content}
</Text>
)}
{/* <Text as={p} fontSize={"sm"} fontWeight={400} color={"#1D1D1D"} px={3} w={"85%"} mb={"15px"} >
{content}
</Text> */}
{/* <Text as={p} fontSize={"sm"} fontWeight={400} color={"#1D1D1D"} px={3} w={"85%"} >
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?
</Text> */}
</Box>
py={0}
px={0}
>
<Text as={"span"} fontSize={"sm"} fontWeight={500} color={"#000"}>
About Us </Text>
{/* <PrivacyPolicyAddModel /> */}
<AboutUsAddModel />
</HStack>
{/* Render multiple skeletons or content based on loading state */}
{isFetching || !content ? (
<PrivacyPolicySkeleton />
) : (
<Text
as="p"
fontSize="sm"
fontWeight={400}
color="#1D1D1D"
>
{content}
</Text>
)}
</VStack>)}
</VStack>}
</MainFrame>
)
}

View File

@@ -1,76 +1,3 @@
// 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 (
// <DialogRoot placement="center">
// <DialogTrigger asChild>
// {/* <Button bg={"transparent"} size="sm">
// <MdOutlineRemoveRedEye style={{ cursor: "pointer", fontSize: "16px" }} />
// </Button> */}
// <Button bgColor={'#EEEEEE'} pl={3} pr={3} size={'xs'} color={'#000'}> <FaRegEdit color="#000" style={{ height: '14px', width: '14px' }} /> <Text color={"#000"} mt={1}>Edit</Text></Button>
// </DialogTrigger>
// <DialogContent
// bg={"#fff"}
// // w={{ lg: "60%", md: "230px" }}
// w={{ base: '90%', md: '400px' }}
// height={"auto"}
// p={3} // Reduced padding
// bgSize={'md'}
// >
// <DialogHeader bg="white" >
// <DialogTitle alignSelf="center" color="black" fontSize="14px">Edit</DialogTitle>
// </DialogHeader>
// <DialogBody bg="white">
// <Stack py={3} >
// <Field.Root>
// <Field.Label color="black" pt={1} fontSize="12px">AboutUs</Field.Label>
// <Textarea placeholder="" bgColor="#EEEEEE" color="black" border="none" pl={1} fontSize="12px" height="30px" pt={1.5} />
// </Field.Root>
// </Stack>
// </DialogBody>
// <DialogFooter display="flex" justifyContent="center" pt={"2"}>
// <Button w="100%" bg="#02A0A0" color={"#fff"}>
// Save
// </Button>
// </DialogFooter>
// <DialogCloseTrigger color="black" />
// </DialogContent>
// </DialogRoot >
// )
// }
// export default AboutUsAddModel
import React, { useState } from "react";
import { FaRegEdit } from "react-icons/fa";
import {
DialogBody,
@@ -84,44 +11,8 @@ import {
} 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 [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 (
<DialogRoot placement="center">
@@ -161,8 +52,6 @@ function AboutUsAddModel() {
fontSize="12px"
height="100px" // Increased height for better usability
pt={1.5}
value={content} // Bind the state to the textarea
onChange={(e) => setContent(e.target.value)} // Update state on change
/>
</Field.Root>
</Stack>
@@ -173,7 +62,6 @@ function AboutUsAddModel() {
w="100%"
bg="#02A0A0"
color="#fff"
onClick={handleSubmit} // Trigger handleSubmit on button click
// isLoading={isLoading} // Show loading state while the mutation is in progress
>
Save

View File

@@ -1,12 +1,14 @@
import { Box, HStack, Text, Skeleton } from "@chakra-ui/react";
import { Box, HStack, Text, Skeleton, VStack } from "@chakra-ui/react";
import MainFrame from "../../../components/MainFrame";
import PrivacyPolicyAddModel from "./PrivacyPolicyAddModel";
import { useGetPrivacyPolicyQuery } from "../../../Redux/Service/privacy.policy.service";
import PrivacyPolicySkeleton from "./PrivacyPolicySkeleton";
import { Spinner } from "../../../components/Sipnner/Spinner";
const PrivacyPolicy = () => {
// Fetch data using RTK Query with type annotations
const { data, isLoading } = useGetPrivacyPolicyQuery();
const { data, isLoading, isFetching } = useGetPrivacyPolicyQuery();
console.log(isLoading);
@@ -16,51 +18,42 @@ const PrivacyPolicy = () => {
console.log(data);
console.log("====================================");
// Extract content array from the response
const content = data?.data?.[0]?.content;
return (
<MainFrame>
<Box>
<HStack
w={"100%"}
justifyContent={"space-between"}
mb={4}
py={0}
px={3}
>
<Text as={"span"} fontSize={"sm"} fontWeight={500} color={"#000"}>
Privacy Policy
</Text>
<MainFrame transperant={true}>
{isLoading ? <Spinner /> :
<VStack gap={4} pb={4}>
{data?.data?.map(({ id, content }, index) => <VStack bg={'#fff'}
boxShadow={'rgba(99, 99, 99, 0.2) 0px 2px 8px 0px'} rounded={'lg'} p={3} key={id}>
<HStack
w={"100%"}
justifyContent={"space-between"}
<HStack>
<PrivacyPolicyAddModel />
</HStack>
</HStack>
py={0}
px={0}
>
<Text as={"span"} fontSize={"sm"} fontWeight={500} color={"#000"}>
Privacy Policy
</Text>
{/* Render multiple skeletons or content based on loading state */}
{isLoading || !content ? (
<Box px={3} pb={3} w="90%">
<Skeleton height="20px" mb="10px" width="90%" />
<Skeleton height="20px" mb="15px" width="90%" />
<Skeleton height="20px" mb="10px" width="90%" />
<Skeleton height="20px" mb="10px" width="80%" />
<Skeleton height="20px" width="60%" />
</Box>
) : (
<Text
as="p"
fontSize="sm"
fontWeight={400}
color="#1D1D1D"
px={3}
w="85%"
mb="15px"
>
{content}
</Text>
)}
</Box>
<PrivacyPolicyAddModel />
</HStack>
{/* Render multiple skeletons or content based on loading state */}
{isFetching || !content ? (
<PrivacyPolicySkeleton />
) : (
<Text
as="p"
fontSize="sm"
fontWeight={400}
color="#1D1D1D"
>
{content}
</Text>
)}
</VStack>)}
</VStack>}
</MainFrame>
);
};

View File

@@ -11,7 +11,7 @@ function PrivacyPolicyAddModel() {
{/* <Button bg={"transparent"} size="sm">
<MdOutlineRemoveRedEye style={{ cursor: "pointer", fontSize: "16px" }} />
</Button> */}
<Button bgColor={'#EEEEEE'} pl={3} pr={3} size={'xs'} color={'#000'}> <FaRegEdit color="#000" style={{ height: '14px', width: '14px' }} /> <Text color={"#000"} mt={1}>Edit</Text></Button>
<Button bgColor={'#EEEEEE'} pl={3} pr={3} size={'2xs'} color={'#000'}> <FaRegEdit color="#000" /> <Text fontSize={'xs'} color={"#000"} >Edit</Text></Button>
</DialogTrigger>

View File

@@ -0,0 +1,15 @@
import { Box, Skeleton } from '@chakra-ui/react'
const PrivacyPolicySkeleton = () => {
return (
<Box px={3} pb={3} w="90%">
<Skeleton height="20px" mb="10px" width="90%" />
<Skeleton height="20px" mb="15px" width="90%" />
<Skeleton height="20px" mb="10px" width="90%" />
<Skeleton height="20px" mb="10px" width="80%" />
<Skeleton height="20px" width="60%" />
</Box>
)
}
export default PrivacyPolicySkeleton

View File

@@ -78,12 +78,12 @@ export type Post = {
export type UpdateAboutUsRequest={
id: number; updatedData: string
id: number; updatedData: string,language_code:string
}
export type UpdateAboutUsResponse={
id: number; updatedData: string
id: number; updatedData: string,language_code:string
}

View File

@@ -9,19 +9,20 @@ const MotionVStack = motion(VStack)
interface MainFrameProps {
children: React.ReactNode
title?: string
transperant?:boolean
}
const MainFrame: FC<MainFrameProps> = ({ children }) => {
const MainFrame: FC<MainFrameProps> = ({ children, transperant }) => {
return (
<MotionVStack rounded="lg" overflowY={'auto'} overflowX={'hidden'} {...OPACITY_ON_LOAD} w="100%" minH="93%" p={0} pe={2} ps={1.5} pb={2}>
<MotionVStack rounded="lg" overflowY={'auto'} overflowX={'hidden'} {...OPACITY_ON_LOAD} w="100%" minH="93%" pe={2} ps={1.5} pt={transperant?0:1} pb={2}>
<Box
w="100%"
// h="100%"
bg="#ffffff"
h="100%"
bg={transperant?'transperant':"#ffffff"}
// overflow={'scroll'}
rounded="lg"
boxShadow={'rgba(99, 99, 99, 0.2) 0px 2px 8px 0px'}
pt={3}
boxShadow={transperant?'none':'rgba(99, 99, 99, 0.2) 0px 2px 8px 0px'}
pt={transperant?0:3}
>
{children}