QC User & Admin Responsive : Menu Landing Page - Desa
This commit is contained in:
@@ -46,12 +46,19 @@ function EditPejabatDesa() {
|
||||
const profileData = await profileLandingPageState.pejabatDesa.findUnique.load(id);
|
||||
|
||||
if (profileData) {
|
||||
// Initialize form data
|
||||
setFormData({
|
||||
name: profileData.name || '',
|
||||
position: profileData.position || '',
|
||||
imageId: profileData.imageId || null,
|
||||
});
|
||||
|
||||
// Initialize edit state with profile data
|
||||
profileLandingPageState.pejabatDesa.edit.initialize({
|
||||
...profileData,
|
||||
imageId: profileData.imageId || ''
|
||||
});
|
||||
|
||||
if (profileData.image?.link) {
|
||||
setPreviewImage(profileData.image.link);
|
||||
}
|
||||
@@ -110,7 +117,14 @@ function EditPejabatDesa() {
|
||||
imageId = uploaded.id;
|
||||
}
|
||||
|
||||
// Update global state only on submit
|
||||
// Ensure we have the ID from the URL
|
||||
const id = params?.id as string;
|
||||
if (!id) {
|
||||
throw new Error("ID tidak ditemukan");
|
||||
}
|
||||
|
||||
// Update global state with the ID and form data
|
||||
profileLandingPageState.pejabatDesa.edit.id = id;
|
||||
profileLandingPageState.pejabatDesa.edit.form = {
|
||||
...formData,
|
||||
imageId: imageId || '', // Ensure imageId is always a string
|
||||
|
||||
Reference in New Issue
Block a user