diff --git a/src/pages/Directory/Directory.jsx b/src/pages/Directory/Directory.jsx index 3b3f4671..05f465c9 100644 --- a/src/pages/Directory/Directory.jsx +++ b/src/pages/Directory/Directory.jsx @@ -39,6 +39,7 @@ const Directory = ({ IsPage = true, prefernceContacts }) => { const [openBucketModal, setOpenBucketModal] = useState(false); const [notes, setNotes] = useState([]); const [filterAppliedNotes, setFilterAppliedNotes] = useState([]); + const [filterAppliedNotes, setFilterAppliedNotes] = useState([]); // const [selectedOrgs, setSelectedOrgs] = useState([]); // ✅ Changed to an array for multiple selections @@ -354,6 +355,7 @@ const Directory = ({ IsPage = true, prefernceContacts }) => { contactsToExport={contacts} notesToExport={notes} selectedNoteNames={selectedNoteNames} + selectedNoteNames={selectedNoteNames} setSelectedNoteNames={setSelectedNoteNames} notesForFilter={notes} setFilterAppliedNotes={setFilterAppliedNotes} @@ -361,97 +363,75 @@ const Directory = ({ IsPage = true, prefernceContacts }) => {
- {/* LIST VIEW */} - {viewType === "list" && ( -
-
+ {/* Loader when switching between Active/Pending or filtering */} + {loading && ( +
+
+ Loading... +
+
+ )} + + {/* Empty state messages */} + {!loading && (viewType === "card" || viewType === "list") && ( +
+ {contacts?.length === 0 && ( +

No contact found

+ )} + {contacts?.length > 0 && currentItems.length === 0 && ( +

No matching contact found

+ )} +
+ )} + + {/* List View */} + {!loading && viewType === "list" && currentItems.length > 0 && ( +
+
- {!loading && contacts?.length === 0 ? ( - - -
-

No contact found

-
- - - ) : !loading && contacts?.length > 0 && currentItems.length === 0 ? ( - - -
-

No matching contact found

-
- - - ) : ( - !loading && - currentItems.map((contact) => ( - - )) - )} + {currentItems.map((contact) => ( + + ))}
)} - {/* CARD VIEW */} - {viewType === "card" && ( - <> - {contacts?.length === 0 && !loading ? ( + {/* Card View */} + {!loading && viewType === "card" && currentItems.length > 0 && ( +
+ {currentItems.map((contact) => (
-

No contact found

+
- ) : currentItems.length === 0 && !loading ? ( -
-

No matching contact found

-
- ) : ( -
- {currentItems.map((contact) => ( -
- -
- ))} -
- )} - + ))} +
)} - {/* NOTES VIEW */} - {viewType === "notes" && ( + {/* Notes View */} + {!loading && viewType === "notes" && (
{ searchText={searchText} setIsOpenModalNote={setIsOpenModalNote} filterAppliedNotes={filterAppliedNotes} + filterAppliedNotes={filterAppliedNotes} />
)} @@ -467,7 +448,7 @@ const Directory = ({ IsPage = true, prefernceContacts }) => { {!loading && viewType !== "notes" && contacts?.length > 0 && - currentItems.length > ITEMS_PER_PAGE && ( + filteredContacts.length > ITEMS_PER_PAGE && (
+
); }; -export default Directory; \ No newline at end of file +export default Directory; +