import Image from "next/image"; // react-hook-form import { Controller, useForm } from "react-hook-form"; // headless ui import { Disclosure } from "@headlessui/react"; // ui import { ToggleSwitch } from "components/ui"; import { Input } from "../input"; // icons import { CheckCircle2, ChevronDown } from "lucide-react"; // assets import CheckRepresentation from "public/custom-attributes/checkbox/check.svg"; import ToggleSwitchRepresentation from "public/custom-attributes/checkbox/toggle-switch.svg"; // types import { ICustomAttribute, TCustomAttributeTypes } from "types"; // constants import { CUSTOM_ATTRIBUTES_LIST } from "constants/custom-attributes"; type Props = {}; const checkboxAttributeRepresentations = [ { image: CheckRepresentation, key: "check", label: "Check", }, { image: ToggleSwitchRepresentation, key: "toggle_switch", label: "Toggle Switch", }, ]; const defaultFormValues: Partial = { default_value: "checked", display_name: "", extra_settings: { representation: "check", }, is_required: false, }; export const CheckboxAttributeForm: React.FC = () => { const { control, watch } = useForm({ defaultValues: defaultFormValues }); const typeMetaData = CUSTOM_ATTRIBUTES_LIST.checkbox; return ( {({ open }) => ( <>
{typeMetaData.label}

Default value

Show as
( <> {checkboxAttributeRepresentations.map((representation) => (
onChange(representation.key)} >
{representation.label}
{representation.label} {value === representation.key && ( )}
))} )} />
( )} /> Mandatory field
)} ); };