added form submission logic with loading state management
This commit is contained in:
parent
d81482583e
commit
6c4c6db0d7
@ -98,12 +98,13 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose }) => {
|
|||||||
|
|
||||||
const onSubmitForm = (updatedProject) => {
|
const onSubmitForm = (updatedProject) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
handleSubmitForm(updatedProject);
|
|
||||||
|
handleSubmitForm( updatedProject ,setLoading);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
return () => setLoading(false);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -269,8 +270,8 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12 text-center">
|
<div className="col-12 text-center">
|
||||||
<button type="submit" className="btn btn-sm btn-primary me-3">
|
<button type="submit" className="btn btn-sm btn-primary me-3" disabled={isloading}>
|
||||||
{isloading ? "Please Wait" : project?.id ? "Update" : "Submit"}
|
{isloading ? "Please Wait..." : project?.id ? "Update" : "Submit"}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -21,7 +21,7 @@ const ProjectBanner = ( {project_data} ) =>
|
|||||||
const handleShow = () => setShowModal(true);
|
const handleShow = () => setShowModal(true);
|
||||||
const handleClose = () => setShowModal(false);
|
const handleClose = () => setShowModal(false);
|
||||||
|
|
||||||
const handleFormSubmit = ( updatedProject ) =>
|
const handleFormSubmit = ( updatedProject,setLoading ) =>
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( CurrentProject?.id )
|
if ( CurrentProject?.id )
|
||||||
@ -51,7 +51,7 @@ const ProjectBanner = ( {project_data} ) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
showToast( "Project updated successfully.", "success" );
|
showToast( "Project updated successfully.", "success" );
|
||||||
|
setLoading(false)
|
||||||
setShowModal(false)
|
setShowModal(false)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user