"use client"; import { useActionState } from "react"; import Link from "next/link"; import { Button } from "@/components/ui/button"; import { Input, Textarea, Select } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { fmtDate } from "@/lib/utils"; import type { ActionState } from "./actions"; type CustomerValues = { customerName?: string | null; contacts?: string | null; balanceUser?: string | null; phone?: string | null; detail?: string | null; deposit?: string | null; buy?: string | null; birthdayType?: number | null; birthday?: Date | null; salesman?: string | null; reportDate?: Date | null; remark?: string | null; }; function Field({ label, name, defaultValue, required, type = "text", pattern, inputMode, title, }: { label: string; name: string; defaultValue?: string | null; required?: boolean; type?: string; pattern?: string; inputMode?: React.HTMLAttributes["inputMode"]; title?: string; }) { return (
); } export function CustomerForm({ action, defaultValues, submitLabel = "保存", requireAll = false, }: { action: (prev: ActionState, formData: FormData) => Promise; defaultValues?: CustomerValues; submitLabel?: string; requireAll?: boolean; }) { const [state, formAction, pending] = useActionState(action, {}); const v = defaultValues ?? {}; return (