"use client"; import { Checkbox } from "@suphark/ui/components/ui/checkbox"; import { FormControl, FormDescription, FormField, FormItem, FormLabel, } from "@suphark/ui/components/ui/form"; import { Switch } from "@suphark/ui/components/ui/switch"; import { cn } from "@suphark/ui/lib/utils"; import type { ComponentProps } from "react"; import type { Control, FieldValues, Path } from "react-hook-form"; type FormFieldBooleanProps = { control: Control; name: Path; label: string; description?: string; disabled?: boolean; } & ( | { variant?: "checkbox"; // Default checkboxProps?: ComponentProps; className?: string; // Container className } | { variant: "switch"; switchProps?: ComponentProps; className?: string; // Container className } ); export function FormFieldBoolean({ control, name, label, description, disabled, className, ...props }: FormFieldBooleanProps) { return ( { if (props.variant === "switch") { return (
{label} {description && {description}}
); } // Default: Checkbox return (
{label} {description && {description}}
); }} /> ); }