import { useState } from "react"; // mobx import { useMobxStore } from "lib/mobx/store-provider"; import { observer } from "mobx-react-lite"; // headless ui import { Disclosure } from "@headlessui/react"; // ui import { Loader, ToggleSwitch } from "components/ui"; // icons import { ChevronDown } from "lucide-react"; // types import { TCustomAttributeTypes } from "types"; type Props = { entityId: string; issueId: string; onChange: (attributeId: string, val: string | string[] | undefined) => void; projectId: string; values: { [key: string]: string[] }; }; const DESCRIPTION_FIELDS: TCustomAttributeTypes[] = ["email", "number", "text", "url"]; export const CustomAttributesDescriptionFields: React.FC = observer((props) => { const { entityId, onChange, values } = props; const [hideOptionalFields, setHideOptionalFields] = useState(false); const { customAttributes } = useMobxStore(); const attributes = customAttributes.entityAttributes[entityId] ?? {}; const descriptionFields = Object.values(attributes).filter((a) => DESCRIPTION_FIELDS.includes(a.type) ); return ( <> {customAttributes.fetchEntityDetailsLoader ? ( ) : ( {({ open }) => ( <>
Custom Attributes
Hide optional fields setHideOptionalFields((prev) => !prev)} />
{Object.entries(descriptionFields).map(([attributeId, attribute]) => (
onChange(attribute.id, e.target.value)} required={attribute.is_required} /> {attribute.type === "number" && attribute.extra_settings?.representation !== "numerical" && ( Maximum value: {attribute.extra_settings?.divided_by} )}
))}
)}
)} ); });