Skip to content

Commit

Permalink
fix (createNewProject): pageReload - redirect user to projectDetails …
Browse files Browse the repository at this point in the history
…step when page is reloaded on other steps of form
  • Loading branch information
NSUWAL123 committed Nov 24, 2023
1 parent 2a0f4a0 commit c066e38
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/frontend/src/views/CreateNewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,31 @@ import UploadArea from '../components/createnewproject/UploadArea';
import DataExtract from '../components/createnewproject/DataExtract';
import SplitTasks from '../components/createnewproject/SplitTasks';
import SelectForm from '../components/createnewproject/SelectForm';
import { useLocation } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import { CommonActions } from '.././store/slices/CommonSlice';
import { useAppSelector } from '../types/reduxTypes';
import Prompt from '../hooks/Prompt';
const CreateNewProject = () => {
const location = useLocation();
const dispatch = useDispatch();
const navigate = useNavigate();

const isUnsavedChanges = useAppSelector((state) => state.createproject.isUnsavedChanges);
const canSwitchCreateProjectSteps = useAppSelector((state) => state.createproject.canSwitchCreateProjectSteps);
const projectDetails: any = useAppSelector((state) => state.createproject.projectDetails);
const [geojsonFile, setGeojsonFile] = useState(null);
const [customLineUpload, setCustomLineUpload] = useState(null);
const [customPolygonUpload, setCustomPolygonUpload] = useState(null);
const [customFormFile, setCustomFormFile] = useState(null);

useEffect(() => {
if (location.pathname !== '/create-project' && !projectDetails.name && !projectDetails.odk_central_url) {
dispatch(CommonActions.SetCurrentStepFormStep({ flag: 'create_project', step: 1 }));
navigate('/create-project');
}
}, [location.pathname]);

useEffect(() => {
switch (location.pathname) {
case '/create-project':
Expand Down

0 comments on commit c066e38

Please sign in to comment.