add form validation to prevent empty input

This commit is contained in:
Wikzyy
2025-03-20 14:40:18 +07:00
parent ac3ccbdaba
commit 69d9fc66cb
2 changed files with 12 additions and 0 deletions

View File

@ -83,6 +83,12 @@ const AddDialog = () => {
const doCreatePosition = useCallback(
async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (formField.name.trim() === '') {
setAlert({ show: true, message: 'Please fill in all required fields.' });
return;
}
const response = await PostData(`${API_URL}/user_role/create`, {
name: formField.name,
roles: selectMenus,