Fix image di seafile sudah tidak pakai token tapi by folder di seafile

Kasih console di page profil ppid & visi misi di Profile Desa
This commit is contained in:
2026-02-05 11:10:30 +08:00
parent 25000d0b0f
commit df154806f7
8 changed files with 274 additions and 12 deletions

View File

@@ -57,12 +57,24 @@ const stateProfilePPID = proxy({
if (result.success) {
this.data = result.data;
return result.data;
} else throw new Error(result.message || "Gagal memuat data profile");
} else {
// Jika pesan adalah "Data tidak ditemukan" atau "Belum ada data profil PPID yang aktif",
// tetap simpan sebagai error tapi tidak perlu menampilkan toast error karena ini bukan error sebenarnya
if (result.message === "Data tidak ditemukan" || result.message === "Belum ada data profil PPID yang aktif") {
this.error = result.message;
return null;
} else {
throw new Error(result.message || "Gagal memuat data profile");
}
}
} catch (err) {
const msg = (err as Error).message;
this.error = msg;
console.error("Load profile error:", msg);
toast.error("Gagal memuat data profile");
// Hanya tampilkan toast error jika bukan karena data tidak ditemukan
if (msg !== "Data tidak ditemukan" && msg !== "Belum ada data profil PPID yang aktif") {
toast.error("Gagal memuat data profile");
}
return null;
} finally {
this.loading = false;

View File

@@ -41,10 +41,18 @@ export default async function handler(request: Request) {
}
if (!data) {
return Response.json({
success: false,
message: "Data tidak ditemukan",
}, { status: 404 });
// Untuk ID 'edit', kembalikan pesan khusus karena mungkin memang belum ada data
if (id === 'edit') {
return Response.json({
success: false,
message: "Belum ada data profil PPID yang aktif",
}, { status: 404 });
} else {
return Response.json({
success: false,
message: "Data tidak ditemukan",
}, { status: 404 });
}
}
return Response.json({

View File

@@ -13,9 +13,9 @@ function VisiMisiDesa() {
state.findUnique.load('edit');
}, []);
const { data, loading } = state.findUnique;
const { data, loading, error } = state.findUnique;
if (loading || !data) {
if (loading) {
return (
<Box py="xl">
<Skeleton h={500} radius="lg" />
@@ -23,6 +23,21 @@ function VisiMisiDesa() {
);
}
if (error || !data) {
return (
<Box py="xl">
<Paper p="xl" radius="lg" shadow="md" withBorder>
<Title order={2} c="red" ta="center" mb="md">
Terjadi Kesalahan
</Title>
<Text ta="center" c="dimmed">
{error || 'Data visi dan misi desa tidak ditemukan'}
</Text>
</Paper>
</Box>
);
}
return (
<Box>
<Stack align="center" gap="xl">

View File

@@ -34,7 +34,7 @@ function Page() {
}, []);
// LOADING SKELETON
if (!allList.profile.data)
if (allList.profile.loading)
return (
<Stack bg={colors.Bg} py="xl" gap="22">
<Box px={{ base: 'md', md: 100 }}>
@@ -53,6 +53,50 @@ function Page() {
</Stack>
);
// ERROR HANDLING
if (allList.profile.error)
return (
<Stack bg={colors.Bg} py="xl" gap="22" justify="center" align="center">
<Box px={{ base: 'md', md: 100 }}>
<Paper p="xl" bg={colors['white-trans-1']} radius="lg" shadow="xl">
{allList.profile.error === "Belum ada data profil PPID yang aktif" ? (
<>
<Title order={3} ta="center" c={"orange"} fw={700}>
Data Profile PPID Belum Tersedia
</Title>
<Text ta="center" mt="md">Mohon maaf, data profil PPID belum tersedia saat ini</Text>
</>
) : (
<>
<Title order={3} ta="center" c={"red"} fw={700}>
Gagal Memuat Data Profile
</Title>
<Text ta="center" mt="md">Silakan coba beberapa saat lagi</Text>
<Text ta="center" size="sm" c={"gray"} mt="sm">
Error: {allList.profile.error}
</Text>
</>
)}
</Paper>
</Box>
</Stack>
);
// NO DATA HANDLING
if (!allList.profile.data)
return (
<Stack bg={colors.Bg} py="xl" gap="22" justify="center" align="center">
<Box px={{ base: 'md', md: 100 }}>
<Paper p="xl" bg={colors['white-trans-1']} radius="lg" shadow="xl">
<Title order={3} ta="center" c={"orange"} fw={700}>
Data Profile PPID Belum Tersedia
</Title>
<Text ta="center" mt="md">Mohon maaf, data profil PPID belum tersedia saat ini</Text>
</Paper>
</Box>
</Stack>
);
const dataArray = Array.isArray(allList.profile.data)
? allList.profile.data
: [allList.profile.data];