fix form add and edit

- add type and code field
- fix field with response
This commit is contained in:
Wikzyy
2025-03-21 09:46:09 +07:00
6 changed files with 336 additions and 82 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,

View File

@ -91,6 +91,12 @@ const EditDialog = () => {
const doEditPosition = useCallback(
async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (formField.name.trim() === '') {
setAlert((prev) => ({ ...prev, show: true, message: 'Please fill name field.' }));
return;
}
if (!selectedPosition) {
toast.success('Please Select Position');
return;