|
|
|
@ -21,9 +21,20 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (typeDialog === "Edit") { |
|
|
|
|
setId(dataEdit.id) |
|
|
|
|
setName(dataEdit.name) |
|
|
|
|
setEmail(dataEdit.email) |
|
|
|
|
setMessage(dataEdit.message) |
|
|
|
|
setPhoneNumber(dataEdit.number_phone) |
|
|
|
|
setStatus(dataEdit.status) |
|
|
|
|
setRole(dataEdit.role) |
|
|
|
|
} else { |
|
|
|
|
setId(0) |
|
|
|
|
|
|
|
|
|
setName('') |
|
|
|
|
setEmail('') |
|
|
|
|
setMessage('') |
|
|
|
|
setStatus('') |
|
|
|
|
setRole('') |
|
|
|
|
setPhoneNumber('') |
|
|
|
|
} |
|
|
|
|
}, [dataEdit, openDialog]) |
|
|
|
|
|
|
|
|
@ -40,13 +51,23 @@ const DialogForm = ({ openDialog, closeDialog, toggleDialog, typeDialog, dataEdi
|
|
|
|
|
if (!err) { |
|
|
|
|
if (typeDialog === "Save") { |
|
|
|
|
data = { |
|
|
|
|
name |
|
|
|
|
name, |
|
|
|
|
email, |
|
|
|
|
message, |
|
|
|
|
number_phone: phoneNumber, |
|
|
|
|
role, |
|
|
|
|
status |
|
|
|
|
} |
|
|
|
|
closeDialog('save', data); |
|
|
|
|
} else { |
|
|
|
|
data = { |
|
|
|
|
id, |
|
|
|
|
name, |
|
|
|
|
email, |
|
|
|
|
message, |
|
|
|
|
number_phone: phoneNumber, |
|
|
|
|
role, |
|
|
|
|
status |
|
|
|
|
} |
|
|
|
|
closeDialog('edit', data); |
|
|
|
|
} |
|
|
|
|