|
|
@ -460,18 +460,29 @@ const ResourceWorker = ({ params, ...props }) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const saveUser = async (data) => { |
|
|
|
const saveUser = async (data) => { |
|
|
|
const formData = data |
|
|
|
try { |
|
|
|
const result = await axios.post(USER_ADD, formData, HEADER) |
|
|
|
const result = await axios.post(USER_ADD, data, HEADER); |
|
|
|
.then(res => res) |
|
|
|
if (result.data.code === 200) { |
|
|
|
.catch((error) => error.response); |
|
|
|
getDataUser(); |
|
|
|
|
|
|
|
NotificationManager.success(`Data resource berhasil ditambah`, 'Success!!'); |
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
} else { |
|
|
|
getDataUser(); |
|
|
|
NotificationManager.error(result.data.message, 'Failed!!'); |
|
|
|
NotificationManager.success(`Data resource berhasil ditambah`, 'Success!!'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
} catch (error) { |
|
|
|
NotificationManager.error(`${result.data.message}`, 'Failed!!'); |
|
|
|
if (error.response && error.response.data) { |
|
|
|
|
|
|
|
const errors = error.response.data; |
|
|
|
|
|
|
|
setOpenDialog(true); |
|
|
|
|
|
|
|
for (const [field, messages] of Object.entries(errors)) { |
|
|
|
|
|
|
|
messages.forEach(message => { |
|
|
|
|
|
|
|
NotificationManager.error(message, `Error validation`); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setOpenDialog(true); |
|
|
|
|
|
|
|
NotificationManager.error('Internal server error', 'Error!!'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const saveUserShift = async (data) => { |
|
|
|
const saveUserShift = async (data) => { |
|
|
|
const formData = data |
|
|
|
const formData = data |
|
|
@ -488,19 +499,32 @@ const ResourceWorker = ({ params, ...props }) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const editUser = async (data) => { |
|
|
|
const editUser = async (data) => { |
|
|
|
|
|
|
|
|
|
|
|
let urlEdit = USER_EDIT(data.id) |
|
|
|
let urlEdit = USER_EDIT(data.id) |
|
|
|
const formData = data |
|
|
|
const formData = data |
|
|
|
|
|
|
|
|
|
|
|
const result = await axios.put(urlEdit, formData, HEADER) |
|
|
|
try { |
|
|
|
|
|
|
|
const result = await axios.put(urlEdit, formData, HEADER) |
|
|
|
.then(res => res) |
|
|
|
.then(res => res) |
|
|
|
.catch((error) => error.response); |
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
if (result && result.data && result.data.code === 200) { |
|
|
|
getDataUser(); |
|
|
|
getDataUser(); |
|
|
|
NotificationManager.success(`Data resource berhasil diedit`, 'Success!!'); |
|
|
|
NotificationManager.success(`Data resource berhasil diedit`, 'Success!!'); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
NotificationManager.error(`${result.data.message}`, `Failed!!`); |
|
|
|
NotificationManager.error(`${result.data.message}`, `Failed!!`); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
if (error.response && error.response.data) { |
|
|
|
|
|
|
|
const errors = error.response.data; |
|
|
|
|
|
|
|
setOpenDialog(true); |
|
|
|
|
|
|
|
for (const [field, messages] of Object.entries(errors)) { |
|
|
|
|
|
|
|
messages.forEach(message => { |
|
|
|
|
|
|
|
NotificationManager.error(message, `Error validation`); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
setOpenDialog(true); |
|
|
|
|
|
|
|
NotificationManager.error('Internal server error', 'Error!!'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|