From d0bf6782d52891e20854b06b4fafe8a4d8723647 Mon Sep 17 00:00:00 2001 From: vinix Date: Sat, 11 Oct 2025 03:07:27 +0700 Subject: [PATCH] update mengikuti pusat --- src/pages/user/component/DetailUser.jsx | 29 +++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/pages/user/component/DetailUser.jsx b/src/pages/user/component/DetailUser.jsx index 50d9ffa..d251b5d 100644 --- a/src/pages/user/component/DetailUser.jsx +++ b/src/pages/user/component/DetailUser.jsx @@ -142,23 +142,28 @@ const DetailUser = (props) => { phone = '+62' + phone; } + // Backend expects field names with 'user_' prefix const payload = { - fullname: FormData.user_fullname, - name: FormData.user_name, - email: FormData.user_email, - phone: phone, - role_id: FormData.role_id || null, + user_fullname: FormData.user_fullname, + user_email: FormData.user_email, + user_phone: phone, }; - // Add password for new user (create mode) - if (!FormData.user_id) { - payload.password = FormData.password; - // Don't send confirmPassword, is_sa, is_active for create - } else { - // Only send is_active for update mode (is_sa is immutable) - payload.is_active = FormData.is_active ? 1 : 0; + // Only add role_id if it exists (backend requires number >= 1, no null) + if (FormData.role_id) { + payload.role_id = FormData.role_id; } + // Add password and name for new user (create mode) + if (!FormData.user_id) { + payload.user_name = FormData.user_name; // Username only for create + payload.user_password = FormData.password; // Backend expects 'user_password' + // Don't send confirmPassword, is_sa, is_active for create + } + // For update mode: + // - Don't send 'user_name' (username is immutable) + // - Don't send 'is_active' (backend validation schema doesn't allow it) + try { console.log('Payload being sent:', payload);