Skip to content

Commit

Permalink
Fix: Error Messages Persist in UserAdd Component
Browse files Browse the repository at this point in the history
  • Loading branch information
shauryag2002 committed Oct 5, 2024
1 parent 8e6a2f2 commit fcfb2f2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Components/Users/UserAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,24 +294,28 @@ export const UserAdd = (props: UserProps) => {

const handleDateChange = (e: FieldChangeEvent<Date>) => {
if (dayjs(e.value).isValid()) {
const errors = { ...state.errors, [e.name]: "" };
dispatch({
type: "set_form",
form: {
...state.form,
[e.name]: dayjs(e.value).format("YYYY-MM-DD"),
},
});
dispatch({ type: "set_errors", errors });
}
};

const handleFieldChange = (event: FieldChangeEvent<unknown>) => {
const errors = { ...state.errors, [event.name]: "" };
dispatch({
type: "set_form",
form: {
...state.form,
[event.name]: event.value,
},
});
dispatch({ type: "set_errors", errors });
};

useAbortableEffect(() => {
Expand Down

0 comments on commit fcfb2f2

Please sign in to comment.