feat(apbdes): make image and file optional for edit page too
Changes: Backend (updt.ts, index.ts): - Update FormUpdateBody: imageId?: string | null - Update Elysia schema: t.Optional(t.String()) - Handle null/undefined values when updating UI (edit/page.tsx): - Remove mandatory validation for imageId and fileId - Update labels to show '(Opsional)' - Simplify handleSubmit logic (no validation check) - Keep existing file IDs if no new upload User Flow: Before: Edit required imageId and fileId to be present After: Can update APBDes without files, preserve existing or set to null Files changed: - src/app/api/[[...slugs]]/_lib/landing_page/apbdes/updt.ts - src/app/api/[[...slugs]]/_lib/landing_page/apbdes/index.ts - src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -23,8 +23,9 @@ const ApbdesFormSchema = z.object({
|
||||
name: z.string().optional(),
|
||||
deskripsi: z.string().optional(),
|
||||
jumlah: z.string().optional(),
|
||||
imageId: z.string().min(1, "Gambar wajib diunggah"),
|
||||
fileId: z.string().min(1, "File wajib diunggah"),
|
||||
// Image dan file opsional (bisa kosong)
|
||||
imageId: z.string().optional(),
|
||||
fileId: z.string().optional(),
|
||||
items: z.array(ApbdesItemSchema).min(1, "Minimal ada 1 item"),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user