diff --git a/src/components/Directory/CardViewDirectory.jsx b/src/components/Directory/CardViewDirectory.jsx index 5cfe3af8..9be8663a 100644 --- a/src/components/Directory/CardViewDirectory.jsx +++ b/src/components/Directory/CardViewDirectory.jsx @@ -16,6 +16,7 @@ const CardViewDirectory = ({ }) => { const { buckets } = useBuckets(); const { dirActions, setDirActions } = useDir(); + return (
{ if (IsActive) { setIsOpenModalNote(true); @@ -89,11 +89,10 @@ const CardViewDirectory = ({ )} {!IsActive && ( { setDirActions({ action: false, id: contact.id }); @@ -114,9 +113,8 @@ const CardViewDirectory = ({
{ if (IsActive) { setIsOpenModalNote(true); @@ -151,17 +149,19 @@ const CardViewDirectory = ({ )} - {contact?.contactCategory?.name ? ( -
    + {contact?.tags?.length > 0 ? ( +
    • -
    • - {contact?.contactCategory?.name} -
    • + {contact.tags.map((tag, index) => ( +
    • + {tag.name} +
    • + ))}
    ) : ( -
      +
      • diff --git a/src/components/Directory/ManageBucket.jsx b/src/components/Directory/ManageBucket.jsx index bf48d8fe..b34c6ede 100644 --- a/src/components/Directory/ManageBucket.jsx +++ b/src/components/Directory/ManageBucket.jsx @@ -66,7 +66,6 @@ const ManageBucket = () => { const cache_buckets = getCachedData("buckets") || []; let response; - // Utility: Compare arrays regardless of order const arraysAreEqual = (a, b) => { if (a.length !== b.length) return false; const setA = new Set(a); @@ -74,11 +73,9 @@ const ManageBucket = () => { return [...setA].every((id) => setB.has(id)); }; - // UPDATE existing bucket if (selected_bucket) { const payload = { ...data, id: selected_bucket.id }; - // 1. Update bucket details response = await DirectoryRepository.UpdateBuckets( selected_bucket.id, payload @@ -91,14 +88,12 @@ const ManageBucket = () => { cacheData("buckets", updatedBuckets); setBucketList(updatedBuckets); - // 2. Update employee assignments if they changed const existingEmployeeIds = selected_bucket?.employeeIds || []; const employeesToUpdate = selectedEmployee.filter((emp) => { const isExisting = existingEmployeeIds.includes(emp.employeeId); return (!isExisting && emp.isActive) || (isExisting && !emp.isActive); }); - // Create a filtered list of active employee IDs to compare const newActiveEmployeeIds = selectedEmployee .filter((emp) => { const isExisting = existingEmployeeIds.includes(emp.employeeId); @@ -110,7 +105,7 @@ const ManageBucket = () => { if ( !arraysAreEqual(newActiveEmployeeIds, existingEmployeeIds) && - employeesToUpdate.length != 0 + employeesToUpdate.length !== 0 ) { try { response = await DirectoryRepository.AssignedBuckets( @@ -135,7 +130,6 @@ const ManageBucket = () => { showToast("Bucket Updated Successfully", "success"); } - // CREATE new bucket else { response = await DirectoryRepository.CreateBuckets(data); @@ -163,7 +157,7 @@ const ManageBucket = () => { const resp = await DirectoryRepository.DeleteBucket(deleteBucket); const cache_buckets = getCachedData("buckets") || []; const updatedBuckets = cache_buckets.filter( - (bucket) => bucket.id != deleteBucket + (bucket) => bucket.id !== deleteBucket ); cacheData("buckets", updatedBuckets); setBucketList(updatedBuckets); @@ -193,6 +187,8 @@ const ManageBucket = () => { select_bucket(null); setAction_bucket(false); setSubmitting(false); + reset({ name: "", description: "" }); + setSelectEmployee([]); }; const sortedBucktesList = sortedBuckteList?.filter((bucket) => { @@ -200,11 +196,12 @@ const ManageBucket = () => { const name = bucket.name?.toLowerCase(); return name?.includes(term); }); + return ( <> {deleteBucket && (
        { setDeleteBucket(null)} - // loading={IsDeleting} />
        )} -
        +

        Manage Buckets

        @@ -254,10 +250,15 @@ const ManageBucket = () => {
        {!action_bucket ? ( -
        - - - - - - - - - - - - {loading && ( - - - - )} - {!loading && buckets.length == 0 && ( - - - - )} - {!loading && sortedBucktesList.length == 0 && ( - - - - )} - {!loading && - sortedBucktesList.map((bucket) => ( - - - - - - - ))} - -
        requestSort((e) => `${e.name} `)} - > -
        - Name {getSortIcon()} -
        -
        -
        - Description -
        -
        Contacts -
        - Action -
        -
        - {" "} -
        - Loading... -
        -
        -
        - Bucket Not Available. -
        -
        -
        - No Matching Bucket Found. -
        -
        - {" "} - {bucket.name} - - {bucket.description} - {bucket.numberOfContacts} - {(DirManager || - DirAdmin || - bucket?.createdBy?.id === - profile?.employeeInfo?.id) && ( -
        +
        + {loading && ( +
        +
        + Loading... +
        +
        + )} + {!loading && buckets.length === 0 && ( +
        +
        + No Buckets Available. +
        +
        + )} + {!loading && sortedBucktesList.length === 0 && ( +
        +
        + No Matching Bucket Found. +
        +
        + )} + {!loading && + sortedBucktesList.map((bucket) => ( +
        +
        +
        +
        + {bucket.name} + {(DirManager || DirAdmin || bucket?.createdBy?.id === profile?.employeeInfo?.id) && ( +
        { select_bucket(bucket); setAction_bucket(true); + const initialSelectedEmployees = employeesList + .filter(emp => bucket.employeeIds?.includes(emp.employeeId)) + .map(emp => ({ ...emp, isActive: true })); + setSelectEmployee(initialSelectedEmployees); }} > setDeleteBucket(bucket?.id)} >
        )} -
        + +
        + Contacts: {bucket.numberOfContacts} +
        +

        + {bucket.description || "No description available."} +

        +
        +
        +
        + ))}
) : ( <>
-
- +
+ @@ -379,9 +340,10 @@ const ManageBucket = () => { {errors.name.message} )}
-
- +
+