From 784eebafea3831ffaced7473f252807528a3edff Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 15 May 2025 15:04:58 +0530 Subject: [PATCH 1/4] added one more master in masterList - Contact Category --- src/data/masters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/masters.js b/src/data/masters.js index 0f302184..e64972b4 100644 --- a/src/data/masters.js +++ b/src/data/masters.js @@ -1,5 +1,5 @@ // it important ------ -export const mastersList = [ {id: 1, name: "Application Role"}, {id: 2, name: "Job Role"}, {id: 3, name: "Activity"},{id: 4, name:"Work Category"} ] +export const mastersList = [ {id: 1, name: "Application Role"}, {id: 2, name: "Job Role"}, {id: 3, name: "Activity"},{id: 4, name:"Work Category"},{id:5,name:"Contact Category"}] // ------------------- export const dailyTask = [ From 74ed8d3c4fc250a761b3c5b8ad05e55427e3c57f Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 15 May 2025 15:07:37 +0530 Subject: [PATCH 2/4] created new constact category master --- .../master/CreateContactCategory.jsx | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/components/master/CreateContactCategory.jsx diff --git a/src/components/master/CreateContactCategory.jsx b/src/components/master/CreateContactCategory.jsx new file mode 100644 index 00000000..5bce4171 --- /dev/null +++ b/src/components/master/CreateContactCategory.jsx @@ -0,0 +1,113 @@ +import React, { useEffect,useState } from 'react' +import { useForm } from 'react-hook-form'; +import { z } from 'zod'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { MasterRespository } from '../../repositories/MastersRepository'; +import { clearApiCacheKey } from '../../slices/apiCacheSlice'; +import { getCachedData,cacheData } from '../../slices/apiDataManager'; +import showToast from '../../services/toastService'; + + +const schema = z.object({ + name: z.string().min(1, { message: "Category name is required" }), + description: z.string().min(1, { message: "Description is required" }) + .max(255, { message: "Description cannot exceed 255 characters" }), +}); + +const CreateContactCategory = ({onClose}) => { + + const[isLoading,setIsLoading] = useState(false) + const { + register, + handleSubmit, + formState: { errors },reset + + } = useForm({ + resolver: zodResolver(schema), + defaultValues: { + name: "", + description: "", + + }, + }); + + const onSubmit = (data) => { + setIsLoading(true) + MasterRespository.createContactCategory(data).then((resp)=>{ + setIsLoading(false) + resetForm() + const cachedData = getCachedData("Contact Category"); + const updatedData = [...cachedData, resp?.data]; + cacheData("Contact Category", updatedData); + showToast("Contact Category Added successfully.", "success"); + + onClose() + }).catch((error)=>{ + showToast(error?.response?.data?.message, "error"); + setIsLoading(false) + }) + }; + const resetForm = () => { + reset({ + name: "", + description: "" + }); + setDescriptionLength(0); + } + + useEffect(()=>{ + return ()=>resetForm() + },[]) + + const [descriptionLength, setDescriptionLength] = useState(0); + const maxDescriptionLength = 255; + return (<> +
+
+ + + {errors.name &&

{errors.name.message}

} +
+
+ + +
+ {maxDescriptionLength - descriptionLength} characters left +
+ {errors.description && ( +

{errors.description.message}

+ )} +
+ +
+ + +
+ +
+ + + ) +} + +export default CreateContactCategory; \ No newline at end of file From 40df12de8631410d67b12294f6e58bb17ba8ea38 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 15 May 2025 15:08:55 +0530 Subject: [PATCH 3/4] added CreateContactCategory in master modal --- src/components/master/MasterModal.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/master/MasterModal.jsx b/src/components/master/MasterModal.jsx index 056451a4..58ae4b16 100644 --- a/src/components/master/MasterModal.jsx +++ b/src/components/master/MasterModal.jsx @@ -13,6 +13,7 @@ import {cacheData, getCachedData} from "../../slices/apiDataManager"; import showToast from "../../services/toastService"; import CreateWorkCategory from "./CreateWorkCategory"; import EditWorkCategory from "./EditWorkCategory"; +import CreateCategory from "./CreateContactCategory"; const MasterModal = ({ modaldata, closeModal }) => { @@ -74,7 +75,6 @@ const MasterModal = ({ modaldata, closeModal }) => { ); } - return (
{ >
- +
{modaldata.modalType === "Application Role" && ( @@ -125,6 +128,9 @@ const MasterModal = ({ modaldata, closeModal }) => { {modaldata.modalType === "Edit-Work Category" && ( )} + {modaldata.modalType === "Contact Category" && ( + + )}
From cd21bc14ff9abf0134619e2927302fe7e3484b96 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 15 May 2025 15:09:57 +0530 Subject: [PATCH 4/4] created new repo for tag and contact category mastes --- src/repositories/MastersRepository.jsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/repositories/MastersRepository.jsx b/src/repositories/MastersRepository.jsx index ee91022d..33761336 100644 --- a/src/repositories/MastersRepository.jsx +++ b/src/repositories/MastersRepository.jsx @@ -40,10 +40,20 @@ export const MasterRespository = { "Job Role": ( id ) => api.delete( `/api/roles/jobrole/${ id }` ), "Activity": ( id ) => api.delete( `/api/master/activity/delete/${ id }` ), "Application Role":(id)=>api.delete(`/api/roles/${id}`), - "Work Category": (id) => api.delete(`api/master/work-category/${id}`), + "Work Category": ( id ) => api.delete( `api/master/work-category/${ id }` ), + "Contact Category": ( id ) => api.delete( `/api/master/contact-category` ), + "Conatct Tag" :(id)=>api.delete("/api/master/contact-tag"), getWorkCategory:() => api.get(`/api/master/work-categories`), createWorkCategory: (data) => api.post(`/api/master/work-category`,data), - updateWorkCategory: (id,data) => api.post(`/api/master/work-category/edit/${id}`,data), + updateWorkCategory: ( id, data ) => api.post( `/api/master/work-category/edit/${ id }`, data ), + + getContactCategory: () => api.get( `/api/master/contact-categories` ), + createContactCategory: (data ) => api.post( `/api/master/contact-category`, data ), + updateContactCategory: ( id, data ) => api.post( `/api/master/contact-category/${ id }`, data ), + + getContactTag: () => api.get( `/api/master/contact-tag` ), + createContactTag: (data ) => api.post( `/api/master/contact-tag`, data ), + updateContactTag: ( id, data ) => api.post( `/api/master/contact-tag/${ id }`, data ) } \ No newline at end of file