upd: dashboard admin

Deskripsi:
- view file pada detail pengaduan
- view file pada detail pelayanan surat
- close modal file jika error

No Issues
This commit is contained in:
2025-11-28 16:04:07 +08:00
parent cd7e602254
commit 075cb12417
7 changed files with 67 additions and 29 deletions

View File

@@ -80,7 +80,7 @@ export default function DashboardLastData() {
<PengaduanSection
key={index}
id={item.id}
nomer={item.noPengaduan}
nomer={item.noPengajuan}
judul={item.title}
status={item.status}
updated={item.updatedAt}

View File

@@ -7,6 +7,7 @@ export default function ModalFile({ open, onClose, folder, fileName }: { open: b
const [viewFile, setViewFile] = useState<string>("");
const [loading, setLoading] = useState<boolean>(false);
const [typeFile, setTypeFile] = useState<string>("");
const [error, setError] = useState<boolean>(false);
useEffect(() => {
if (open && fileName) {
@@ -27,23 +28,36 @@ export default function ModalFile({ open, onClose, folder, fileName }: { open: b
// load file
const urlApi = '/api/pengaduan/image?folder=' + folder + '&fileName=' + fileName;
const res = await fetch(urlApi);
if (!res.ok)
if (!res.ok) {
setError(true);
return notification({
title: "Error",
message: "Failed to load image",
type: "error",
});
}
const blob = await res.blob();
const url = URL.createObjectURL(blob);
setViewFile(url);
} catch (err) {
console.error("Gagal load gambar:", err);
setError(true);
notification({
title: "Error",
message: "Failed to load image",
type: "error",
});
} finally {
setLoading(false);
}
};
useEffect(() => {
if (error) {
onClose();
}
}, [error]);
return (