QC User & Admin Responsive : Menu Kesehatan - Ekonomi

This commit is contained in:
2025-10-03 10:17:06 +08:00
parent 8a6d8ed8db
commit f7fd9be255
55 changed files with 754 additions and 372 deletions

View File

@@ -581,33 +581,24 @@ const pelayananPerizinanBerusaha = proxy({
findById: {
data: null as pelayananPerizinanBerusahaForm | null,
loading: false,
initialize() {
pelayananPerizinanBerusaha.findById.data = {
id: "",
name: "",
deskripsi: "",
link: "",
} as pelayananPerizinanBerusahaForm;
},
async load(id: string) {
try {
pelayananPerizinanBerusaha.findById.loading = true;
const res = await fetch(
`/api/desa/layanan/pelayananperizinanberusaha/${id}`
);
if (res.ok) {
const data = await res.json();
pelayananPerizinanBerusaha.findById.data = data.data ?? null;
} else {
console.error(
"Failed to fetch pelayanan perizinan berusaha:",
res.statusText
);
pelayananPerizinanBerusaha.findById.data = null;
this.loading = true;
const response = await fetch(`/api/desa/layanan/pelayananperizinanberusaha/${id}`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = await response.json();
if (result?.success) {
this.data = result.data; // Make sure this matches your API response structure
}
return result?.data || null;
} catch (error) {
console.error("Error fetching pelayanan perizinan berusaha:", error);
pelayananPerizinanBerusaha.findById.data = null;
console.error('Error loading data:', error);
toast.error('Gagal memuat data');
return null;
} finally {
this.loading = false;
}
},
},