Skip to content

Commit

Permalink
fix: create new project ux tweaks (#969)
Browse files Browse the repository at this point in the history
* fix (createNewProject): splitTasks - when proceed btn is clicked, user is redirected to project_details page

* fix (projectDetails): download - file name renamed when user download forms or tasks
  • Loading branch information
NSUWAL123 authored Nov 6, 2023
1 parent 6016e60 commit 1ad32bd
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/frontend/src/api/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export const ProjectById = (url, existingProjectList, projectId) => {
};
};

export const DownloadProjectForm = (url, payload) => {
export const DownloadProjectForm = (url, payload, projectId) => {
return async (dispatch) => {
dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: payload, loading: true }));

const fetchProjectForm = async (url, payload) => {
const fetchProjectForm = async (url, payload, projectId) => {
try {
let response;
if (payload === 'form') {
Expand All @@ -79,7 +79,7 @@ export const DownloadProjectForm = (url, payload) => {
}
const a = document.createElement('a');
a.href = window.URL.createObjectURL(response.data);
a.download = `Project_form.${payload === 'form' ? '.xls' : '.geojson'}`;
a.download = `${payload === 'form' ? `project_form_${projectId}.xls` : `task_polygons_${projectId}.geojson`}`;
a.click();
dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: payload, loading: false }));
} catch (error) {
Expand All @@ -88,7 +88,7 @@ export const DownloadProjectForm = (url, payload) => {
dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: payload, loading: false }));
}
};
await fetchProjectForm(url, payload);
await fetchProjectForm(url, payload, projectId);
};
};
export const DownloadDataExtract = (url, payload) => {
Expand Down
12 changes: 10 additions & 2 deletions src/frontend/src/components/ProjectDetails/ProjectOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ const ProjectOptions = ({ setToggleGenerateModal }) => {
const handleDownload = (downloadType) => {
if (downloadType === 'form') {
dispatch(
DownloadProjectForm(`${import.meta.env.VITE_API_URL}/projects/download_form/${decodedId}/`, downloadType),
DownloadProjectForm(
`${import.meta.env.VITE_API_URL}/projects/download_form/${decodedId}/`,
downloadType,
decodedId,
),
);
} else if (downloadType === 'geojson') {
dispatch(
DownloadProjectForm(`${import.meta.env.VITE_API_URL}/projects/${decodedId}/download_tasks`, downloadType),
DownloadProjectForm(
`${import.meta.env.VITE_API_URL}/projects/${decodedId}/download_tasks`,
downloadType,
decodedId,
),
);
}
};
Expand Down
6 changes: 5 additions & 1 deletion src/frontend/src/components/createnewproject/SplitTasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,11 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customLineUpload, custo
</p>
<div className="fmtm-flex fmtm-justify-center fmtm-gap-6 fmtm-pt-5 ">
{/* <Button btnText="CANCEL" btnType="secondary"></Button> */}
<Button btnText="PROCEED" onClick={() => setToggleStatus(false)} btnType="primary"></Button>
<Button
btnText="PROCEED"
onClick={() => navigate(`/project_details/${environment.encode(projectDetailsResponse?.id)}`)}
btnType="primary"
></Button>
</div>
</div>
}
Expand Down

0 comments on commit 1ad32bd

Please sign in to comment.