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