import { useEffect, useState } from "react"; import { useRouter } from "next/router"; // mobx import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; // components import { DeleteObjectModal } from "components/custom-attributes"; // ui import { CustomMenu, Loader } from "components/ui"; // icons import { TableProperties } from "lucide-react"; // types import { ICustomAttribute } from "types"; type Props = { handleEditObject: (object: ICustomAttribute) => void; projectId: string; }; export const ObjectsList: React.FC = observer(({ handleEditObject, projectId }) => { const [deleteObjectModal, setDeleteObjectModal] = useState(false); const [objectToDelete, setObjectToDelete] = useState(null); const router = useRouter(); const { workspaceSlug } = router.query; const { customAttributes: customAttributesStore } = useMobxStore(); const { entities, fetchEntities } = customAttributesStore; const handleDeleteObject = async (object: ICustomAttribute) => { setObjectToDelete(object); setDeleteObjectModal(true); }; useEffect(() => { if (!workspaceSlug) return; if (!entities) fetchEntities(workspaceSlug.toString(), projectId); }, [entities, fetchEntities, projectId, workspaceSlug]); return ( <> { setDeleteObjectModal(false); setTimeout(() => { setObjectToDelete(null); }, 300); }} />
{entities ? ( entities.length > 0 ? ( entities.map((entity) => (
{entity.display_name}

{entity.description}

handleEditObject(entity)}> Edit handleDeleteObject(entity)}> Delete
)) ) : (

No objects present

) ) : ( )}
); });