Skip to content

Commit

Permalink
Merge pull request #441 from hotosm/feat/implement-gcp
Browse files Browse the repository at this point in the history
Feat/implement gcp
  • Loading branch information
suzit-10 authored Jan 16, 2025
2 parents c05c2ad + 8b311ae commit 32a6f16
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"dependencies": {
"@cyntler/react-doc-viewer": "^1.17.0",
"@geomatico/maplibre-cog-protocol": "^0.3.1",
"@hotosm/gcp-editor": "^0.0.8",
"@hotosm/gcp-editor": "^0.0.9",
"@mapbox/mapbox-gl-draw": "^1.4.2",
"@mapbox/mapbox-gl-draw-static-mode": "^1.0.1",
"@radix-ui/react-popover": "^1.0.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@hotosm/gcp-editor';
import '@hotosm/gcp-editor/style.css';
import { useDispatch } from 'react-redux';
import { setProjectState } from '@Store/actions/project';
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { processAllImagery } from '@Services/project';
import { useParams } from 'react-router-dom';

Expand All @@ -16,10 +16,12 @@ const GcpEditor = ({
const { id } = useParams();
const dispatch = useDispatch();
const CUSTOM_EVENT: any = 'start-processing-click';
const queryClient = useQueryClient();

const { mutate: startImageProcessing } = useMutation({
mutationFn: processAllImagery,
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['project-detail'] });
dispatch(setProjectState({ showGcpEditor: false }));
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const DescriptionSection = ({
page?: 'project-description' | 'project-approval';
}) => {
const dispatch = useDispatch();

return (
<div className="naxatw-mt-4 naxatw-flex naxatw-flex-col naxatw-gap-3">
{page === 'project-approval' && (
Expand Down Expand Up @@ -66,18 +67,19 @@ const DescriptionSection = ({
)}
</div>
</div>
{page !== 'project-approval' && (
<div>
<Button
className="naxatw-bg-red"
onClick={() => {
dispatch(setProjectState({ showGcpEditor: true }));
}}
>
Start Processing
</Button>
</div>
)}
{page !== 'project-approval' &&
projectData?.image_processing_status !== 1 && (
<div>
<Button
className="naxatw-bg-red"
onClick={() => {
dispatch(setProjectState({ showGcpEditor: true }));
}}
>
Start Processing
</Button>
</div>
)}
{page === 'project-approval' &&
projectData?.regulator_approval_status === 'PENDING' && (
<ApprovalSection />
Expand Down
19 changes: 6 additions & 13 deletions src/frontend/src/views/IndividualProject/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { setProjectState } from '@Store/actions/project';
import { useTypedDispatch, useTypedSelector } from '@Store/hooks';
import centroid from '@turf/centroid';
import hasErrorBoundary from '@Utils/hasErrorBoundary';
import { useEffect } from 'react';
import { useParams } from 'react-router-dom';

// eslint-disable-next-line camelcase
Expand Down Expand Up @@ -111,19 +112,11 @@ const IndividualProject = () => {
return {};
};

// const { mutate: startImageProcessing } = useMutation({
// mutationFn: processAllImagery,
// onSuccess: () => {
// dispatch(setProjectState({ showGcpEditor: false }));
// },
// });

// useEffect(() => {
// if (!gcpData || !showGcpEditor) return;
// const blob = new Blob([gcpData], { type: 'text/plain;charset=utf-8;' });
// const gcpFile = new File([blob], 'gcp.txt');
// startImageProcessing({ projectId: id, gcp_file: gcpFile });
// }, [gcpData, id]);
useEffect(() => {
return () => {
dispatch(setProjectState({ showGcpEditor: false }));
};
}, [dispatch]);

return (
<section className="individual project naxatw-h-screen-nav naxatw-px-3 naxatw-py-8 lg:naxatw-px-20">
Expand Down

0 comments on commit 32a6f16

Please sign in to comment.