"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { IdCard, Image as ImageIcon, Landmark, Check } from "lucide-react"; import { submitVerificationAction } from "@/features/organizer/actions"; import { DateField } from "@/components/shared/date-picker"; type Initial = { fullName: string; nik: string; birthDate: Date; address: string; ktpImageKey: string; livenessKey: string; bankName: string; bankAccountNumber: string; bankAccountName: string; } | null; type UploadKind = "ktp" | "liveness"; const ACCEPT_MIME = "image/jpeg,image/png,image/webp"; const MAX_BYTES = 5 * 1024 * 1024; export function VerifyForm({ initial }: { initial: Initial }) { const router = useRouter(); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const [ktpKey, setKtpKey] = useState(initial?.ktpImageKey ?? ""); const [livenessKey, setLivenessKey] = useState(initial?.livenessKey ?? ""); // `birthDate` dari DB tersimpan sebagai tengah malam UTC — baca pakai getter // UTC supaya hari kalender yang tampil di picker tidak bergeser. const [birthDate, setBirthDate] = useState( initial ? new Date( initial.birthDate.getUTCFullYear(), initial.birthDate.getUTCMonth(), initial.birthDate.getUTCDate() ) : null ); async function handleSubmit(e: React.FormEvent) { e.preventDefault(); setError(""); if (!birthDate) { setError("Tanggal lahir wajib diisi"); return; } if (!ktpKey || !livenessKey) { setError("Foto KTP dan foto memegang kertas SETRIP wajib diunggah"); return; } setLoading(true); const formData = new FormData(e.currentTarget); formData.set("ktpImageKey", ktpKey); formData.set("livenessKey", livenessKey); const result = await submitVerificationAction(formData); setLoading(false); if (result.error) { setError(result.error); return; } router.refresh(); } const inputCls = "w-full rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-2.5 text-sm text-neutral-800 transition-colors placeholder:text-neutral-400 focus:bg-white"; return (
{error && (
{error}
)}

Data KTP