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()) ); if (loading) return
Loading...
; if (!loading && sorted.length === 0) return
No buckets found
; return (
{sorted.map((bucket) => (
{bucket.name} {(IsDirecrory_Admin || IsDirectory_Manager || bucket?.createdBy?.id === profile?.employeeInfo?.id) && (
onEdit(bucket)} /> onDelete(bucket?.id)} />
)}
Contacts: {bucket.numberOfContacts || 0}

{bucket.description || "No description"}

))}
); }; export default BucketList;