fixing add dialog manage user & manage position and edit dialog manage user
This commit is contained in:
@ -59,6 +59,7 @@ const AddDialog = () => {
|
||||
const [formField, setFormField] = useState(initialState);
|
||||
const resetForm = () => {
|
||||
setFormField(initialState);
|
||||
setAlert({ show: false, message: '' });
|
||||
};
|
||||
const [showPassword, setShowPassword] = useState({
|
||||
password: false,
|
||||
@ -104,6 +105,12 @@ const AddDialog = () => {
|
||||
|
||||
const isButtonDisabled = !messagePassword || isSubmitting || passwordErrors.length > 0;
|
||||
|
||||
useEffect(() => {
|
||||
if (showAddDialog === false) {
|
||||
resetForm();
|
||||
}
|
||||
}, [showAddDialog]);
|
||||
|
||||
/* actions */
|
||||
const doCreateUser = useCallback(
|
||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
@ -118,7 +125,7 @@ const AddDialog = () => {
|
||||
`${API_URL}/user/add_role/${response?.message?.id}/${formField.id_role}`,
|
||||
{}
|
||||
);
|
||||
setAlert((prev) => ({ ...prev, show: false, message: '' }));
|
||||
resetForm();
|
||||
handleAddDialog(false);
|
||||
toast.success('Success Create User');
|
||||
reload();
|
||||
@ -336,7 +343,6 @@ const AddDialog = () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="flex justify-end pt-2.5">
|
||||
<Button className="btn btn-primary" type="submit" disabled={isButtonDisabled}>
|
||||
|
||||
Reference in New Issue
Block a user