From 2ef90b8f8d7a7a3b1551cef46e6d0e782074c497 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 = [ -- 2.43.0 From 2b4bb4c750f17ca254b6e39a1317bfaea0ec1476 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 -- 2.43.0 From 398c149276608f2d7c11dfbc8435767bc93a2991 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" && ( + + )}
-- 2.43.0 From 1f8f3f0cc9aa38fe549088ac35700134f05ea314 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 -- 2.43.0