diff --git a/src/frontend/src/components/Activities.jsx b/src/frontend/src/components/Activities.jsx index f916003585..16faaf9c59 100755 --- a/src/frontend/src/components/Activities.jsx +++ b/src/frontend/src/components/Activities.jsx @@ -1,12 +1,11 @@ import React from 'react'; import IconButtonCard from '@/utilities/IconButtonCard'; -import environment from '@/environment'; import { easeIn, easeOut } from 'ol/easing'; import CoreModules from '@/shared/CoreModules'; import AssetModules from '@/shared/AssetModules'; //Activity Model to be display in Activities panel const Activities = ({ history, defaultTheme, mapDivPostion, map, view, state, params }) => { - const index = state.projectTaskBoundries.findIndex((project) => project.id == environment.decode(params.id)); + const index = state.projectTaskBoundries.findIndex((project) => project.id == params.id); return ( diff --git a/src/frontend/src/components/ActivitiesPanel.jsx b/src/frontend/src/components/ActivitiesPanel.jsx index 0c5a0d2976..55cd6aac7b 100755 --- a/src/frontend/src/components/ActivitiesPanel.jsx +++ b/src/frontend/src/components/ActivitiesPanel.jsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from 'react'; import BasicCard from '@/utilities/BasicCard'; import Activities from '@/components/Activities'; -import environment from '@/environment'; import CoreModules from '@/shared/CoreModules'; import AssetModules from '@/shared/AssetModules'; @@ -67,7 +66,7 @@ const ActivitiesPanel = ({ defaultTheme, state, params, map, view, mapDivPostion }; useEffect(() => { - const index = state.findIndex((project) => project.id == environment.decode(params.id)); + const index = state.findIndex((project) => project.id == params.id); let taskHistories = []; if (index != -1) { diff --git a/src/frontend/src/components/DialogTaskActions.jsx b/src/frontend/src/components/DialogTaskActions.jsx index 16d5708fb8..b96958f46a 100755 --- a/src/frontend/src/components/DialogTaskActions.jsx +++ b/src/frontend/src/components/DialogTaskActions.jsx @@ -19,8 +19,8 @@ export default function Dialog({ taskId, feature, map, view }) { const geojsonStyles = MapStyles(); const dispatch = CoreModules.useAppDispatch(); const params = CoreModules.useParams(); - const currentProjectId = environment.decode(params.id); - const currentTaskId = environment.encode(taskId); + const currentProjectId = params.id; + const currentTaskId = taskId; const projectIndex = projectData.findIndex((project) => project.id == currentProjectId); const currentStatus = { ...projectData?.[projectIndex]?.taskBoundries?.filter((task) => { diff --git a/src/frontend/src/components/GenerateBasemap.jsx b/src/frontend/src/components/GenerateBasemap.jsx index 77386b4436..ea0f6d1b96 100644 --- a/src/frontend/src/components/GenerateBasemap.jsx +++ b/src/frontend/src/components/GenerateBasemap.jsx @@ -9,8 +9,7 @@ import { ProjectActions } from '@/store/slices/ProjectSlice'; const GenerateBasemap = ({ projectInfo }) => { const dispatch = CoreModules.useAppDispatch(); const params = CoreModules.useParams(); - const encodedId = params.id; - const decodedId = environment.decode(encodedId); + const id = params.id; const [selectedTileSource, setSelectedTileSource] = useState(null); const [selectedOutputFormat, setSelectedOutputFormat] = useState(null); @@ -37,7 +36,7 @@ const GenerateBasemap = ({ projectInfo }) => { }; const getTilesList = () => { - dispatch(GetTilesList(`${import.meta.env.VITE_API_URL}/projects/tiles_list/${decodedId}/`)); + dispatch(GetTilesList(`${import.meta.env.VITE_API_URL}/projects/tiles_list/${id}/`)); }; useEffect(() => { @@ -81,8 +80,8 @@ const GenerateBasemap = ({ projectInfo }) => { GenerateProjectTiles( `${ import.meta.env.VITE_API_URL - }/projects/tiles/${decodedId}?source=${selectedTileSource}&format=${selectedOutputFormat}&tms=${tmsUrl}`, - decodedId, + }/projects/tiles/${id}?source=${selectedTileSource}&format=${selectedOutputFormat}&tms=${tmsUrl}`, + id, ), ); } diff --git a/src/frontend/src/components/ProjectDetailsV2/ActivitiesPanel.tsx b/src/frontend/src/components/ProjectDetailsV2/ActivitiesPanel.tsx index 733983eedb..49b1611fc2 100644 --- a/src/frontend/src/components/ProjectDetailsV2/ActivitiesPanel.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/ActivitiesPanel.tsx @@ -1,6 +1,5 @@ /* eslint-disable react/jsx-key */ import React, { useEffect, useState } from 'react'; -import environment from '@/environment'; import AssetModules from '@/shared/AssetModules'; import { Feature } from 'ol'; import { Polygon } from 'ol/geom'; @@ -23,7 +22,7 @@ const ActivitiesPanel = ({ defaultTheme, state, params, map, view, mapDivPostion }; useEffect(() => { - const index = state.findIndex((project) => project.id == environment.decode(params.id)); + const index = state.findIndex((project) => project.id == params.id); let taskHistories: taskHistoryListType[] = []; if (index != -1) { diff --git a/src/frontend/src/components/ProjectDetailsV2/Comments.tsx b/src/frontend/src/components/ProjectDetailsV2/Comments.tsx index 24f84b79f9..8690ef392d 100644 --- a/src/frontend/src/components/ProjectDetailsV2/Comments.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/Comments.tsx @@ -4,7 +4,6 @@ import Button from '@/components/common/Button'; import { PostProjectComments, GetProjectComments } from '@/api/Project'; import { useDispatch } from 'react-redux'; import { useParams } from 'react-router-dom'; -import environment from '@/environment'; import { useAppSelector } from '@/types/reduxTypes'; import AssetModules from '@/shared/AssetModules'; import { ProjectCommentsSekeletonLoader } from '@/components/ProjectDetailsV2/SkeletonLoader'; @@ -21,7 +20,7 @@ const Comments = () => { const projectPostCommentsLoading = useAppSelector((state) => state?.project?.projectPostCommentsLoading); const selectedTask = useAppSelector((state) => state.task.selectedTask); - const projectId = environment.decode(params.id); + const projectId = params.id; useEffect(() => { dispatch( diff --git a/src/frontend/src/components/ProjectDetailsV2/ProjectOptions.tsx b/src/frontend/src/components/ProjectDetailsV2/ProjectOptions.tsx index c57cc5fd24..34780a07bb 100644 --- a/src/frontend/src/components/ProjectDetailsV2/ProjectOptions.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/ProjectOptions.tsx @@ -1,7 +1,6 @@ import React from 'react'; import CoreModules from '@/shared/CoreModules'; import AssetModules from '@/shared/AssetModules'; -import environment from '@/environment'; import { DownloadDataExtract, DownloadProjectForm } from '@/api/Project'; import { ProjectActions } from '@/store/slices/ProjectSlice'; import Button from '@/components/common/Button'; @@ -20,31 +19,30 @@ const ProjectOptions = () => { (state) => state.project.downloadDataExtractLoading, ); - const encodedId: string = params.id; - const decodedId: number = environment.decode(encodedId); + const projectId: string = params.id; const handleDownload = (downloadType) => { if (downloadType === 'form') { dispatch( DownloadProjectForm( - `${import.meta.env.VITE_API_URL}/projects/download-form/${decodedId}/`, + `${import.meta.env.VITE_API_URL}/projects/download-form/${projectId}/`, downloadType, - decodedId, + projectId, ), ); } else if (downloadType === 'geojson') { dispatch( DownloadProjectForm( - `${import.meta.env.VITE_API_URL}/projects/${decodedId}/download_tasks`, + `${import.meta.env.VITE_API_URL}/projects/${projectId}/download_tasks`, downloadType, - decodedId, + projectId, ), ); } }; const onDataExtractDownload = () => { dispatch( - DownloadDataExtract(`${import.meta.env.VITE_API_URL}/projects/features/download/?project_id=${decodedId}`), + DownloadDataExtract(`${import.meta.env.VITE_API_URL}/projects/features/download/?project_id=${projectId}`), ); }; return ( @@ -108,7 +106,7 @@ const ProjectOptions = () => { Generate MbTiles navigate(`/manage-project/${encodedId}`)} + onClick={() => navigate(`/manage-project/${projectId}`)} variant="contained" color="error" sx={{ width: '200px', mr: '15px' }} @@ -118,7 +116,7 @@ const ProjectOptions = () => { Manage Project navigate(`/project-submissions/${encodedId}`)} + onClick={() => navigate(`/project-submissions/${projectId}`)} variant="contained" color="error" sx={{ width: '200px', mr: '15px' }} diff --git a/src/frontend/src/components/ProjectDetailsV2/TaskSectionPopup.tsx b/src/frontend/src/components/ProjectDetailsV2/TaskSectionPopup.tsx index 979c459fcf..79cc638c35 100644 --- a/src/frontend/src/components/ProjectDetailsV2/TaskSectionPopup.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/TaskSectionPopup.tsx @@ -19,7 +19,7 @@ const TaskSectionPopup = ({ taskId, body, feature }: TaskSectionPopupPropType) = const [task_status, set_task_status] = useState('READY'); const taskModalStatus = CoreModules.useAppSelector((state) => state.project.taskModalStatus); const params = CoreModules.useParams(); - const currentProjectId = environment.decode(params.id); + const currentProjectId = params.id; const projectData = CoreModules.useAppSelector((state) => state.project.projectTaskBoundries); const projectIndex = projectData.findIndex((project) => project.id == currentProjectId); diff --git a/src/frontend/src/components/ProjectSubmissions/ProjectInfo.tsx b/src/frontend/src/components/ProjectSubmissions/ProjectInfo.tsx index 689efe8aa2..4359cadd23 100644 --- a/src/frontend/src/components/ProjectSubmissions/ProjectInfo.tsx +++ b/src/frontend/src/components/ProjectSubmissions/ProjectInfo.tsx @@ -7,7 +7,7 @@ import { projectDashboardDetailTypes, projectInfoType } from '@/models/project/p const ProjectInfo = () => { const navigate = useNavigate(); const params = CoreModules.useParams(); - const encodedId = params.projectId; + const projectId = params.projectId; const projectInfo: projectInfoType = CoreModules.useAppSelector((state) => state.project.projectInfo); const projectDashboardDetail: projectDashboardDetailTypes = CoreModules.useAppSelector( (state) => state.project.projectDashboardDetail, @@ -55,7 +55,7 @@ const ProjectInfo = () => {

navigate(`/project_details/${encodedId}`)} + onClick={() => navigate(`/project_details/${projectId}`)} > {projectInfo?.title}{' '} diff --git a/src/frontend/src/components/ProjectSubmissions/SubmissionsInfographics.tsx b/src/frontend/src/components/ProjectSubmissions/SubmissionsInfographics.tsx index 7793468175..decd2f2ebd 100644 --- a/src/frontend/src/components/ProjectSubmissions/SubmissionsInfographics.tsx +++ b/src/frontend/src/components/ProjectSubmissions/SubmissionsInfographics.tsx @@ -11,7 +11,6 @@ import { ProjectSubmissionInfographicsService, ValidatedVsMappedInfographicsService, } from '@/api/SubmissionService'; -import environment from '@/environment'; import { submissionContributorsTypes, submissionInfographicsTypes, @@ -96,8 +95,7 @@ const SubmissionsInfographics = ({ toggleView }) => { const dispatch = CoreModules.useAppDispatch(); const params = CoreModules.useParams(); - const encodedId = params.projectId; - const decodedId = environment.decode(encodedId); + const projectId = params.projectId; const submissionInfographicsData: submissionInfographicsTypes[] = CoreModules.useAppSelector( (state) => state.submission.submissionInfographics, @@ -124,19 +122,19 @@ const SubmissionsInfographics = ({ toggleView }) => { useEffect(() => { dispatch( ProjectSubmissionInfographicsService( - `${import.meta.env.VITE_API_URL}/submission/submission_page/${decodedId}?days=${submissionProjection}`, + `${import.meta.env.VITE_API_URL}/submission/submission_page/${projectId}?days=${submissionProjection}`, ), ); }, [submissionProjection]); useEffect(() => { dispatch( - ValidatedVsMappedInfographicsService(`${import.meta.env.VITE_API_URL}/tasks/activity/?project_id=${decodedId}`), + ValidatedVsMappedInfographicsService(`${import.meta.env.VITE_API_URL}/tasks/activity/?project_id=${projectId}`), ); }, []); useEffect(() => { - dispatch(ProjectContributorsService(`${import.meta.env.VITE_API_URL}/projects/contributors/${decodedId}`)); + dispatch(ProjectContributorsService(`${import.meta.env.VITE_API_URL}/projects/contributors/${projectId}`)); }, []); const FormSubmissionSubHeader = () => ( diff --git a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx index 2cafde9e42..a70e19ec68 100644 --- a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx +++ b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx @@ -5,7 +5,6 @@ import windowDimention from '@/hooks/WindowDimension'; import Table, { TableHeader } from '@/components/common/CustomTable'; import { SubmissionFormFieldsService, SubmissionTableService } from '@/api/SubmissionService'; import CoreModules from '@/shared/CoreModules.js'; -import environment from '@/environment'; import { SubmissionsTableSkeletonLoader } from '@/components/ProjectSubmissions/ProjectSubmissionsSkeletonLoader.js'; import { Loader2 } from 'lucide-react'; import { SubmissionActions } from '@/store/slices/SubmissionSlice'; @@ -46,8 +45,7 @@ const SubmissionsTable = ({ toggleView }) => { const params = CoreModules.useParams(); const navigate = useNavigate(); - const encodedId = params.projectId; - const decodedId = environment.decode(encodedId); + const projectId = params.projectId; const submissionFormFields = useAppSelector((state) => state.submission.submissionFormFields); const submissionTableData = useAppSelector((state) => state.submission.submissionTableData); const submissionFormFieldsLoading = useAppSelector((state) => state.submission.submissionFormFieldsLoading); @@ -96,21 +94,21 @@ const SubmissionsTable = ({ toggleView }) => { useEffect(() => { dispatch( - SubmissionFormFieldsService(`${import.meta.env.VITE_API_URL}/submission/submission_form_fields/${decodedId}`), + SubmissionFormFieldsService(`${import.meta.env.VITE_API_URL}/submission/submission_form_fields/${projectId}`), ); }, []); useEffect(() => { if (!filter.task_id) { dispatch( - SubmissionTableService(`${import.meta.env.VITE_API_URL}/submission/submission_table/${decodedId}`, { + SubmissionTableService(`${import.meta.env.VITE_API_URL}/submission/submission_table/${projectId}`, { page: paginationPage, ...filter, }), ); } else { dispatch( - SubmissionTableService(`${import.meta.env.VITE_API_URL}/submission/task_submissions/${decodedId}`, { + SubmissionTableService(`${import.meta.env.VITE_API_URL}/submission/task_submissions/${projectId}`, { page: paginationPage, ...filter, }), @@ -124,19 +122,19 @@ const SubmissionsTable = ({ toggleView }) => { const refreshTable = () => { dispatch( - SubmissionFormFieldsService(`${import.meta.env.VITE_API_URL}/submission/submission_form_fields/${decodedId}`), + SubmissionFormFieldsService(`${import.meta.env.VITE_API_URL}/submission/submission_form_fields/${projectId}`), ); dispatch(SubmissionActions.SetSubmissionTableRefreshing(true)); if (!filter.task_id) { dispatch( - SubmissionTableService(`${import.meta.env.VITE_API_URL}/submission/submission_table/${decodedId}`, { + SubmissionTableService(`${import.meta.env.VITE_API_URL}/submission/submission_table/${projectId}`, { page: paginationPage, ...filter, }), ); } else { dispatch( - SubmissionTableService(`${import.meta.env.VITE_API_URL}/submission/task_submissions/${decodedId}`, { + SubmissionTableService(`${import.meta.env.VITE_API_URL}/submission/task_submissions/${projectId}`, { page: paginationPage, ...filter, }), @@ -198,7 +196,7 @@ const SubmissionsTable = ({ toggleView }) => { const uploadToJOSM = () => { dispatch( ConvertXMLToJOSM( - `${import.meta.env.VITE_API_URL}/submission/get_osm_xml/${decodedId}`, + `${import.meta.env.VITE_API_URL}/submission/get_osm_xml/${projectId}`, projectInfo?.outline_geojson?.properties?.bbox, ), ); @@ -208,13 +206,13 @@ const SubmissionsTable = ({ toggleView }) => { if (downloadType === 'csv') { dispatch( getDownloadProjectSubmission( - `${import.meta.env.VITE_API_URL}/submission/download?project_id=${decodedId}&export_json=false`, + `${import.meta.env.VITE_API_URL}/submission/download?project_id=${projectId}&export_json=false`, ), ); } else if (downloadType === 'json') { dispatch( getDownloadProjectSubmissionJson( - `${import.meta.env.VITE_API_URL}/submission/download-submission?project_id=${decodedId}`, + `${import.meta.env.VITE_API_URL}/submission/download-submission?project_id=${projectId}`, ), ); } @@ -447,7 +445,7 @@ const SubmissionsTable = ({ toggleView }) => { { - navigate(`/project/${encodedId}/tasks/${row?.phonenumber}/submission/${row?.meta?.instanceID}`); + navigate(`/project/${projectId}/tasks/${row?.phonenumber}/submission/${row?.meta?.instanceID}`); }} />{' '} {' '} diff --git a/src/frontend/src/components/createnewproject/SplitTasks.tsx b/src/frontend/src/components/createnewproject/SplitTasks.tsx index c7be28b76b..fc22ae03e7 100644 --- a/src/frontend/src/components/createnewproject/SplitTasks.tsx +++ b/src/frontend/src/components/createnewproject/SplitTasks.tsx @@ -17,7 +17,6 @@ import { GetDividedTaskFromGeojson, TaskSplittingPreviewService, } from '@/api/CreateProjectService'; -import environment from '@/environment'; import { Modal } from '@/components/common/Modal'; import ProgressBar from '@/components/common/ProgressBar'; import { task_split_type } from '@/types/enums'; @@ -211,7 +210,7 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customDataExtractUpload ); } else if (generateQrSuccess && generateProjectLog?.status === 'SUCCESS') { clearInterval(generateProjectLogIntervalCb); - const encodedProjectId = environment.encode(projectDetailsResponse?.id); + const projectId = projectDetailsResponse?.id; dispatch( CommonActions.SetSnackBar({ open: true, @@ -222,7 +221,7 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customDataExtractUpload ); dispatch(CreateProjectActions.SetGenerateProjectLog(null)); dispatch(CreateProjectActions.SetGenerateProjectQRSuccess(null)); - navigate(`/project_details/${encodedProjectId}`); + navigate(`/project_details/${projectId}`); dispatch(CreateProjectActions.ClearCreateProjectFormData()); dispatch(CreateProjectActions.SetCanSwitchCreateProjectSteps(false)); } diff --git a/src/frontend/src/components/home/ExploreProjectCard.tsx b/src/frontend/src/components/home/ExploreProjectCard.tsx index 2ed4e86ed7..bdb1408fdc 100755 --- a/src/frontend/src/components/home/ExploreProjectCard.tsx +++ b/src/frontend/src/components/home/ExploreProjectCard.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import CustomizedImage from '@/utilities/CustomizedImage'; import CustomizedProgressBar from '@/utilities/CustomizedProgressBar'; -import environment from '@/environment'; import { HomeActions } from '@/store/slices/HomeSlice'; import { HomeProjectCardModel, projectType } from '@/models/home/homeModel'; import CoreModules from '@/shared/CoreModules'; @@ -60,7 +59,7 @@ export default function ExploreProjectCard({ data }: { data: projectType }) { const project: projectType = data; // dispatch(ProjectActions.SetProjectTaskBoundries([])) dispatch(HomeActions.SetSelectedProject(project)); - navigate(`/project_details/${environment.encode(data.id)}`); + navigate(`/project_details/${data.id}`); }} style={cardInnerStyles.card} sx={{ boxShadow: 0 }} diff --git a/src/frontend/src/components/home/ProjectListMap.tsx b/src/frontend/src/components/home/ProjectListMap.tsx index 81703e08e9..a2797d9f77 100644 --- a/src/frontend/src/components/home/ProjectListMap.tsx +++ b/src/frontend/src/components/home/ProjectListMap.tsx @@ -8,7 +8,6 @@ import { geojsonObjectModel } from '@/constants/geojsonObjectModal'; import { defaultStyles, getStyles } from '@/components/MapComponent/OpenLayersComponent/helpers/styleUtils'; import MarkerIcon from '@/assets/images/red_marker.png'; import { useNavigate } from 'react-router-dom'; -import environment from '@/environment'; import { Style, Text, Icon, Fill } from 'ol/style'; import { projectType } from '@/models/home/homeModel'; @@ -74,8 +73,8 @@ const ProjectListMap = () => { }, [homeProjectSummary]); const projectClickOnMap = (properties: any) => { - const encodedProjectId = environment.encode(properties.id); - navigate(`/project_details/${encodedProjectId}`); + const projectId = properties.id; + navigate(`/project_details/${projectId}`); }; return ( diff --git a/src/frontend/src/views/ManageProject.tsx b/src/frontend/src/views/ManageProject.tsx index a46faa3449..ccca1e905c 100644 --- a/src/frontend/src/views/ManageProject.tsx +++ b/src/frontend/src/views/ManageProject.tsx @@ -4,7 +4,6 @@ import DeleteTab from '../components/ManageProject/DeleteTab'; import React, { useEffect, useState } from 'react'; import AssetModules from '../shared/AssetModules.js'; import CoreModules from '@/shared/CoreModules'; -import environment from '@/environment'; import { GetIndividualProjectDetails } from '@/api/CreateProjectService'; import { useNavigate } from 'react-router-dom'; import { useAppSelector } from '@/types/reduxTypes'; @@ -18,14 +17,13 @@ const ManageProject = () => { const dispatch = CoreModules.useAppDispatch(); const params = CoreModules.useParams(); const navigate = useNavigate(); - const encodedProjectId = params.id; - const decodedProjectId = environment.decode(encodedProjectId); + const projectId = params.id; const [tabView, setTabView] = useState<'users' | 'edit' | string>('users'); const editProjectDetails = useAppSelector((state) => state.createproject.editProjectDetails); useEffect(() => { - dispatch(GetIndividualProjectDetails(`${import.meta.env.VITE_API_URL}/projects/${decodedProjectId}`)); - }, [decodedProjectId]); + dispatch(GetIndividualProjectDetails(`${import.meta.env.VITE_API_URL}/projects/${projectId}`)); + }, [projectId]); return (

@@ -59,9 +57,9 @@ const ManageProject = () => { {tabView === 'users' ? ( ) : tabView === 'edit' ? ( - + ) : ( - + )}
diff --git a/src/frontend/src/views/ProjectDetailsV2.tsx b/src/frontend/src/views/ProjectDetailsV2.tsx index 52419a631a..e3c89ef05f 100644 --- a/src/frontend/src/views/ProjectDetailsV2.tsx +++ b/src/frontend/src/views/ProjectDetailsV2.tsx @@ -4,7 +4,6 @@ import '../styles/home.scss'; import WindowDimension from '@/hooks/WindowDimension'; // import MapDescriptionComponents from '@/components/MapDescriptionComponents'; import ActivitiesPanel from '@/components/ProjectDetailsV2/ActivitiesPanel'; -import environment from '@/environment'; import { ProjectById, GetProjectDashboard } from '@/api/Project'; import { ProjectActions } from '@/store/slices/ProjectSlice'; import CustomizedSnackbar from '@/utilities/CustomizedSnackbar'; @@ -65,8 +64,7 @@ const Home = () => { const [positionGeojson, setPositionGeojson] = useState(null); const [deviceRotation, setDeviceRotation] = useState(0); const [viewState, setViewState] = useState('project_info'); - const encodedId: string = params.id; - const decodedId = environment.decode(encodedId); + const projectId: string = params.id; const defaultTheme = useAppSelector((state) => state.theme.hotTheme); const state = CoreModules.useAppSelector((state) => state.project); const projectInfo = useAppSelector((state) => state.home.selectedProject); @@ -97,17 +95,17 @@ const Home = () => { //Fetch project for the first time useEffect(() => { dispatch(ProjectActions.SetNewProjectTrigger()); - if (state.projectTaskBoundries.findIndex((project) => project.id == environment.decode(encodedId)) == -1) { + if (state.projectTaskBoundries.findIndex((project) => project.id == projectId) == -1) { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, environment.decode(encodedId))); + dispatch(ProjectById(state.projectTaskBoundries, projectId)); } else { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, environment.decode(encodedId))); + dispatch(ProjectById(state.projectTaskBoundries, projectId)); } if (Object.keys(state.projectInfo)?.length == 0) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); } else { - if (state.projectInfo.id != environment.decode(encodedId)) { + if (state.projectInfo.id != projectId) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); } } @@ -223,7 +221,7 @@ const Home = () => { }, [taskModalStatus]); useEffect(() => { - dispatch(GetProjectDashboard(`${import.meta.env.VITE_API_URL}/projects/project_dashboard/${decodedId}`)); + dispatch(GetProjectDashboard(`${import.meta.env.VITE_API_URL}/projects/project_dashboard/${projectId}`)); }, []); useEffect(async () => { @@ -351,7 +349,7 @@ const Home = () => { btnText="VIEW INFOGRAPHICS" btnType="other" className="hover:fmtm-text-red-700 fmtm-border-red-700 !fmtm-rounded-md fmtm-my-2" - onClick={() => navigate(`/project-submissions/${encodedId}`)} + onClick={() => navigate(`/project-submissions/${projectId}`)} />
handleToggle()}> diff --git a/src/frontend/src/views/ProjectSubmissions.tsx b/src/frontend/src/views/ProjectSubmissions.tsx index 560a623a3d..605a4a9eac 100644 --- a/src/frontend/src/views/ProjectSubmissions.tsx +++ b/src/frontend/src/views/ProjectSubmissions.tsx @@ -6,7 +6,6 @@ import SubmissionsTable from '@/components/ProjectSubmissions/SubmissionsTable.j import CoreModules from '@/shared/CoreModules'; import { ProjectActions } from '@/store/slices/ProjectSlice'; import { ProjectById } from '@/api/Project'; -import environment from '@/environment'; import { fetchInfoTask } from '@/api/task'; import { GetProjectDashboard } from '@/api/Project'; import { useSearchParams } from 'react-router-dom'; @@ -17,8 +16,7 @@ const ProjectSubmissions = () => { const params = CoreModules.useParams(); const [searchParams, setSearchParams] = useSearchParams(); - const encodedId = params.projectId; - const decodedId = environment.decode(encodedId); + const projectId = params.projectId; const state = CoreModules.useAppSelector((state) => state.project); const projectInfo: projectInfoType = CoreModules.useAppSelector((state) => state.project.projectInfo); @@ -26,17 +24,17 @@ const ProjectSubmissions = () => { //Fetch project for the first time useEffect(() => { dispatch(ProjectActions.SetNewProjectTrigger()); - if (state.projectTaskBoundries.findIndex((project) => project.id == environment.decode(encodedId)) == -1) { + if (state.projectTaskBoundries.findIndex((project) => project.id == projectId) == -1) { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, environment.decode(encodedId))); + dispatch(ProjectById(state.projectTaskBoundries, projectId)); } else { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, environment.decode(encodedId))); + dispatch(ProjectById(state.projectTaskBoundries, projectId)); } if (Object.keys(state.projectInfo).length == 0) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); } else { - if (state.projectInfo.id != environment.decode(encodedId)) { + if (state.projectInfo.id != projectId) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); } } @@ -44,13 +42,13 @@ const ProjectSubmissions = () => { useEffect(() => { const fetchData = () => { - dispatch(fetchInfoTask(`${import.meta.env.VITE_API_URL}/tasks/features/?project_id=${decodedId}`)); + dispatch(fetchInfoTask(`${import.meta.env.VITE_API_URL}/tasks/features/?project_id=${projectId}`)); }; fetchData(); }, []); useEffect(() => { - dispatch(GetProjectDashboard(`${import.meta.env.VITE_API_URL}/projects/project_dashboard/${decodedId}`)); + dispatch(GetProjectDashboard(`${import.meta.env.VITE_API_URL}/projects/project_dashboard/${projectId}`)); }, []); useEffect(() => { diff --git a/src/frontend/src/views/SubmissionDetails.tsx b/src/frontend/src/views/SubmissionDetails.tsx index 5276569263..6abd07dee1 100644 --- a/src/frontend/src/views/SubmissionDetails.tsx +++ b/src/frontend/src/views/SubmissionDetails.tsx @@ -1,6 +1,5 @@ import CoreModules from '@/shared/CoreModules.js'; import React, { useEffect } from 'react'; -import environment from '@/environment'; import { SubmissionService } from '@/api/Submission'; import SubmissionInstanceMap from '@/components/SubmissionMap/SubmissionInstanceMap'; import { GetProjectDashboard } from '@/api/Project'; @@ -14,8 +13,7 @@ const SubmissionDetails = () => { const dispatch = CoreModules.useAppDispatch(); const params = CoreModules.useParams(); const navigate = useNavigate(); - const encodedProjectId = params.projectId; - const decodedProjectId = environment.decode(encodedProjectId); + const projectId = params.projectId; const taskId = params.taskId; const paramsInstanceId = params.instanceId; const projectDashboardDetail = CoreModules.useAppSelector((state) => state.project.projectDashboardDetail); @@ -25,7 +23,7 @@ const SubmissionDetails = () => { const submissionDetailsLoading = useAppSelector((state) => state.submission.submissionDetailsLoading); useEffect(() => { - dispatch(GetProjectDashboard(`${import.meta.env.VITE_API_URL}/projects/project_dashboard/${decodedProjectId}`)); + dispatch(GetProjectDashboard(`${import.meta.env.VITE_API_URL}/projects/project_dashboard/${projectId}`)); }, []); useEffect(() => { @@ -33,10 +31,10 @@ const SubmissionDetails = () => { SubmissionService( `${ import.meta.env.VITE_API_URL - }/submission/task_submissions/${decodedProjectId}?task_id=${taskId}&submission_id=${paramsInstanceId}`, + }/submission/task_submissions/${projectId}?task_id=${taskId}&submission_id=${paramsInstanceId}`, ), ); - }, [decodedProjectId, taskId, paramsInstanceId]); + }, [projectId, taskId, paramsInstanceId]); function removeNullValues(obj) { const newObj = {}; @@ -123,14 +121,14 @@ const SubmissionDetails = () => {

navigate(`/project_details/${encodedProjectId}`)} + onClick={() => navigate(`/project_details/${projectId}`)} > {projectDashboardDetail?.project_name_prefix} > navigate(`/project-submissions/${encodedProjectId}?tab=table`)} + onClick={() => navigate(`/project-submissions/${projectId}?tab=table`)} > Dashboard diff --git a/src/frontend/src/views/Submissions.tsx b/src/frontend/src/views/Submissions.tsx index 1e08cb1d08..6ade0fdd7f 100755 --- a/src/frontend/src/views/Submissions.tsx +++ b/src/frontend/src/views/Submissions.tsx @@ -6,7 +6,6 @@ import CoreModules from '@/shared/CoreModules'; // import { useLocation, useNavigate } from 'react-router-dom'; import Avatar from '@/assets/images/avatar.png'; // import SubmissionMap from '@/components/SubmissionMap/SubmissionMap'; -import environment from '@/environment'; import { ProjectActions } from '@/store/slices/ProjectSlice'; import { ProjectById } from '@/api/Project'; @@ -19,27 +18,26 @@ const Submissions = () => { // const projectTaskBoundries = CoreModules.useAppSelector((state) => state.project.projectTaskBoundries); // const projectBuildingGeojson = CoreModules.useAppSelector((state) => state.project.projectBuildingGeojson); const params = CoreModules.useParams(); - const encodedId = params.id; - const decodedId = environment.decode(encodedId); + const projectId = params.id; // const theme = CoreModules.useAppSelector(state => state.theme.hotTheme) useEffect(() => { - dispatch(ProjectSubmissionService(`${import.meta.env.VITE_API_URL}/submission/?project_id=${decodedId}`)); - // dispatch(ProjectDataExtractService(`${import.meta.env.VITE_API_URL}/projects/${decodedId}/features`)); + dispatch(ProjectSubmissionService(`${import.meta.env.VITE_API_URL}/submission/?project_id=${projectId}`)); + // dispatch(ProjectDataExtractService(`${import.meta.env.VITE_API_URL}/projects/${projectId}/features`)); //creating a manual thunk that will make an API call then autamatically perform state mutation whenever we navigate to home page }, []); // Requesting Task Boundaries on Page Load useEffect(() => { - if (state.projectTaskBoundries.findIndex((project) => project.id == environment.decode(encodedId)) == -1) { - dispatch(ProjectById(state.projectTaskBoundries, environment.decode(encodedId))); + if (state.projectTaskBoundries.findIndex((project) => project.id == projectId) == -1) { + dispatch(ProjectById(state.projectTaskBoundries, projectId)); } else { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, environment.decode(encodedId))); + dispatch(ProjectById(state.projectTaskBoundries, projectId)); } if (Object.keys(state.projectInfo).length == 0) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); } else { - if (state.projectInfo.id != environment.decode(encodedId)) { + if (state.projectInfo.id != projectId) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); } } @@ -66,7 +64,7 @@ const Submissions = () => { Convert - + Download CSV diff --git a/src/frontend/src/views/Tasks.tsx b/src/frontend/src/views/Tasks.tsx index 405eae3065..a4ee1243cf 100644 --- a/src/frontend/src/views/Tasks.tsx +++ b/src/frontend/src/views/Tasks.tsx @@ -8,7 +8,6 @@ import AssetModules from '@/shared/AssetModules'; // import { styled, alpha } from '@mui/material'; import Avatar from '@/assets/images/avatar.png'; -import environment from '@/environment'; import { ProjectSubmissionService } from '@/api/SubmissionService'; import { ProjectActions } from '@/store/slices/ProjectSlice'; import { ProjectById } from '@/api/Project'; @@ -28,41 +27,37 @@ const TasksSubmission = () => { // const projectTaskBoundries = CoreModules.useAppSelector((state) => state.project.projectTaskBoundries); // const projectBuildingGeojson = CoreModules.useAppSelector((state) => state.project.projectBuildingGeojson); const params = CoreModules.useParams(); - const encodedProjectId = params.projectId; - const decodedProjectId = environment.decode(encodedProjectId); - const encodedTaskId = params.taskId; - const decodedTaskId = environment.decode(encodedTaskId); + const projectId = params.projectId; + const taskId = params.taskId; // const theme = CoreModules.useAppSelector(state => state.theme.hotTheme) useEffect(() => { dispatch( - ProjectSubmissionService( - `${import.meta.env.VITE_API_URL}/submission/?project_id=${decodedProjectId}&task_id=${decodedTaskId}`, - ), + ProjectSubmissionService(`${import.meta.env.VITE_API_URL}/submission/?project_id=${projectId}&task_id=${taskId}`), ); // dispatch( // ProjectDataExtractService( - // `${import.meta.env.VITE_API_URL}/projects/${decodedProjectId}/features?task_id=${decodedTaskId}`, + // `${import.meta.env.VITE_API_URL}/projects/${projectId}/features?task_id=${taskId}`, // ), // ); //creating a manual thunk that will make an API call then autamatically perform state mutation whenever we navigate to home page }, []); //Fetch project for the first time useEffect(() => { - if (state.projectTaskBoundries.findIndex((project) => project.id == environment.decode(encodedProjectId)) == -1) { - dispatch(ProjectById(state.projectTaskBoundries, environment.decode(encodedProjectId))); + if (state.projectTaskBoundries.findIndex((project) => project.id == projectId) == -1) { + dispatch(ProjectById(state.projectTaskBoundries, projectId)); // dispatch( // ProjectDataExtractService( - // `${import.meta.env.VITE_API_URL}/projects/${environment.decode(encodedProjectId)}/features`, + // `${import.meta.env.VITE_API_URL}/projects/${projectId}/features`, // ), // ); } else { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, environment.decode(encodedProjectId))); + dispatch(ProjectById(state.projectTaskBoundries, projectId)); } if (Object.keys(state.projectInfo).length == 0) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); } else { - if (state.projectInfo.id != environment.decode(encodedProjectId)) { + if (state.projectInfo.id != projectId) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); } } @@ -77,7 +72,7 @@ const TasksSubmission = () => { ...basicGeojsonTemplate, features: [ ...projectTaskBoundries?.[0]?.taskBoundries - ?.filter((task) => task.id === decodedTaskId) + ?.filter((task) => task.id == taskId) .map((task) => ({ ...task.outline_geojson, id: task.outline_geojson.properties.uid, @@ -91,7 +86,7 @@ const TasksSubmission = () => { ...basicGeojsonTemplate, features: [ ...projectBuildingGeojson - ?.filter((task) => task.task_id === decodedTaskId) + ?.filter((task) => task.task_id == taskId) .map((task) => ({ ...task.geometry, id: task.id })), ], // features: projectBuildingGeojson.map((feature) => ({ ...feature.geometry, id: feature.id })) @@ -144,7 +139,7 @@ const TasksSubmission = () => { getDownloadProjectSubmission( `${ import.meta.env.VITE_API_URL - }/submission/download?project_id=${decodedProjectId}&task_id=${decodedTaskId}&export_json=false`, + }/submission/download?project_id=${projectId}&task_id=${taskId}&export_json=false`, ), ); } else if (downloadType === 'json') { @@ -152,7 +147,7 @@ const TasksSubmission = () => { getDownloadProjectSubmission( `${ import.meta.env.VITE_API_URL - }/submission/download?project_id=${decodedProjectId}&task_id=${decodedTaskId}&export_json=true`, + }/submission/download?project_id=${projectId}&task_id=${taskId}&export_json=true`, ), ); } @@ -241,7 +236,7 @@ const TasksSubmission = () => { key={submission.id} style={{ textDecoration: 'auto' }} className="submission-item" - to={`/project/${encodedProjectId}/tasks/${encodedTaskId}/submission/${submission.instanceId}`} + to={`/project/${projectId}/tasks/${taskId}/submission/${submission.instanceId}`} >