From 7ae83788b4ee41840e3bc68e6ad539fc30127bd1 Mon Sep 17 00:00:00 2001 From: nico Date: Mon, 1 Sep 2025 16:14:28 +0800 Subject: [PATCH] Fix UI Admin Menu Landing Page & PPID --- .../landing-page/apbdes/[id]/edit/page.tsx | 359 ++++++++++-------- .../landing-page/apbdes/[id]/page.tsx | 166 ++++---- .../landing-page/apbdes/create/page.tsx | 289 ++++++++------ .../(dashboard)/landing-page/apbdes/page.tsx | 114 +++--- .../desa-anti-korupsi/_lib/layouTabs.tsx | 2 +- .../kategori-desa-anti-korupsi/[id]/page.tsx | 2 +- .../create/page.tsx | 2 +- .../kategori-desa-anti-korupsi/page.tsx | 2 +- .../list-desa-anti-korupsi/[id]/edit/page.tsx | 2 +- .../list-desa-anti-korupsi/[id]/page.tsx | 1 + .../list-desa-anti-korupsi/create/page.tsx | 2 +- .../list-desa-anti-korupsi/page.tsx | 144 ++++--- .../_lib/layoutTab.tsx | 130 ++++--- .../grafik-kepuasan-masyarakat/page.tsx | 90 ++--- .../responden/[id]/edit/page.tsx | 102 +++-- .../responden/[id]/page.tsx | 120 +++--- .../responden/page.tsx | 145 ++++--- .../prestasi-desa/_lib/layoutTabs.tsx | 137 ++++--- .../kategori-prestasi-desa/[id]/page.tsx | 54 ++- .../kategori-prestasi-desa/create/page.tsx | 66 ++-- .../kategori-prestasi-desa/page.tsx | 119 ++++-- .../list-prestasi-desa/[id]/edit/page.tsx | 248 ++++++------ .../list-prestasi-desa/[id]/page.tsx | 126 +++--- .../list-prestasi-desa/create/page.tsx | 180 +++++---- .../prestasi-desa/list-prestasi-desa/page.tsx | 123 +++--- .../landing-page/profile/_lib/layoutTabs.tsx | 2 +- .../profile/media-sosial/[id]/edit/page.tsx | 2 +- .../profile/media-sosial/[id]/page.tsx | 1 + .../profile/media-sosial/create/page.tsx | 2 +- .../profile/media-sosial/page.tsx | 36 +- .../profile/pejabat-desa/[id]/page.tsx | 2 +- .../profile/pejabat-desa/page.tsx | 4 +- .../program-inovasi/[id]/edit/page.tsx | 20 +- .../profile/program-inovasi/[id]/page.tsx | 31 +- .../profile/program-inovasi/create/page.tsx | 2 +- .../profile/program-inovasi/page.tsx | 6 +- .../landing-page/sdgs-desa/[id]/edit/page.tsx | 167 ++++---- .../landing-page/sdgs-desa/[id]/page.tsx | 136 ++++--- .../landing-page/sdgs-desa/create/page.tsx | 184 +++++---- .../landing-page/sdgs-desa/page.tsx | 139 ++++--- .../[id]/edit/page.tsx | 2 +- .../create/page.tsx | 2 +- .../[id]/page.tsx | 2 +- .../page.tsx | 2 +- .../keunggulan-program/[id]/page.tsx | 2 +- .../beasiswa-desa/keunggulan-program/page.tsx | 2 +- .../[id]/edit/page.tsx | 72 +++- .../[id]/page.tsx | 135 ++++--- .../create/page.tsx | 136 +++++-- .../page.tsx | 148 ++++---- .../ppid/dasar-hukum/edit/page.tsx | 85 +++-- .../(dashboard)/ppid/dasar-hukum/page.tsx | 90 +++-- .../ikm-desa-darmasaba/_lib/layoutTabs.tsx | 59 ++- .../indeks-kepuasan-masyarakat/page.tsx | 72 ++-- .../responden/[id]/edit/page.tsx | 100 +++-- .../responden/[id]/page.tsx | 120 +++--- .../ikm-desa-darmasaba/responden/page.tsx | 159 ++++---- .../ppid/permohonan-informasi-publik/page.tsx | 132 ++++--- .../page.tsx | 123 ++++-- .../ppid/profile-ppid/[id]/page.tsx | 230 +++++------ .../(dashboard)/ppid/profile-ppid/page.tsx | 165 ++++---- .../ppid/struktur-ppid/_lib/layoutTabs.tsx | 97 +++-- .../struktur-ppid/pegawai/[id]/edit/page.tsx | 295 ++++++++------ .../ppid/struktur-ppid/pegawai/[id]/page.tsx | 204 +++++----- .../struktur-ppid/pegawai/create/page.tsx | 308 +++++++++------ .../ppid/struktur-ppid/pegawai/page.tsx | 128 ++++--- .../posisi-organisasi/[id]/page.tsx | 73 +++- .../posisi-organisasi/create/page.tsx | 177 +++++---- .../struktur-ppid/posisi-organisasi/page.tsx | 141 ++++--- .../struktur-organisasi/page.tsx | 82 ++-- .../ppid/visi-misi-ppid/edit/page.tsx | 82 ++-- .../(dashboard)/ppid/visi-misi-ppid/page.tsx | 127 ++++--- .../(tambahan)/program-inovasi/[id]/page.tsx | 97 +++++ .../main-page/landing-page/ModuleView.tsx | 2 +- 74 files changed, 4312 insertions(+), 2798 deletions(-) create mode 100644 src/app/darmasaba/(tambahan)/program-inovasi/[id]/page.tsx diff --git a/src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx b/src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx index e40d354f..4d4c74f9 100644 --- a/src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx +++ b/src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx @@ -1,26 +1,27 @@ /* eslint-disable react-hooks/exhaustive-deps */ -"use client"; +'use client'; - -import apbdes from "@/app/admin/(dashboard)/_state/landing-page/apbdes"; -import colors from "@/con/colors"; -import ApiFetch from "@/lib/api-fetch"; +import apbdes from '@/app/admin/(dashboard)/_state/landing-page/apbdes'; +import colors from '@/con/colors'; +import ApiFetch from '@/lib/api-fetch'; import { Box, Button, Group, + Image, Paper, Stack, Text, TextInput, - Title -} from "@mantine/core"; -import { Dropzone } from "@mantine/dropzone"; -import { IconArrowBack, IconFile, IconImageInPicture, IconUpload, IconX } from "@tabler/icons-react"; -import { useParams, useRouter } from "next/navigation"; -import { useEffect, useState } from "react"; -import { toast } from "react-toastify"; -import { useProxy } from "valtio/utils"; + Title, + Tooltip, +} from '@mantine/core'; +import { Dropzone } from '@mantine/dropzone'; +import { IconArrowBack, IconFile, IconPhoto, IconUpload, IconX } from '@tabler/icons-react'; +import { useParams, useRouter } from 'next/navigation'; +import { useEffect, useState } from 'react'; +import { toast } from 'react-toastify'; +import { useProxy } from 'valtio/utils'; function EditAPBDes() { const apbdesState = useProxy(apbdes); @@ -38,14 +39,14 @@ function EditAPBDes() { fileId: apbdesState.edit.form.fileId || '' }); - // Load sdgs desa by id saat pertama kali + // Load APBDes data by id useEffect(() => { - const loadKolaborasi = async () => { + const loadAPBDes = async () => { const id = params?.id as string; if (!id) return; try { - const data = await apbdesState.edit.load(id); // akses langsung, bukan dari proxy + const data = await apbdesState.edit.load(id); if (data) { setFormData({ name: data.name || '', @@ -53,202 +54,238 @@ function EditAPBDes() { imageId: data.imageId || '', fileId: data.fileId || '' }); - if (data.image) { - if (data?.image?.link) { - setPreviewImage(data.image.link); - } - } - if (data.file) { - if (data?.file?.link) { - setPreviewDoc(data.file.link); - } - } + + if (data.image?.link) setPreviewImage(data.image.link); + if (data.file?.link) setPreviewDoc(data.file.link); } } catch (error) { - console.error("Error loading apbdes:", error); - toast.error("Gagal memuat data apbdes"); + console.error('Error loading APBDes:', error); + toast.error('Gagal memuat data APBDes'); } }; - loadKolaborasi(); + loadAPBDes(); }, [params?.id]); const handleSubmit = async () => { - try { - // edit global state with form data + // Update global state with form data apbdesState.edit.form = { ...apbdesState.edit.form, - name: formData.name, - jumlah: formData.jumlah, - imageId: formData.imageId // Keep existing imageId if not changed + ...formData, }; - // Jika ada file image baru, upload + // Upload new image if exists if (imageFile) { - const res = await ApiFetch.api.fileStorage.create.post({ file: imageFile, name: imageFile.name }); + const res = await ApiFetch.api.fileStorage.create.post({ + file: imageFile, + name: imageFile.name + }); const uploaded = res.data?.data; if (!uploaded?.id) { - return toast.error("Gagal upload gambar"); + return toast.error('Gagal upload gambar'); } - // edit imageId in global state apbdesState.edit.form.imageId = uploaded.id; } - // Jika ada file doc baru, upload + // Upload new document if exists if (docFile) { - const res = await ApiFetch.api.fileStorage.create.post({ file: docFile, name: docFile.name }); + const res = await ApiFetch.api.fileStorage.create.post({ + file: docFile, + name: docFile.name + }); const uploaded = res.data?.data; if (!uploaded?.id) { - return toast.error("Gagal upload doc"); + return toast.error('Gagal upload dokumen'); } - // edit fileId in global state apbdesState.edit.form.fileId = uploaded.id; } await apbdesState.edit.update(); - toast.success("apbdes berhasil diperbarui!"); - router.push("/admin/landing-page/APBDes"); + toast.success('APBDes berhasil diperbarui!'); + router.push('/admin/landing-page/APBDes'); } catch (error) { - console.error("Error updating apbdes:", error); - toast.error("Terjadi kesalahan saat memperbarui apbdes"); + console.error('Error updating APBDes:', error); + toast.error('Terjadi kesalahan saat memperbarui APBDes'); } }; return ( - - - - - - - Edit APBDes + + + + + + + Edit APBDes + + + + + setFormData({ ...formData, name: e.target.value })} - label={Nama} - placeholder="masukkan nama" + required /> setFormData({ ...formData, jumlah: e.target.value })} - label={Jumlah} - placeholder="masukkan jumlah" + required /> - - File Image - - { - const selectedFile = files[0]; // Ambil file pertama - if (selectedFile) { - setImageFile(selectedFile); - setPreviewImage(URL.createObjectURL(selectedFile)); // Buat preview - } - }} - onReject={() => toast.error('File tidak valid.')} - maxSize={5 * 1024 ** 2} // Maks 5MB - accept={{ - 'application/*': ['.jpeg', '.jpg', '.png', '.gif', '.webp', '.svg'], - }} - > - - - - - - - - - - -
- - Drag file ke sini atau klik untuk pilih image - - - Maksimal 5MB dan harus format image - -
-
-
- - Image - {previewImage ? ( -