fixed double input issue when double clicking on manage user
This commit is contained in:
@ -134,6 +134,7 @@ const AddDialog = () => {
|
||||
async (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
const response = await PostData(`${API_URL}/user/create`, formField);
|
||||
|
||||
if (response?.status) {
|
||||
@ -152,6 +153,12 @@ const AddDialog = () => {
|
||||
toast.error('Failed to create user');
|
||||
setAlert({ show: true, message: 'Failed to create user. Please try again.' });
|
||||
}
|
||||
} catch (err) {
|
||||
toast.error('Something went wrong');
|
||||
console.log(err);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
},
|
||||
[formField]
|
||||
);
|
||||
@ -204,6 +211,8 @@ const AddDialog = () => {
|
||||
|
||||
// console.log('Form data before submit:', formField);
|
||||
|
||||
if (isSubmitting) return;
|
||||
|
||||
if (
|
||||
formField.email.trim() === '' ||
|
||||
formField.username.trim() === '' ||
|
||||
@ -218,6 +227,7 @@ const AddDialog = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSubmitting(true);
|
||||
doCreateUser(e);
|
||||
// console.log(formField);
|
||||
setAlert({ show: false, message: '' });
|
||||
@ -505,7 +515,7 @@ const AddDialog = () => {
|
||||
|
||||
<div className="flex justify-end pt-2.5">
|
||||
<Button className="btn btn-primary" type="submit" disabled={isButtonDisabled}>
|
||||
Save Changes
|
||||
{isSubmitting ? 'Saving...' : 'Save Changes'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user