diff --git a/src/components/Directory/BucketList.jsx b/src/components/Directory/BucketList.jsx index 34b63ba6..7e941c1f 100644 --- a/src/components/Directory/BucketList.jsx +++ b/src/components/Directory/BucketList.jsx @@ -1,4 +1,11 @@ +import { useHasUserPermission } from "../../hooks/useHasUserPermission"; +import { useProfile } from "../../hooks/useProfile"; +import { DIRECTORY_ADMIN, DIRECTORY_MANAGER } from "../../utils/constants"; + const BucketList = ({ buckets, loading, searchTerm, onEdit, onDelete }) => { + const { profile } = useProfile(); + const IsDirecrory_Admin = useHasUserPermission(DIRECTORY_ADMIN); + const IsDirectory_Manager = useHasUserPermission(DIRECTORY_MANAGER); const sorted = buckets.filter((bucket) => bucket.name.toLowerCase().includes(searchTerm.toLowerCase()) ); @@ -14,21 +21,27 @@ const BucketList = ({ buckets, loading, searchTerm, onEdit, onDelete }) => {
{bucket.name} -
- onEdit(bucket)} - /> - onDelete(bucket.id)} - /> -
+ {(IsDirecrory_Admin || + IsDirectory_Manager || + bucket?.createdBy?.id === profile?.employeeInfo?.id) && ( +
+ onEdit(bucket)} + /> + onDelete(bucket?.id)} + /> +
+ )}
Contacts: {bucket.numberOfContacts || 0}
-

{bucket.description || "No description"}

+

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

@@ -37,4 +50,4 @@ const BucketList = ({ buckets, loading, searchTerm, onEdit, onDelete }) => { ); }; -export default BucketList; \ No newline at end of file +export default BucketList;