add validation empty field on create and update form

This commit is contained in:
Wikzyy
2025-03-17 11:06:58 +07:00
parent 075c89c163
commit aeea5c31af
14 changed files with 37 additions and 36 deletions

View File

@ -72,12 +72,12 @@ const AddDialog = () => {
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (formField.name === '') {
if (formField.name.trim() === '') {
setAlert({ show: true, message: 'Please fill name field.' });
return;
}
doCreateMunicipio(e);
// doCreateMunicipio(e);
console.log(parsedUser.email);
console.log(formField);
setAlert({ show: false, message: '' });

View File

@ -77,7 +77,7 @@ const EditDialog = () => {
const handleUpdate = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (formField.name === '') {
if (formField.name.trim() === '') {
setAlert({ show: true, message: 'Please fill name field.' });
return;
}
@ -88,7 +88,7 @@ const EditDialog = () => {
// created_at: formattedTime
// });
doUpdateMunicipios(e);
// doUpdateMunicipios(e);
console.log(formField);
setAlert({ show: false, message: '' });
};

View File

@ -29,8 +29,8 @@ const ListToolbar = () => {
<input
type="text"
placeholder="Search Municipios"
value={searchName}
onChange={(event) => setSearchName(event.target.value)}
value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
/>
</label>
<DefaultTooltip title={'Filter'} placement={'top'}>