fix form add and edit
- add type and code field - fix field with response
This commit is contained in:
@ -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,
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user