update mengikuti pusat
This commit is contained in:
@@ -142,23 +142,28 @@ const DetailUser = (props) => {
|
|||||||
phone = '+62' + phone;
|
phone = '+62' + phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Backend expects field names with 'user_' prefix
|
||||||
const payload = {
|
const payload = {
|
||||||
fullname: FormData.user_fullname,
|
user_fullname: FormData.user_fullname,
|
||||||
name: FormData.user_name,
|
user_email: FormData.user_email,
|
||||||
email: FormData.user_email,
|
user_phone: phone,
|
||||||
phone: phone,
|
|
||||||
role_id: FormData.role_id || null,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add password for new user (create mode)
|
// Only add role_id if it exists (backend requires number >= 1, no null)
|
||||||
if (!FormData.user_id) {
|
if (FormData.role_id) {
|
||||||
payload.password = FormData.password;
|
payload.role_id = FormData.role_id;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 {
|
try {
|
||||||
console.log('Payload being sent:', payload);
|
console.log('Payload being sent:', payload);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user