From 93977ba5b6c7da19f4d32dbc164180b9739079c6 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 10:10:47 +0530 Subject: [PATCH 01/18] =?UTF-8?q?Fixed=20case=20mismatch=20in=20error=20re?= =?UTF-8?q?ndering=20(BucketIds=20=E2=9E=9D=20bucketIds)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Directory/DirectorySchema.js | 4 +- src/components/Directory/ManageBucket.jsx | 43 ++++++++++++++------- src/components/Directory/UpdateContact.jsx | 16 ++++---- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/components/Directory/DirectorySchema.js b/src/components/Directory/DirectorySchema.js index 915cf10a..a8d2d489 100644 --- a/src/components/Directory/DirectorySchema.js +++ b/src/components/Directory/DirectorySchema.js @@ -6,7 +6,7 @@ export const ContactSchema = z contactCategoryId: z.string().nullable().optional(), address: z.string().optional(), description: z.string().min(1, { message: "Description is required" }), - projectIds: z.array(z.string()), // min(1, "Project is required") + projectIds: z.array(z.string()).nullable().optional(), // min(1, "Project is required") contactEmails: z .array( z.object({ @@ -39,7 +39,7 @@ export const ContactSchema = z }) ) .min(1, { message: "At least one tag is required" }), - bucketIds: z.array(z.string()).min(1,{message:"At least one Label required"}), +bucketIds: z.array(z.string()).nonempty({ message: "At least one label is required" }) }) // .refine((data) => { diff --git a/src/components/Directory/ManageBucket.jsx b/src/components/Directory/ManageBucket.jsx index 991d0340..86ba6dfe 100644 --- a/src/components/Directory/ManageBucket.jsx +++ b/src/components/Directory/ManageBucket.jsx @@ -12,8 +12,13 @@ import EmployeeList from "./EmployeeList"; import { useAllEmployees, useEmployees } from "../../hooks/useEmployees"; import { useSortableData } from "../../hooks/useSortableData"; import ConfirmModal from "../common/ConfirmModal"; +import {useHasUserPermission} from "../../hooks/useHasUserPermission"; +import {DIRECTORY_ADMIN, DIRECTORY_MANAGER} from "../../utils/constants"; +import {useProfile} from "../../hooks/useProfile"; -const ManageBucket = () => { +const ManageBucket = () => +{ + const {profile} =useProfile() const [bucketList, setBucketList] = useState([]); const { employeesList } = useAllEmployees(false); const [selectedEmployee, setSelectEmployee] = useState([]); @@ -22,7 +27,9 @@ const ManageBucket = () => { const [isSubmitting, setSubmitting] = useState(false); const [selected_bucket, select_bucket] = useState(null); const [deleteBucket, setDeleteBucket] = useState(null); - const [searchTerm, setSearchTerm] = useState(""); + const [ searchTerm, setSearchTerm ] = useState( "" ); + const DirManager = useHasUserPermission( DIRECTORY_MANAGER ) + const DirAdmin = useHasUserPermission(DIRECTORY_ADMIN) const { items: sortedBuckteList, requestSort, @@ -336,19 +343,25 @@ const ManageBucket = () => { {bucket.numberOfContacts} -
- { - select_bucket(bucket); - setAction_bucket(true); + + {(DirManager || + DirAdmin || + bucket?.createdBy?.id === + profile?.employeeInfo?.id) && ( +
+ { + select_bucket(bucket); + setAction_bucket(true); }} - > - setDeleteBucket(bucket?.id)} - > -
+ >
+ setDeleteBucket(bucket?.id)} + > +
+ )} ))} @@ -386,7 +399,7 @@ const ManageBucket = () => { setSelectEmployee(data)} - assignedEmployee={selected_bucket?.employeeIds} + bucket={selected_bucket} /> )} diff --git a/src/components/Directory/UpdateContact.jsx b/src/components/Directory/UpdateContact.jsx index 3878dc47..985229a3 100644 --- a/src/components/Directory/UpdateContact.jsx +++ b/src/components/Directory/UpdateContact.jsx @@ -387,13 +387,10 @@ await submitContact({ ...cleaned, id: existingContact.id }); )}
-
+
-
    +
      {bucketsLoaging &&

      Loading...

      } {buckets?.map((item) => (
    • ))} + {errors.bucketIds && ( + + {errors.bucketIds.message} + + )}
    - - {errors.BucketIds && ( - {errors.BucketIds.message} - )}
-- 2.43.0 From ecebef71c129642ab5e98b582fe72c285aa5ce55 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 10:12:14 +0530 Subject: [PATCH 02/18] added margin btwn bucket name in filter dropdwon --- src/pages/Directory/DirectoryPageHeader.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Directory/DirectoryPageHeader.jsx b/src/pages/Directory/DirectoryPageHeader.jsx index fcf603f4..728e387c 100644 --- a/src/pages/Directory/DirectoryPageHeader.jsx +++ b/src/pages/Directory/DirectoryPageHeader.jsx @@ -99,7 +99,7 @@ const DirectoryPageHeader = ({
{filteredBuckets.map(({ id, name }) => (
@@ -127,7 +127,7 @@ const DirectoryPageHeader = ({
{filteredCategories.map(({ id, name }) => (
-- 2.43.0 From 766f5d31bfc20723e09aaa4ff2670b4f785aac24 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 10:12:56 +0530 Subject: [PATCH 03/18] corrected state name, mismatched --- src/hooks/useDirectory.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useDirectory.js b/src/hooks/useDirectory.js index df352b98..0854d543 100644 --- a/src/hooks/useDirectory.js +++ b/src/hooks/useDirectory.js @@ -72,7 +72,7 @@ export const useBuckets = () => { }; export const useContactProfile = (id) => { - const [conatProfile, setContactProfile] = useState(null); + const [contactProfile, setContactProfile] = useState(null); const [loading, setLoading] = useState(false); const [Error, setError] = useState(""); @@ -105,7 +105,7 @@ export const useContactProfile = (id) => { } }, [id]); - return { conatProfile, loading, Error }; + return { contactProfile, loading, Error }; }; export const useContactNotes = (id, IsActive) => { -- 2.43.0 From e94e41a9527106a4389f9fdb47417836ab3b3dbc Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 17:20:27 +0530 Subject: [PATCH 04/18] changed font size --- src/components/Layout/Footer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Layout/Footer.tsx b/src/components/Layout/Footer.tsx index d1d7f0a1..8808d39f 100644 --- a/src/components/Layout/Footer.tsx +++ b/src/components/Layout/Footer.tsx @@ -3,7 +3,7 @@ const Footer = () => { <>
-
+
© {new Date().getFullYear()} , by MARCO AIoT Technologies Pvt. Ltd.
-- 2.43.0 From a2e34b91dcfacc848941a8c3ebe9f6b749d0debe Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 17:21:07 +0530 Subject: [PATCH 05/18] changed navigation tab layout --- src/data/menuData.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/data/menuData.json b/src/data/menuData.json index 0870d187..f0b6b12f 100644 --- a/src/data/menuData.json +++ b/src/data/menuData.json @@ -23,11 +23,6 @@ "text": "Employees", "available": true, "link": "/employees" - }, - { - "text": "Directory", - "available": true, - "link": "/directory" } ] }, @@ -68,6 +63,12 @@ "link": "/activities/gallary" } ] + }, + { + "text": "Directory", + "icon": "bx bx-folder", + "available": true, + "link": "/directory" }, { "text": "Administration", -- 2.43.0 From b9f24e9954b9dd11cbb6751eb831c63c1bab7a0d Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 17:24:58 +0530 Subject: [PATCH 06/18] changed delete contact Url --- src/repositories/DirectoryRepository.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/repositories/DirectoryRepository.jsx b/src/repositories/DirectoryRepository.jsx index c123cf82..ac9fa617 100644 --- a/src/repositories/DirectoryRepository.jsx +++ b/src/repositories/DirectoryRepository.jsx @@ -6,7 +6,7 @@ export const DirectoryRepository = { GetContacts: (isActive) => api.get( `/api/directory?active=${isActive}` ), CreateContact: ( data ) => api.post( '/api/directory', data ), UpdateContact: ( id, data ) => api.put( `/api/directory/${ id }`, data ), - DeleteContact: ( id ) => api.delete( `/api/directory/${ id }` ), + DeleteContact: ( id,isActive) => api.delete( `/api/directory/${ id }/?active=${isActive}` ), AssignedBuckets:(id,data)=>api.post(`/api/directory/assign-bucket/${id}`,data), GetBucktes: () => api.get( `/api/directory/buckets` ), @@ -19,5 +19,5 @@ export const DirectoryRepository = { CreateNote: ( data ) => api.post( '/api/directory/note', data ), GetNote: ( id,isActive ) => api.get( `/api/directory/notes/${ id }?active=${isActive}` ), UpdateNote: ( id, data ) => api.put( `/api/directory/note/${ id }`, data ), - DeleteNote:(id)=> api.delete(`/api/directory/note/${ id }`) + DeleteNote:(id,isActive)=> api.delete(`/api/directory/note/${ id }?active=${isActive}`) } \ No newline at end of file -- 2.43.0 From 5a59e791607f6bfa5e946e68bbd559692c6bc1d3 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 17:26:07 +0530 Subject: [PATCH 07/18] changed useDirectory hook calling format --- src/hooks/useDirectory.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/hooks/useDirectory.js b/src/hooks/useDirectory.js index 0854d543..7ec08c4b 100644 --- a/src/hooks/useDirectory.js +++ b/src/hooks/useDirectory.js @@ -77,9 +77,7 @@ export const useContactProfile = (id) => { const [Error, setError] = useState(""); const fetchContactProfile = async () => { - const cached = getCachedData("Contact Profile"); - if (!cached || cached.contactId !== id) { setLoading(true); try { const resp = await DirectoryRepository.GetContactProfile(id); @@ -94,18 +92,20 @@ export const useContactProfile = (id) => { } finally { setLoading(false); } + + }; + + useEffect( () => + { + const cached = getCachedData("Contact Profile"); + if (!cached || cached.contactId !== id) { + fetchContactProfile(id); } else { setContactProfile(cached.data); } - }; - - useEffect(() => { - if (id) { - fetchContactProfile(id); - } }, [id]); - return { contactProfile, loading, Error }; + return { contactProfile, loading, Error ,refetch:fetchContactProfile}; }; export const useContactNotes = (id, IsActive) => { @@ -113,10 +113,9 @@ export const useContactNotes = (id, IsActive) => { const [loading, setLoading] = useState(false); const [Error, setError] = useState(""); - const fetchContactNotes = async () => { - const cached = getCachedData("Contact Notes"); + const fetchContactNotes = async (id,IsActive) => { + - if (!cached || cached.contactId !== id) { setLoading(true); try { const resp = await DirectoryRepository.GetNote(id, IsActive); @@ -131,18 +130,19 @@ export const useContactNotes = (id, IsActive) => { } finally { setLoading(false); } - } else { - setContactNotes(cached.data); - } + }; useEffect(() => { - if (id) { - fetchContactNotes(id); + const cached = getCachedData("Contact Notes"); + if (!cached || cached.contactId !== id) { + fetchContactNotes(id,IsActive); + } else { + setContactNotes(cached.data); } - }, [id]); + }, [id,IsActive]); - return { contactNotes, loading, Error }; + return { contactNotes, loading, Error,refetch:fetchContactNotes }; }; export const useOrganization = () => { -- 2.43.0 From 2b65f92f5436edb1a544d1acec5e213fdaba8a78 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 19:55:36 +0530 Subject: [PATCH 08/18] Support tag creation on spacebar key --- src/components/common/TagInput.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/common/TagInput.jsx b/src/components/common/TagInput.jsx index c40a278f..6430197e 100644 --- a/src/components/common/TagInput.jsx +++ b/src/components/common/TagInput.jsx @@ -60,7 +60,7 @@ useEffect(() => { }; const handleInputKeyDown = (e) => { - if (e.key === "Enter" && input.trim() !== "") { + if ((e.key === "Enter" || e.key === " ")&& input.trim() !== "") { e.preventDefault(); const existing = options.find( (opt) => opt.name.toLowerCase() === input.trim().toLowerCase() -- 2.43.0 From 0069b48ca8cdc702cef044daabad9b7b551de633 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 19:56:18 +0530 Subject: [PATCH 09/18] added wrapped DirProver for context --- src/App.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 8ad23207..5499dba1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,3 +1,4 @@ +import { DireProvider } from "./Context/DireContext"; import AppRoutes from "./router/AppRoutes"; import { ToastContainer } from "react-toastify"; @@ -5,8 +6,13 @@ import { ToastContainer } from "react-toastify"; const App = () => { return (
- - + + + + + + +
); -- 2.43.0 From f9d94d1b186d80efd4e231806ea5746af5a6aacc Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 19:57:24 +0530 Subject: [PATCH 10/18] fixed console warning --- src/components/common/TextEditor/Editor.jsx | 44 +++++++++++---------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/components/common/TextEditor/Editor.jsx b/src/components/common/TextEditor/Editor.jsx index 84f9728f..dd6938f2 100644 --- a/src/components/common/TextEditor/Editor.jsx +++ b/src/components/common/TextEditor/Editor.jsx @@ -29,21 +29,22 @@ const Editor = ({ "code-block", "link", "align", - "image" + "image", ]; return (
-
+
{/* Left: Quill Format Buttons */} -
- {/* Right: Submit + Cancel Buttons */} -
- - Cancel - - - {loading ? "Please Wait..." : "Submit"} - -
- + {/* Right: Submit + Cancel Buttons */} +
+ + Cancel + + + {loading ? "Please Wait..." : "Submit"} + +
); }; -- 2.43.0 From 114aac089bb7580d0db2efa1320c05bcc8265be0 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 19:58:45 +0530 Subject: [PATCH 11/18] added restore feature for contacts --- src/Context/DireContext.jsx | 21 ++ .../Directory/CardViewDirectory.jsx | 130 ++++++------ .../Directory/ListViewDirectory.jsx | 186 +++++++++++------- src/pages/Directory/Directory.jsx | 80 +++++--- 4 files changed, 266 insertions(+), 151 deletions(-) create mode 100644 src/Context/DireContext.jsx diff --git a/src/Context/DireContext.jsx b/src/Context/DireContext.jsx new file mode 100644 index 00000000..a8e842e9 --- /dev/null +++ b/src/Context/DireContext.jsx @@ -0,0 +1,21 @@ +import React, { createContext, useContext, useState } from "react"; + +const DireContext = createContext(undefined); + +export const DireProvider = ({ children }) => { + const [dirActions, setDirActions] = useState([]); + + return ( + + {children} + + ); +}; + +export const useDir = () => { + const context = useContext(DireContext); + if (!context) { + throw new Error("useDir must be used within a "); + } + return context; +}; diff --git a/src/components/Directory/CardViewDirectory.jsx b/src/components/Directory/CardViewDirectory.jsx index 1dc16cec..33fcad6f 100644 --- a/src/components/Directory/CardViewDirectory.jsx +++ b/src/components/Directory/CardViewDirectory.jsx @@ -3,6 +3,7 @@ import Avatar from "../common/Avatar"; import { getBucketNameById } from "./DirectoryUtils"; import { useBuckets } from "../../hooks/useDirectory"; import { getPhoneIcon } from "./DirectoryUtils"; +import { useDir } from "../../Context/DireContext"; const CardViewDirectory = ({ IsActive, contact, @@ -11,8 +12,10 @@ const CardViewDirectory = ({ setOpen_contact, setIsOpenModalNote, IsDeleted, + restore, }) => { const { buckets } = useBuckets(); + const { dirActions, setDirActions } = useDir(); return (
{" "} - {contact.name} + {contact.name}
+ )} + {!IsActive && ( + { + setDirActions({ action: false, id: contact.id }); + restore(contact.id); + }} + > + )}
  • - +
  • {contact.organization} @@ -97,7 +116,7 @@ const CardViewDirectory = ({ {contact.contactEmails[0] && (
    • - +
    • {contact.contactEmails[0]?.emailAddress} @@ -122,27 +141,28 @@ const CardViewDirectory = ({
      • - - +
      • {contact.contactCategory.name}
      -
        - {contact.bucketIds?.map((bucketId) => ( -
      • - - - - {getBucketNameById(buckets, bucketId)} - - -
      • - ))} -
      - +
        + {contact.bucketIds?.map((bucketId) => ( +
      • + + + + {getBucketNameById(buckets, bucketId)} + + +
      • + ))} +
); diff --git a/src/components/Directory/ListViewDirectory.jsx b/src/components/Directory/ListViewDirectory.jsx index 20636c2e..d227d99d 100644 --- a/src/components/Directory/ListViewDirectory.jsx +++ b/src/components/Directory/ListViewDirectory.jsx @@ -1,74 +1,128 @@ -import React from 'react' -import Avatar from '../common/Avatar'; -import { getEmailIcon,getPhoneIcon } from './DirectoryUtils'; +import React, { useEffect } from "react"; +import Avatar from "../common/Avatar"; +import { getEmailIcon, getPhoneIcon } from "./DirectoryUtils"; +import { useDir } from "../../Context/DireContext"; +const ListViewDirectory = ({ + IsActive, + contact, + setSelectedContact, + setIsOpenModal, + setOpen_contact, + setIsOpenModalNote, + IsDeleted, + restore, +}) => { + const { dirActions, setDirActions } = useDir(); -const ListViewDirectory = ({IsActive, contact,setSelectedContact,setIsOpenModal,setOpen_contact,setIsOpenModalNote,IsDeleted}) => { return ( - - { - if (IsActive) { - setIsOpenModalNote(true); - setOpen_contact(contact); - } - }}> -
- - {contact?.name || ""} -
- - - -
- {contact.contactEmails?.map((email, index) => ( - - - {email.emailAddress} - - ))} -
- - - -
- {contact.contactPhones?.map((phone, index) => ( - - - {phone.phoneNumber} - - ))} -
- - - - {contact.organization} - - - - - {contact?.contactCategory?.name} - - - - {IsActive && ( - - + { - setSelectedContact(contact); - setIsOpenModal(true); - }}> - IsDeleted(contact.id)}> - - )} - + if (IsActive) { + setIsOpenModalNote(true); + setOpen_contact(contact); + } + }} + > +
+ + + {contact?.name || ""} + +
+ + +
+ {contact.contactEmails?.map((email, index) => ( + + + + {email.emailAddress} + + + ))} +
+ + + +
+ {contact.contactPhones?.map((phone, index) => ( + + + {phone.phoneNumber} + + ))} +
+ + + + {contact.organization} + + + + + {contact?.contactCategory?.name} + + + + + {IsActive && ( + <> + { + setSelectedContact(contact); + setIsOpenModal(true); + }} + > + IsDeleted(contact.id)} + > + + )} + {!IsActive && ( + { + setDirActions({ action: false, id: contact.id }); + restore(contact.id); + }} + > + )} + + ); }; -export default ListViewDirectory; \ No newline at end of file +export default ListViewDirectory; diff --git a/src/pages/Directory/Directory.jsx b/src/pages/Directory/Directory.jsx index b19eecf3..a9ceab49 100644 --- a/src/pages/Directory/Directory.jsx +++ b/src/pages/Directory/Directory.jsx @@ -19,6 +19,7 @@ import DirectoryListTableHeader from "./DirectoryListTableHeader"; import DirectoryPageHeader from "./DirectoryPageHeader"; import ManageBucket from "../../components/Directory/ManageBucket"; import {useFab} from "../../Context/FabContext"; +import {DireProvider, useDir} from "../../Context/DireContext"; const Directory = () => { @@ -33,12 +34,15 @@ const Directory = () => const [listView, setListView] = useState(false); const [selectedBucketIds, setSelectedBucketIds] = useState([]); const [deleteContact, setDeleteContact] = useState(null); - const [ IsDeleting, setIsDeletng ] = useState( false ); - const [openBucketModal,setOpenBucketModal] = useState(false) + const [ IsDeleting, setDeleting ] = useState( false ); + const [ openBucketModal, setOpenBucketModal ] = useState( false ) + const [tempSelectedBucketIds, setTempSelectedBucketIds] = useState([]); const [ tempSelectedCategoryIds, setTempSelectedCategoryIds ] = useState( [] ); - const {setActions} = useFab() + const {setActions} = useFab() + const { dirActions, setDirActions } = useDir(); + const { contacts, loading , refetch} = useDirectory(IsActive); const { contactCategory, loading: contactCategoryLoading } = @@ -78,28 +82,43 @@ const Directory = () => } }; - const handleDeleteContact = async () => { - try { - setIsDeletng(true); - const contacts_cache = getCachedData("contacts")?.data || []; - - const response = await DirectoryRepository.DeleteContact(deleteContact); - const updatedContacts = ContactList.filter( ( c ) => c.id !== deleteContact ); - setContactList(updatedContacts); - cacheData("Contacts", {data:updatedContacts,isActive:IsActive}); - showToast("Contact deleted successfully", "success"); - setDeleteContact(null); - - setIsDeletng(false); - } catch (error) { - const msg = - error.response.data.message || - error.message || - "Error occured during API calling"; - showToast(msg, "error"); - setIsDeletng(false); +const handleDeleteContact = async (overrideId = null) => { + try + { + if (!IsActive) { + setDirActions((prev) => ({ ...prev, action: true })); + } else { + setDeleting(true); } - }; + const id = overrideId || (!IsActive ? dirActions.id : deleteContact); + if (!id) { + showToast("No contact selected for deletion", "error"); + return; + } + + await DirectoryRepository.DeleteContact(id, !IsActive); + + const updatedContacts = ContactList.filter((c) => c.id !== id); + setContactList(updatedContacts); + cacheData("Contacts", { data: updatedContacts, isActive: IsActive }); + + showToast(`Contact ${IsActive ? "Deleted":"Restored"} successfully`, "success"); + + setDeleteContact(null); + setDirActions({ action: false, id: null }); + setDeleting(false); + } catch (error) { + const msg = + error?.response?.data?.message || + error.message || + "Error occurred during API call"; + showToast(msg, "error"); + + setDeleting(false); + setDirActions({ action: false, id: null }); + } +}; + const closedModel = () => { setIsOpenModal(false); @@ -306,7 +325,6 @@ const Directory = () => applyFilter={applyFilter} loading={loading} IsActive={IsActive} - setIsOpenModal={setIsOpenModal} setOpenBucketModal={setOpenBucketModal} /> {!listView && loading &&

Loading...

} @@ -314,7 +332,7 @@ const Directory = () =>

No Matching Contact Found

)} {listView ? ( - + {loading && ( Loading... @@ -336,6 +354,7 @@ const Directory = () => setOpen_contact={setOpen_contact} setIsOpenModalNote={setIsOpenModalNote} IsDeleted={setDeleteContact} + restore={handleDeleteContact} /> ))} @@ -354,15 +373,16 @@ const Directory = () => setOpen_contact={setOpen_contact} setIsOpenModalNote={setIsOpenModalNote} IsDeleted={setDeleteContact} + restore={handleDeleteContact} />
))}
)} -
-
+ + - {!loading && currentItems < ITEMS_PER_PAGE && ( + {!loading && currentItems < ITEMS_PER_PAGE && ( )}
-
+ ); }; -- 2.43.0 From 3ed2048e45885a755625db5e7b49cfe49b4aac42 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 19:59:24 +0530 Subject: [PATCH 12/18] changed table column email to role --- src/components/Directory/EmployeeList.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Directory/EmployeeList.jsx b/src/components/Directory/EmployeeList.jsx index 1374ba38..24f0218f 100644 --- a/src/components/Directory/EmployeeList.jsx +++ b/src/components/Directory/EmployeeList.jsx @@ -96,7 +96,7 @@ const EmployeeList = ({ employees, onChange, bucket }) => { > Name {getSortIcon()} - Email + Role @@ -143,7 +143,7 @@ const EmployeeList = ({ employees, onChange, bucket }) => { - {employee.email} + {employee.jobRole} )) -- 2.43.0 From 054c129ba58e914a1bf20ca2d8c83ee6293f14cd Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 20:01:42 +0530 Subject: [PATCH 13/18] removed new contact button form header --- src/pages/Directory/DirectoryPageHeader.jsx | 48 ++------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/src/pages/Directory/DirectoryPageHeader.jsx b/src/pages/Directory/DirectoryPageHeader.jsx index 728e387c..fb782c3f 100644 --- a/src/pages/Directory/DirectoryPageHeader.jsx +++ b/src/pages/Directory/DirectoryPageHeader.jsx @@ -16,7 +16,6 @@ const DirectoryPageHeader = ({ applyFilter, loading, IsActive, - setIsOpenModal, setOpenBucketModal, }) => { const [filtered, setFiltered] = useState(); @@ -169,38 +168,10 @@ const DirectoryPageHeader = ({
- - -
-- 2.43.0 From 069d12ecd6c78e613ac729daa085954bd5da3015 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Thu, 29 May 2025 20:05:43 +0530 Subject: [PATCH 14/18] aded validation for tags and rename label to bucket --- src/components/Directory/ManageDirectory.jsx | 125 +++++++++---------- 1 file changed, 60 insertions(+), 65 deletions(-) diff --git a/src/components/Directory/ManageDirectory.jsx b/src/components/Directory/ManageDirectory.jsx index 003b7696..9f4d33fa 100644 --- a/src/components/Directory/ManageDirectory.jsx +++ b/src/components/Directory/ManageDirectory.jsx @@ -17,24 +17,22 @@ import { changeMaster } from "../../slices/localVariablesSlice"; import { useBuckets, useOrganization } from "../../hooks/useDirectory"; import { useProjects } from "../../hooks/useProjects"; import SelectMultiple from "../common/SelectMultiple"; -import {ContactSchema} from "./DirectorySchema"; +import { ContactSchema } from "./DirectorySchema"; import InputSuggestions from "../common/InputSuggestion"; - - const ManageDirectory = ({ submitContact, onCLosed }) => { const selectedMaster = useSelector( (store) => store.localVariables.selectedMaster ); - const [ categoryData, setCategoryData ] = useState( [] ); - + const [categoryData, setCategoryData] = useState([]); + const [TagsData, setTagsData] = useState([]); const { data, loading } = useMaster(); const { buckets, loading: bucketsLoaging } = useBuckets(); const { projects, loading: projectLoading } = useProjects(); const { contactCategory, loading: contactCategoryLoading } = useContactCategory(); - const {organizationList,loading:orgLoading} = useOrganization() + const { organizationList, loading: orgLoading } = useOrganization(); const { contactTags, loading: Tagloading } = useContactTags(); const [IsSubmitting, setSubmitting] = useState(false); const dispatch = useDispatch(); @@ -79,15 +77,14 @@ const ManageDirectory = ({ submitContact, onCLosed }) => { remove: removePhone, } = useFieldArray({ control, name: "contactPhones" }); -useEffect(() => { - if (emailFields.length === 0) { - appendEmail({ label: "Work", emailAddress: "" }); - } - if (phoneFields.length === 0) { - appendPhone({ label: "Office", phoneNumber: "" }); - } -}, [emailFields.length, phoneFields.length]); - + useEffect(() => { + if (emailFields.length === 0) { + appendEmail({ label: "Work", emailAddress: "" }); + } + if (phoneFields.length === 0) { + appendPhone({ label: "Office", phoneNumber: "" }); + } + }, [emailFields.length, phoneFields.length]); const handleAddEmail = async () => { const emails = getValues("contactEmails"); @@ -124,22 +121,21 @@ useEffect(() => { setValue("bucketIds", updated, { shouldValidate: true }); }; - const onSubmit = ( data ) => - { - const cleaned = { - ...data, - contactEmails: (data.contactEmails || []).filter( - (e) => e.emailAddress?.trim() !== "" - ), - contactPhones: (data.contactPhones || []).filter( - (p) => p.phoneNumber?.trim() !== "" - ), - }; + const onSubmit = (data) => { + const cleaned = { + ...data, + contactEmails: (data.contactEmails || []).filter( + (e) => e.emailAddress?.trim() !== "" + ), + contactPhones: (data.contactPhones || []).filter( + (p) => p.phoneNumber?.trim() !== "" + ), + }; setSubmitting(true); submitContact(cleaned, reset, setSubmitting); }; - const orgValue = watch("organization") + const orgValue = watch("organization"); const handleClosed = () => { onCLosed(); @@ -165,16 +161,11 @@ useEffect(() => {
setValue("organization", val)} - error={errors.organization?.message} - /> - {errors.organization && ( - - {errors.organization.message} - - )} + organizationList={organizationList} + value={getValues("organization") || ""} + onChange={(val) => setValue("organization", val)} + error={errors.organization?.message} + />
@@ -216,7 +207,10 @@ useEffect(() => { // onClick={handleAddEmail} // style={{ width: "24px", height: "24px" }} // > - + ) : ( //
{errors.contactEmails?.[index]?.emailAddress && ( @@ -275,8 +271,10 @@ useEffect(() => { // onClick={handleAddPhone} // style={{ width: "24px", height: "24px" }} // > - - + ) : ( //