From 44a6f60868ec64147ec5f90ddf0e0a8145b6cfa7 Mon Sep 17 00:00:00 2001 From: rockyeverlast Date: Fri, 7 Mar 2025 20:13:25 +0530 Subject: [PATCH] Faq / JobType / IndustryMaster/TemplateMaster/Pagination data enabled --- src/Pages/ManageCMS/FAQ/EditDetails.tsx | 82 +++++++++- src/Pages/ManageCMS/FAQ/FAQ.tsx | 113 +++++++++++-- src/Pages/ManageCMS/FAQ/FaqAddModel.tsx | 105 +++++++++++- .../AgencyMaster/AgencyMaster.tsx | 2 + .../IndustryMaster/AddIndustryMaster.tsx | 103 ++++++++++++ .../IndustryMaster/EditIndustryMaster.tsx | 112 +++++++++++++ .../IndustryMaster/IndustryMasterList.tsx | 154 ++++++++++++++++++ .../MasterModule/JobType/EditJobModel.tsx | 58 ++++++- .../MasterModule/JobType/JobAddModel.tsx | 72 ++++++-- src/Pages/MasterModule/JobType/JobType.tsx | 86 ++++++++-- .../TemplateMaster/EditTemplateModel.tsx | 127 +++++++++++---- .../TemplateMaster/TemplateAddModel.tsx | 18 +- .../TemplateMaster/TemplateMaster.tsx | 4 +- src/Redux/Service/faqs.service.ts | 102 +++++++++--- src/Redux/Service/industry.master.service.ts | 92 +++++++++++ src/Redux/Service/job.type.service.ts | 21 +-- src/Redux/Service/template.master.service.ts | 18 +- src/Redux/Store.tsx | 3 + src/Routes/Nav.ts | 15 +- src/Routes/Routes.ts | 2 + src/components/DataTable.tsx | 44 ++++- 21 files changed, 1177 insertions(+), 156 deletions(-) create mode 100644 src/Pages/MasterModule/IndustryMaster/AddIndustryMaster.tsx create mode 100644 src/Pages/MasterModule/IndustryMaster/EditIndustryMaster.tsx create mode 100644 src/Pages/MasterModule/IndustryMaster/IndustryMasterList.tsx create mode 100644 src/Redux/Service/industry.master.service.ts diff --git a/src/Pages/ManageCMS/FAQ/EditDetails.tsx b/src/Pages/ManageCMS/FAQ/EditDetails.tsx index b712125..3bc39fe 100644 --- a/src/Pages/ManageCMS/FAQ/EditDetails.tsx +++ b/src/Pages/ManageCMS/FAQ/EditDetails.tsx @@ -93,20 +93,82 @@ import { } from "../../../components/ui/dialog"; import { Field, Input, Stack, Textarea } from "@chakra-ui/react"; import Edit from "../../../components/ActionIcons/Edit"; +import { useUpdateFaqMutation } from "../../../Redux/Service/faqs.service"; +import { useEffect, useState } from "react"; +import { toaster } from "../../../components/ui/toaster"; interface RowData { - id: string; + id: number; question: string; answer: string; } -function EditDetails(rowData: RowData) { +function EditDetails({ rowData, refetch }: {rowData: RowData, refetch: VoidFunction}) { + const [faqQuestion, setFaqQuestion] = useState(rowData?.question); + const [faqAnswer, setFaqAnswer] = useState(rowData?.answer); + const [isOpen, setIsOpen] = useState(false); + const [updateFaq] = useUpdateFaqMutation() + + // console.log('ROWDATA', rowData); + + + useEffect(() => { + if (rowData) { + setFaqQuestion(rowData.question); + setFaqAnswer(rowData.answer); + } + }, [rowData]); + + + const handleOpenModal = () => { + setIsOpen(true); + }; + + + const handleSubmit = async () => { + if (!faqQuestion.trim() || !faqAnswer.trim()) { + toaster.create({ + title: "Error", + description: "Input fields cannot be empty", + type: "error", + }); + return; + } + + const payload = { + id: rowData?.id, + question: faqQuestion, + answer: faqAnswer + }; + + try { + const response = await updateFaq(payload).unwrap(); + if (response?.status === "success") { + toaster.create({ + title: "Success", + description: "FAQ updated successfully", + type: "success", + }); + refetch() + setIsOpen(false); + } else { + toaster.create({ + title: "Error", + description: "Failed to update FAQ", + type: "error", + }); + } + } catch (error) { + console.error("Error updating template:", error); + // alert("Failed to update template"); + } + }; return ( - + setIsOpen(open)}> - + setFaqQuestion(e.target.value)} /> @@ -148,21 +211,22 @@ function EditDetails(rowData: RowData) { border="none" p={2} fontSize="12px" - height="30px" + height="auto" pt={1.5} - defaultValue={rowData?.answer} // Pre-fill answer + value={faqAnswer} + onChange={(e) => setFaqAnswer(e.target.value)} /> - - + setIsOpen(false)} /> ); diff --git a/src/Pages/ManageCMS/FAQ/FAQ.tsx b/src/Pages/ManageCMS/FAQ/FAQ.tsx index cc0a840..4fb30a3 100644 --- a/src/Pages/ManageCMS/FAQ/FAQ.tsx +++ b/src/Pages/ManageCMS/FAQ/FAQ.tsx @@ -8,6 +8,8 @@ import AlertDailog from "../../../components/AlertDailog"; import { Switch } from "../../../components/ui/switch"; import FaqAddModel from "./FaqAddModel"; import Delete from "../../../components/ActionIcons/Delete"; +import { useEffect, useState } from "react"; +import { FaqData, useDeleteFaqPostMutation, useFaqToggleMutation, useGetFaqQuery } from "../../../Redux/Service/faqs.service"; // table data @@ -19,18 +21,88 @@ const tableHeadRow = [ "Action", ]; -const managepost: any[] = [ - ...Array.from({ length: 12 }, (_, i) => ({ - "Sr. No": i + 1, - "Question": "Lorem Ipsum", - "Answer": "Lorem Ipsum", +// const managepost: any[] = [ +// ...Array.from({ length: 12 }, (_, i) => ({ +// "Sr. No": i + 1, +// "Question": "Lorem Ipsum", +// "Answer": "Lorem Ipsum", +// "Action": ( +// +// +// +// +// {/* */} +// + +// } +// alertText="Delete Users" +// alertIcon={} +// alertCaption="are you sure you want to delete ?" +// onConfirm={() => { +// console.log("User deleted:", i + 1); +// }} +// /> +// +// ), +// })), +// ]; + +const FAQ = () => { + const { data, refetch } = useGetFaqQuery() + const [localData, setLocalData] = useState([]); + const [faqToggle] = useFaqToggleMutation() + const [deleteFaqPost] = useDeleteFaqPostMutation() + + console.log('DATA', data?.data); + + useEffect(() => { + if (data?.data) { + setLocalData(data?.data); + } + }, [data]); + + + const handleToggle = async (agencyId: string, currentStatus: number) => { + const newStatus = currentStatus ? 0 : 1; + setLocalData((prevData) => + prevData.map((agency) => + agency.id === agencyId ? { ...agency, is_active: newStatus } : agency + ) + ); + try { + await faqToggle({ id: agencyId, is_active: newStatus }).unwrap(); + refetch() + } catch (error) { + console.error("Error updating privacy policy:", error); + setLocalData((prevData) => + prevData.map((agency) => + agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency + ) + ); + } + }; + + const handleDeleteFaq = async (faqId: number) => { + try { + const response = await deleteFaqPost(faqId).unwrap(); + refetch() + console.log("FAQ deleted successfully:", response); + // Optionally, refetch data or update state after deletion + } catch (error) { + console.error("Error deleting FAQ:", error); + } + }; + + const managepost = localData?.map((agency: FaqData, index: number) => ({ + 'id': agency.id, + "Sr. No": index + 1, + "Question": agency.question, + "Answer": agency.answer, + "Action": ( - - - - {/* */} - + } @@ -38,15 +110,22 @@ const managepost: any[] = [ alertIcon={} alertCaption="are you sure you want to delete ?" onConfirm={() => { - console.log("User deleted:", i + 1); + // console.log("User deleted:", index + 1); + handleDeleteFaq(agency.id) }} /> + + handleToggle(agency.id.toString(), Number(agency.is_active))} + checked={Boolean(Number(agency.is_active))} + /> + ), - })), -]; + })); -const FAQ = () => { return ( @@ -84,13 +163,15 @@ const FAQ = () => { /> {/* */} - + diff --git a/src/Pages/ManageCMS/FAQ/FaqAddModel.tsx b/src/Pages/ManageCMS/FAQ/FaqAddModel.tsx index 5af08af..6ddfe1e 100644 --- a/src/Pages/ManageCMS/FAQ/FaqAddModel.tsx +++ b/src/Pages/ManageCMS/FAQ/FaqAddModel.tsx @@ -8,15 +8,77 @@ import { DialogTitle, DialogTrigger, } from "../../../components/ui/dialog"; -import { Field, Input, Stack, Text, Textarea } from "@chakra-ui/react"; +import { Box, Field, Input, Stack, Text, Textarea } from "@chakra-ui/react"; import { IoMdAdd } from "react-icons/io"; import { Button } from "../../../components/ui/button"; +import { useState } from "react"; +import { toaster } from "../../../components/ui/toaster"; +import { useCreateFaqPostMutation } from "../../../Redux/Service/faqs.service"; + +function FaqAddModel({ refetch }: { refetch: VoidFunction }) { + const [faqQuestion, setFaqQuestion] = useState(''); + const [faqAnswer, setFaqAnswer] = useState(''); + const [userType, setUserType] = useState(""); + const [isOpen, setIsOpen] = useState(false); + const [createFaqPost] = useCreateFaqPostMutation() + + const handleOpenModal = () => { + setIsOpen(true); // Open modal when clicking "Add" + }; + + const handleSubmit = async () => { + if (userType === "" || isNaN(Number(userType))) { + toaster.create({ + title: "Error", + description: "Please select a valid user type.", + type: "error", + }); + return; + } + + if (!faqQuestion.trim() || !faqAnswer.trim()) { + toaster.create({ + title: "Error", + description: "Please fill in all required fields", + type: "error", + }); + return; + } + + const payload = { + principal_type_xid: Number(userType), + language_code: 'en', + question: faqQuestion, + answer: faqAnswer + }; + + try { + const response = await createFaqPost(payload).unwrap(); + if (response) { + toaster.create({ + title: "Success", + description: "FAQ updated successfully", + type: "success", + }); + refetch() + setIsOpen(false); + } else { + toaster.create({ + title: "Error", + description: "Failed to update FAQ", + type: "error", + }); + } + } catch (error) { + console.error("Error updating template:", error); + // alert("Failed to update template"); + } + }; -function FaqAddModel() { return ( - + setIsOpen(open)}> - @@ -37,6 +99,29 @@ function FaqAddModel() { + + Select User Type + + + + + Questions @@ -48,8 +133,10 @@ function FaqAddModel() { border="none" pl={1} fontSize="12px" - _focusVisible={{outline:'none'}} + _focusVisible={{ outline: 'none' }} size={'sm'} + value={faqQuestion} + onChange={(e) => setFaqQuestion(e.target.value)} /> @@ -64,18 +151,20 @@ function FaqAddModel() { fontSize="12px" height="120px" resize={'none'} - _focusVisible={{outline:'none'}} + _focusVisible={{ outline: 'none' }} + value={faqAnswer} + onChange={(e) => setFaqAnswer(e.target.value)} /> - - + setIsOpen(false)} /> ); diff --git a/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx b/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx index 39e03a6..2876ef3 100644 --- a/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx +++ b/src/Pages/MasterModule/AgencyMaster/AgencyMaster.tsx @@ -156,6 +156,8 @@ const AgencyMaster = () => { sortableColumns={["Name", "Registration Date "]} tableHeadRow={tableHeadRow} data={managepost || []} + paginationData={data?.data} + refetch={refetch} /> diff --git a/src/Pages/MasterModule/IndustryMaster/AddIndustryMaster.tsx b/src/Pages/MasterModule/IndustryMaster/AddIndustryMaster.tsx new file mode 100644 index 0000000..356cce1 --- /dev/null +++ b/src/Pages/MasterModule/IndustryMaster/AddIndustryMaster.tsx @@ -0,0 +1,103 @@ +import { DialogBody, DialogCloseTrigger, DialogContent, DialogFooter, DialogHeader, DialogRoot, DialogTitle, DialogTrigger } from "../../../components/ui/dialog" +import { Field, Input, Stack, Text } from "@chakra-ui/react" +import { IoMdAdd } from "react-icons/io" +import { Button } from "../../../components/ui/button" +import { useState } from "react"; +import { toaster } from "../../../components/ui/toaster"; +import { useCreateIndustryMasterPostMutation } from "../../../Redux/Service/industry.master.service"; + +function AddIndustryMaster({ refetch }: { refetch: VoidFunction }) { + const [jobType, setJobType] = useState(""); + const [isOpen, setIsOpen] = useState(false); + const [createIndustryMasterPost] = useCreateIndustryMasterPostMutation() + + const handleOpenModal = () => { + setIsOpen(true); // Open modal when clicking "Add" + }; + + const handleSubmit = async () => { + if (!jobType.trim()) { + toaster.create({ + title: "Error", + description: "Title and Subtitle cannot be empty.", + type: "error", + }); + return; + } + + const payload = { + en_name: jobType, + categories_masters_xid:4 + }; + + try { + await createIndustryMasterPost(payload); + refetch() + setIsOpen(false); + } catch (error) { + console.error("Error updating template:", error); + alert("Failed to update template"); + } + }; + + return ( + + + + {/* */} + + + + + + + Add + + + + + + + Job Type + setJobType(e.target.value)} + /> + + + + + + + + + setIsOpen(false)} /> + + + + ) +} + +export default AddIndustryMaster \ No newline at end of file diff --git a/src/Pages/MasterModule/IndustryMaster/EditIndustryMaster.tsx b/src/Pages/MasterModule/IndustryMaster/EditIndustryMaster.tsx new file mode 100644 index 0000000..745c9ec --- /dev/null +++ b/src/Pages/MasterModule/IndustryMaster/EditIndustryMaster.tsx @@ -0,0 +1,112 @@ +import { + DialogBody, + DialogCloseTrigger, + DialogContent, + DialogFooter, + DialogHeader, + DialogRoot, + DialogTitle, + DialogTrigger, +} from "../../../components/ui/dialog"; +import { Box, Field, Input, Stack } from "@chakra-ui/react"; +import { Button } from "../../../components/ui/button"; +import Edit from "../../../components/ActionIcons/Edit"; +import { useState } from "react"; +import { toaster } from "../../../components/ui/toaster"; +import { useUpdateIndustryMasterMutation } from "../../../Redux/Service/industry.master.service"; + +function EditIndustryMaster({ id, localData, refetch, categories }: { id: number, localData: any, refetch: VoidFunction, categories: any }) { + const [jobtype, setJobType] = useState(""); + const [updateIndustryMaster] = useUpdateIndustryMasterMutation() + const [isOpen, setIsOpen] = useState(false); + + const handleOpenModal = () => { + const template = localData?.find((item: any) => item.id === id); + if (template) { + setJobType(template.en_name); + setIsOpen(true); + } + }; + + + const handleSubmit = async () => { + if (!jobtype.trim()) { + toaster.create({ + title: "Error", + description: "Title and Subtitle cannot be empty.", + type: "error", + }); + return; + } + + const payload = { + id: id, + en_name: jobtype, + categories_masters_xid: categories + }; + + try { + await updateIndustryMaster(payload); + refetch() + setIsOpen(false); + } catch (error) { + console.error("Error updating template:", error); + alert("Failed to update template"); + } + }; + + return ( + setIsOpen(open)}> + + + + + + + + + + Edit + + + + + + + + Job Type + + setJobType(e.target.value)} + /> + + + + + + + + setIsOpen(false)} /> + + + ); +} + +export default EditIndustryMaster; diff --git a/src/Pages/MasterModule/IndustryMaster/IndustryMasterList.tsx b/src/Pages/MasterModule/IndustryMaster/IndustryMasterList.tsx new file mode 100644 index 0000000..ccd9501 --- /dev/null +++ b/src/Pages/MasterModule/IndustryMaster/IndustryMasterList.tsx @@ -0,0 +1,154 @@ +import { Box, HStack, Input, Text } from "@chakra-ui/react"; +import MainFrame from "../../../components/MainFrame" +import { InputGroup } from "../../../components/ui/input-group"; +import { LuSearch } from "react-icons/lu"; +import DataTable from "../../../components/DataTable"; +import { Switch } from "../../../components/ui/switch"; +import { useEffect, useState } from "react"; +import { useGetIndustryMasterQuery, useIndustryMasterToggleMutation } from "../../../Redux/Service/industry.master.service"; +import EditIndustryMaster from "./EditIndustryMaster"; +import AddIndustryMaster from "./AddIndustryMaster"; + + +// table data + +const tableHeadRow = [ + "Sr. No", + "Title", + "Action" + +]; + +// const managepost: any[] = [ +// ...Array.from({ length: 12 }, (_, i) => ({ +// "Sr. No": i + 1, +// "Agency Name": "Lorem Ipsum", +// "RC no.": "Lorem Ipsum", +// "State": "Lorem Ipsum", +// "RC Status": "Active", +// "Registered Office Address": "Lorem Ipsum", +// "Website/Domain": "Lorem Ipsum", +// "GST no.": "Lorem Ipsum", +// "Action": ( +// +// +// +// +// +// +// +// ), +// })), +// ]; + +const IndustryMasterList = () => { + const { data, refetch } = useGetIndustryMasterQuery() + const [industryMasterToggle] = useIndustryMasterToggleMutation() + const [localData, setLocalData] = useState([]); + + useEffect(() => { + if (data?.data?.data) { + setLocalData(data?.data.data); + } + }, [data]); + + const handleToggle = async (agencyId: string, currentStatus: number) => { + const newStatus = currentStatus ? 0 : 1; + setLocalData((prevData) => + prevData.map((agency) => + agency.id === agencyId ? { ...agency, is_active: newStatus } : agency + ) + ); + try { + await industryMasterToggle({ id: agencyId, is_active: newStatus }).unwrap(); + refetch() + } catch (error) { + console.error("Error updating privacy policy:", error); + setLocalData((prevData) => + prevData.map((agency) => + agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency + ) + ); + } + }; + + const managepost = localData?.map((agency: any, index: number) => ({ + 'id': agency.id, + "Sr. No": index + 1, + "Title": agency.en_name, + "is_active": agency.is_active, + "Action": ( + + {/* */} + + + handleToggle(agency.id, Number(agency.is_active))} + checked={Boolean(Number(agency.is_active))} + /> + + + ), + })); + + useEffect(() => { + console.log("Fetched data:", data); + console.log("Local data:", localData); + console.log("Managepost data:", managepost); + }, [data, localData, managepost]); + + return ( + + + + + + Industry Master + + + + + } + color={"#000"} + > + + + {/* */} + {/* */} + + + + + + + ) +} +export default IndustryMasterList \ No newline at end of file diff --git a/src/Pages/MasterModule/JobType/EditJobModel.tsx b/src/Pages/MasterModule/JobType/EditJobModel.tsx index a498485..f5063c7 100644 --- a/src/Pages/MasterModule/JobType/EditJobModel.tsx +++ b/src/Pages/MasterModule/JobType/EditJobModel.tsx @@ -8,15 +8,58 @@ import { DialogTitle, DialogTrigger, } from "../../../components/ui/dialog"; -import { Field, Input, Span, Stack } from "@chakra-ui/react"; +import { Box, Field, Input, Stack } from "@chakra-ui/react"; import { Button } from "../../../components/ui/button"; import Edit from "../../../components/ActionIcons/Edit"; +import { useState } from "react"; +import { useUpdateJobTypeMutation } from "../../../Redux/Service/job.type.service"; +import { toaster } from "../../../components/ui/toaster"; + +function EditJobeModel({ id, localData, refetch }: { id: number, localData: any, refetch: VoidFunction }) { + const [jobtype, setJobType] = useState(""); + const [updateJobType] = useUpdateJobTypeMutation() + const [isOpen, setIsOpen] = useState(false); + + const handleOpenModal = () => { + const template = localData?.find((item: any) => item.id === id); + if (template) { + setJobType(template.en_name); + setIsOpen(true); + } + }; + + + const handleSubmit = async () => { + if (!jobtype.trim()) { + toaster.create({ + title: "Error", + description: "Title and Subtitle cannot be empty.", + type: "error", + }); + return; + } + + const payload = { + id: id, + en_name: jobtype, + }; + + try { + await updateJobType(payload); + refetch() + setIsOpen(false); + } catch (error) { + console.error("Error updating template:", error); + alert("Failed to update template"); + } + }; -function EditJobeModel() { return ( - + setIsOpen(open)}> - + + + setJobType(e.target.value)} /> - - + setIsOpen(false)} /> ); diff --git a/src/Pages/MasterModule/JobType/JobAddModel.tsx b/src/Pages/MasterModule/JobType/JobAddModel.tsx index 27eb7a2..4f22c51 100644 --- a/src/Pages/MasterModule/JobType/JobAddModel.tsx +++ b/src/Pages/MasterModule/JobType/JobAddModel.tsx @@ -2,31 +2,65 @@ import { DialogBody, DialogCloseTrigger, DialogContent, DialogFooter, DialogHead import { Field, Input, Stack, Text } from "@chakra-ui/react" import { IoMdAdd } from "react-icons/io" import { Button } from "../../../components/ui/button" +import { useState } from "react"; +import { useCreateJobTypePostMutation } from "../../../Redux/Service/job.type.service"; +import { toaster } from "../../../components/ui/toaster"; + +function JobAddModel({ refetch }: { refetch: VoidFunction }) { + const [jobType, setJobType] = useState(""); + const [isOpen, setIsOpen] = useState(false); + const [createJobTypePost] = useCreateJobTypePostMutation() + + const handleOpenModal = () => { + setIsOpen(true); // Open modal when clicking "Add" + }; + + const handleSubmit = async () => { + if (!jobType.trim()) { + toaster.create({ + title: "Error", + description: "Title and Subtitle cannot be empty.", + type: "error", + }); + return; + } + + const payload = { + en_name: jobType, + }; + + try { + await createJobTypePost(payload); + refetch() + setIsOpen(false); + } catch (error) { + console.error("Error updating template:", error); + alert("Failed to update template"); + } + }; -function JobAddModel() { - return ( - + {/* */} - Add @@ -37,18 +71,28 @@ function JobAddModel() { Job Type - + setJobType(e.target.value)} + /> - - + setIsOpen(false)} /> diff --git a/src/Pages/MasterModule/JobType/JobType.tsx b/src/Pages/MasterModule/JobType/JobType.tsx index 01f7965..81ffb2f 100644 --- a/src/Pages/MasterModule/JobType/JobType.tsx +++ b/src/Pages/MasterModule/JobType/JobType.tsx @@ -6,6 +6,8 @@ import DataTable from "../../../components/DataTable"; import { Switch } from "../../../components/ui/switch"; import JobAddModel from "./JobAddModel"; import EditJobeModel from "./EditJobModel"; +import { JobTypeData, useGetJobTypeQuery } from "../../../Redux/Service/job.type.service"; +import { useEffect, useState } from "react"; @@ -15,25 +17,79 @@ const tableHeadRow = [ "Sr. No", "Title", "Action" - + ]; -const managepost: any[] = [ - ...Array.from({ length: 12 }, (_, i) => ({ - "Sr. No": i + 1, - "Title": "Lorem Ipsum", +// const managepost: any[] = [ +// ...Array.from({ length: 12 }, (_, i) => ({ +// "Sr. No": i + 1, +// "Title": "Lorem Ipsum", +// "Action": ( +// +// +// +// +// +// +// ), +// })), +// ]; + +const JobType = () => { + const { data, refetch } = useGetJobTypeQuery() + const [localData, setLocalData] = useState([]); + // const [templateMasterToggle] = useTemplateMasterToggleMutation() + console.log('DATA', data?.data.data); + + + useEffect(() => { + if (data?.data?.data) { + setLocalData(data?.data.data); + } + }, [data]); + + // const handleToggle = async (agencyId: string, currentStatus: number) => { + // const newStatus = currentStatus ? 0 : 1; + // setLocalData((prevData) => + // prevData.map((agency) => + // agency.id === agencyId ? { ...agency, is_active: newStatus } : agency + // ) + // ); + // try { + // await templateMasterToggle({ id: agencyId, is_active: newStatus }).unwrap(); + // refetch() + // } catch (error) { + // console.error("Error updating privacy policy:", error); + // setLocalData((prevData) => + // prevData.map((agency) => + // agency.id === agencyId ? { ...agency, is_active: currentStatus } : agency + // ) + // ); + // } + // }; + + + const managepost = localData?.map((agency: JobTypeData, index: number) => ({ + 'id': agency.id, + "Sr. No": index + 1, + "Title": agency.en_name, + "Action": ( - + - + handleToggle(agency.id, Number(agency.is_active))} + checked={Boolean(Number(agency.is_active))} + /> ), - })), -]; + })); + -const JobType = () => { return ( @@ -46,11 +102,11 @@ const JobType = () => { px={3} > - Job Type + Job Type - } @@ -71,15 +127,17 @@ const JobType = () => { /> {/* */} - + - + ) } diff --git a/src/Pages/MasterModule/TemplateMaster/EditTemplateModel.tsx b/src/Pages/MasterModule/TemplateMaster/EditTemplateModel.tsx index b84cea0..85cccd8 100644 --- a/src/Pages/MasterModule/TemplateMaster/EditTemplateModel.tsx +++ b/src/Pages/MasterModule/TemplateMaster/EditTemplateModel.tsx @@ -19,31 +19,38 @@ import { useState } from "react"; // import { FaRegEdit } from "react-icons/fa"; import Edit from "../../../components/ActionIcons/Edit"; import { Toaster, toaster } from "../../../components/ui/toaster"; -import { Template, useUpdateTemplateMasterMutation } from "../../../Redux/Service/template.master.service"; +import { Template } from "../../../Redux/Service/template.master.service"; +import axios from "axios"; -const APIURL = import.meta.env.VITE_IMG_TEMPLATES +// const IMGURL = import.meta.env.VITE_IMG_TEMPLATES +const APIURL = import.meta.env.VITE_API_URL -function EditTemplateModel({ id, localData }: { id: any, localData: any }) { +function EditTemplateModel({ id, localData, refetch }: { id: number, localData: any, refetch:VoidFunction }) { const [title, setTitle] = useState(""); const [subTitle, setSubTitle] = useState(""); const [userType, setUserType] = useState(""); const [images, setImages] = useState<(File | string)[]>([]); - const [updateTemplateMaster] = useUpdateTemplateMasterMutation() + // const [objectURLs, setObjectURLs] = useState([]); // Store object URLs separately + // const [updateTemplateMaster] = useUpdateTemplateMasterMutation() const [isOpen, setIsOpen] = useState(false); const [selectedTemplate, setSelectedTemplate] = useState