From 3a6c11dcd5389234b82def3a679f223210a47845 Mon Sep 17 00:00:00 2001 From: "Deepak Pradhan (Varun)" <37866666+varun2948@users.noreply.github.com> Date: Thu, 19 Oct 2023 17:55:22 +0545 Subject: [PATCH] fix: warning message before project creation action is cancelled (#924) * feat: handleInput Change Replaced handlecustomchange with handleinputchanges * feat: SetIsUnsavedChanges added on first submit click * feat: custom hook for handling form exit on create project * feat: list of url to not block for form * feat: isUnsavedChanges action added * feat(CreateProject): prompt for blocking form exit - Fixes Warning message before project creation action is cancelled #700 --- .../createnewproject/ProjectDetailsForm.tsx | 22 +++++++++++++------ .../createnewproject/SplitTasks.tsx | 2 ++ src/frontend/src/constants/blockerUrl.ts | 2 ++ src/frontend/src/hooks/Prompt.tsx | 18 +++++++++++++++ .../src/store/slices/CreateProjectSlice.ts | 5 +++++ .../src/store/types/ICreateProject.ts | 1 + src/frontend/src/views/CreateNewProject.tsx | 7 ++++-- 7 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 src/frontend/src/constants/blockerUrl.ts create mode 100644 src/frontend/src/hooks/Prompt.tsx diff --git a/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx b/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx index 4bf5e29cfd..977d6e9522 100644 --- a/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx +++ b/src/frontend/src/components/createnewproject/ProjectDetailsForm.tsx @@ -29,7 +29,7 @@ const ProjectDetailsForm = ({ flag }) => { navigate('/upload-area'); }; - const { handleSubmit, handleCustomChange, values, errors, checkValidationOnly }: any = useForm( + const { handleSubmit, handleChange, handleCustomChange, values, errors, checkValidationOnly }: any = useForm( projectDetails, submission, CreateProjectValidation, @@ -72,7 +72,10 @@ const ProjectDetailsForm = ({ flag }) => { e.preventDefault(); } }; - + const handleInputChanges = (e) => { + handleChange(e); + dispatch(CreateProjectActions.SetIsUnsavedChanges(true)); + }; return (