"use client" import { format } from "date-fns" import { CalendarIcon, ChevronLeft, ChevronRight } from "lucide-react" import { cn } from "@/app/_lib/utils" // UI Components import { FormControl, FormField, FormItem, FormLabel, FormMessage, FormDescription } from "@/app/_components/ui/form" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/app/_components/ui/select" import { Input } from "@/app/_components/ui/input" import { Button } from "@/app/_components/ui/button" import { Textarea } from "@/app/_components/ui/textarea" import { Popover, PopoverContent, PopoverTrigger } from "@/app/_components/ui/popover" import { Switch } from "@/app/_components/ui/switch" import { Checkbox } from "@/app/_components/ui/checkbox" import { DayPicker } from "react-day-picker" import { DateTimePicker } from "@/app/_components/date-time-picker" import { DateTimePicker2 } from "./ui/date-picker" // Reusable form field component to reduce repetition interface FormFieldProps { name: string label: string type: string control: any placeholder?: string options?: { value: string; label: string }[] rows?: number isDate?: boolean isBoolean?: boolean description?: string booleanType?: "switch" | "checkbox" | "select" fromYear?: number toYear?: number } export function FormFieldWrapper({ name, label, type, control, placeholder, options, rows = 1, isDate, isBoolean, description, booleanType = "switch", fromYear = 1900, toYear = new Date().getFullYear(), }: FormFieldProps) { // Default boolean options for select const booleanOptions = [ { value: "false", label: "False" }, { value: "true", label: "True" }, ] return ( (
{label}

{type}

{description && isBoolean && booleanType === "switch" && {description}}
{isBoolean ? ( booleanType === "switch" ? ( ) : booleanType === "checkbox" ? ( ) : ( ) ) : type.includes("select") && options ? ( ) : isDate ? ( date > new Date() || date < new Date(`${fromYear}-01-01`)} fromYear={fromYear} toYear={toYear} showTimePicker /> ) : rows > 1 ? (