diff --git a/src/pages/Directory/Directory.jsx b/src/pages/Directory/Directory.jsx index a9ceab49..ad3e1052 100644 --- a/src/pages/Directory/Directory.jsx +++ b/src/pages/Directory/Directory.jsx @@ -21,8 +21,9 @@ import ManageBucket from "../../components/Directory/ManageBucket"; import {useFab} from "../../Context/FabContext"; import {DireProvider, useDir} from "../../Context/DireContext"; -const Directory = () => +const Directory = ({IsPage=true,prefernceContacts}) => { + const[projectPrefernce,setPerfence] = useState(null) const[IsActive,setIsActive] = useState(true) const [isOpenModal, setIsOpenModal] = useState(false); const [isOpenModalNote, setIsOpenModalNote] = useState(false); @@ -44,7 +45,7 @@ const Directory = () => const { dirActions, setDirActions } = useDir(); - const { contacts, loading , refetch} = useDirectory(IsActive); + const { contacts, loading , refetch} = useDirectory(IsActive,projectPrefernce); const { contactCategory, loading: contactCategoryLoading } = useContactCategory(); const {buckets} = useBuckets(); @@ -72,7 +73,7 @@ const Directory = () => // cacheData("Contacts", {data:updatedContacts,isActive:IsActive}); // setContactList(updatedContacts); - refetch() + refetch(IsActive,prefernceContacts) } catch (error) { const msg = error.response?.data?.message || @@ -216,35 +217,43 @@ const handleDeleteContact = async (overrideId = null) => { }; - useEffect(() => { - setActions([ - { - label: "New Contact", - icon: "bx bx-plus-circle", - color: "warning", - onClick: () => setIsOpenModal(true), - }, - { - label: "Manage Bucket", - icon: "fa-solid fa-bucket fs-5 ", - color: "primary", - onClick: () => setOpenBucketModal(true), - }, - - ]); + useEffect(() => { + const actions = []; - return () => setActions([]); // Clean up - }, []); + if (IsPage) { + actions.push({ + label: "Manage Bucket", + icon: "fa-solid fa-bucket fs-5", + color:"primary", + onClick: () => setOpenBucketModal(true), + }); + } + actions.push({ + label: "New Contact", + icon: "bx bx-plus-circle", + color: "warning", + onClick: () => setIsOpenModal(true), + } ); + + + setActions(actions); + + return () => setActions([]); +}, [IsPage]); + useEffect( () => + { + setPerfence(prefernceContacts) +},[prefernceContacts]) return (