diff --git a/src/pages/Directory/Directory.jsx b/src/pages/Directory/Directory.jsx index f231cd67..413d7170 100644 --- a/src/pages/Directory/Directory.jsx +++ b/src/pages/Directory/Directory.jsx @@ -12,15 +12,18 @@ import UpdateContact from "../../components/Directory/UpdateContact"; import CardViewDirectory from "../../components/Directory/CardViewDirectory"; import { useContactCategory } from "../../hooks/masterHook/useMaster"; import usePagination from "../../hooks/usePagination"; -import {ITEMS_PER_PAGE} from "../../utils/constants"; +import { ITEMS_PER_PAGE } from "../../utils/constants"; +import ProfileContactDirectory from "../../components/Directory/ProfileContactDirectory"; const Directory = () => { const [isOpenModal, setIsOpenModal] = useState(false); + const [isOpenModalNote, setIsOpenModalNote] = useState(false); const [selectedContact, setSelectedContact] = useState(null); + const [open_contact, setOpen_contact] = useState(null); const [ContatList, setContactList] = useState([]); const [contactCategories, setContactCategories] = useState([]); - const [ searchText, setSearchText ] = useState( "" ); - const [listView, setListView] = useState(true); + const [searchText, setSearchText] = useState(""); + const [listView, setListView] = useState(false); const { contacts, loading } = useDirectory(); const { contactCategory, loading: contactCategoryLoading } = @@ -59,6 +62,7 @@ const Directory = () => { const closedModel = () => { setIsOpenModal(false); setSelectedContact(null); + setOpen_contact(null); }; useEffect(() => { setContactList(contacts); @@ -80,23 +84,39 @@ const Directory = () => { ); }; const filteredContacts = useMemo(() => { - return ContatList - .filter((c) => { - const matchesSearch = - c.name.toLowerCase().includes(searchText.toLowerCase()) || - c.organization.toLowerCase().includes(searchText.toLowerCase()); - const matchesCategory = - selectedCategoryIds.length === 0 || - selectedCategoryIds.includes(c.contactCategory?.id); - return matchesSearch && matchesCategory; - }) - .sort((a, b) => a.name.localeCompare(b.name)); + return ContatList.filter((c) => { + const matchesSearch = + c.name.toLowerCase().includes(searchText.toLowerCase()) || + c.organization.toLowerCase().includes(searchText.toLowerCase()); + const matchesCategory = + selectedCategoryIds.length === 0 || + selectedCategoryIds.includes(c.contactCategory?.id); + return matchesSearch && matchesCategory; + }).sort((a, b) => a.name.localeCompare(b.name)); }, [ContatList, searchText, selectedCategoryIds]); const { currentPage, totalPages, currentItems, paginate } = usePagination( filteredContacts, ITEMS_PER_PAGE ); + const renderModalContent = () => { + if (selectedContact) { + return ( + + ); + } + + if (!open_contact) { + return ( + + ); + } + }; + return (
{ closeModal={() => setIsOpenModal(false)} size="lg" > - {selectedContact ? ( - - ) : ( - - )} + {renderModalContent()} + + )} + {isOpenModalNote && ( + setIsOpenModalNote(false)} + size="lg" + IsCloseBtn={false} + > + {open_contact && setIsOpenModalNote(false)} />} )}
-
+
{
- -
+
- { - listView ? ( -
- - - - - - - - - - - - - - {loading && ContatList.length === 0 && ( + {listView ? ( +
+
-
- alert("User icon clicked")} - /> - Name -
-
-
- - Email -
-
-
- alert("User icon clicked")} - /> - Phone -
-
-
- - Organization -
-
Category - Action -
+ - - - )} - {!loading && contacts.length == 0 && ContatList.length === 0 && ( - - - - )} - {!loading && - currentItems.map((contact) => ( - - ))} - -
Loading...
No Contact Found
-
- ) : ( -
- {currentItems.map((contact, index) => ( -
- -
- ))} -
- ) - } + +
+ alert("User icon clicked")} + /> + Name +
+ + +
+ + Email +
+ - - - + +
+ alert("User icon clicked")} + /> + Phone +
+ + +
+ + Organization +
+ + Category + + Action + + + + + {loading && ContatList.length === 0 && ( + + Loading... + + )} + {!loading && + contacts.length == 0 && + ContatList.length === 0 && ( + + No Contact Found + + )} + {!loading && + currentItems.map((contact) => ( + + ))} + + +
+ ) : ( +
+ {currentItems.map((contact, index) => ( +
+ +
+ ))} +
+ )} {!loading && (