import { useEffect } from "react"; import { useRouter } from "next/router"; // mobx import { useMobxStore } from "lib/mobx/store-provider"; import { observer } from "mobx-react-lite"; import { Loader } from "components/ui"; import { CustomTextAttribute } from "components/custom-attributes"; type Props = { entityId: string; issueId: string; projectId: string; }; export const CustomAttributesList: React.FC = observer( ({ entityId, issueId, projectId }) => { const router = useRouter(); const { workspaceSlug } = router.query; const { customAttributes: customAttributesStore } = useMobxStore(); const { entityAttributes, fetchEntityDetails, fetchEntityDetailsLoader } = customAttributesStore; const attributes = entityAttributes[entityId] ?? {}; useEffect(() => { if (!entityAttributes[entityId]) { if (!workspaceSlug) return; fetchEntityDetails(workspaceSlug.toString(), entityId); } }, [entityAttributes, entityId, fetchEntityDetails, workspaceSlug]); return (
{fetchEntityDetailsLoader ? ( ) : (
{Object.entries(attributes).map(([attributeId, attribute]) => (
{attribute.type === "text" && ( {}} projectId={projectId} value={attribute.default_value ?? ""} /> )}
))}
)}
); } );