perbaikan upload file maks 2mb dan perbaikan input jumlah anggota keluarga

This commit is contained in:
2026-06-03 09:43:57 +07:00
parent 1ee12d8a72
commit 435b714d86
2 changed files with 15 additions and 7 deletions
+8
View File
@@ -2,6 +2,7 @@ import { useId, useMemo, type ChangeEvent } from "react";
import { Button } from "@/components/ui/button";
import { Label } from "@/components/ui/label";
import { FileUp, FileText, Image as ImageIcon, X } from "lucide-react";
import { toast } from "sonner";
type DocumentUploadFieldProps = {
label: string;
@@ -45,6 +46,13 @@ export function DocumentUploadField({
const file = event.target.files?.[0];
event.target.value = "";
if (!file || !onChange) return;
const MAX_SIZE = 2 * 1024 * 1024; // 2MB
if (file.size > MAX_SIZE) {
toast.error("Pastikan gambar tidak lebih besar dari 2mb");
return;
}
const dataUrl = await readFileAsDataUrl(file);
onChange(dataUrl);
};