update mengikuti pusat
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user