// react-hook-form import { Controller, useForm } from "react-hook-form"; // headless ui import { Disclosure } from "@headlessui/react"; // ui import { CustomSelect, ToggleSwitch } from "components/ui"; import { Input } from "../input"; // icons import { ChevronDown } from "lucide-react"; // types import { ICustomAttribute } from "types"; // constants import { CUSTOM_ATTRIBUTES_LIST, DATE_FORMATS, TIME_FORMATS } from "constants/custom-attributes"; type Props = {}; const defaultFormValues: Partial = { default_value: "", display_name: "", extra_settings: { date_format: "DD-MM-YYYY", time_format: "12", }, is_required: false, }; export const DateTimeAttributeForm: React.FC = () => { const { control } = useForm({ defaultValues: defaultFormValues }); const typeMetaData = CUSTOM_ATTRIBUTES_LIST.datetime; return ( {({ open }) => ( <>
{typeMetaData.label}
( )} /> ( {DATE_FORMATS.find((f) => f.value === value)?.label} } value={value} onChange={onChange} buttonClassName="bg-custom-background-100 !px-3 !py-2 !border-custom-border-200 !rounded" optionsClassName="w-full" input > {DATE_FORMATS.map((format) => ( {format.label} ))} )} /> ( {TIME_FORMATS.find((f) => f.value === value)?.label} } value={value} onChange={onChange} buttonClassName="bg-custom-background-100 !px-3 !py-2 !border-custom-border-200 !rounded" optionsClassName="w-full" input > {TIME_FORMATS.map((format) => ( {format.label} ))} )} />
( )} /> Mandatory field
)}
); };