From 2e6a6f1953a3cc4f445ca121fb6a26ba4a61f5de Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Wed, 7 Aug 2024 14:11:07 +0545 Subject: [PATCH 01/35] fix(project): convert js to ts --- src/frontend/src/api/{Project.js => Project.ts} | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) rename src/frontend/src/api/{Project.js => Project.ts} (98%) diff --git a/src/frontend/src/api/Project.js b/src/frontend/src/api/Project.ts similarity index 98% rename from src/frontend/src/api/Project.js rename to src/frontend/src/api/Project.ts index e0af1a0d56..ec49fdec2f 100755 --- a/src/frontend/src/api/Project.js +++ b/src/frontend/src/api/Project.ts @@ -2,12 +2,11 @@ import { ProjectActions } from '@/store/slices/ProjectSlice'; import { CommonActions } from '@/store/slices/CommonSlice'; import CoreModules from '@/shared/CoreModules'; import { task_status } from '@/types/enums'; -import axios from 'axios'; import { writeBinaryToOPFS } from '@/api/Files'; -export const ProjectById = (existingProjectList, projectId) => { +export const ProjectById = (projectId) => { return async (dispatch) => { - const fetchProjectById = async (projectId, existingProjectList) => { + const fetchProjectById = async (projectId) => { try { dispatch(ProjectActions.SetProjectDetialsLoading(true)); const project = await CoreModules.axios.get(`${import.meta.env.VITE_API_URL}/projects/${projectId}`); @@ -65,7 +64,7 @@ export const ProjectById = (existingProjectList, projectId) => { } }; - await fetchProjectById(projectId, existingProjectList); + await fetchProjectById(projectId); dispatch(ProjectActions.SetNewProjectTrigger()); }; }; From f271f1fa9f7efccf12aaf74d0a24dd41bfed5956 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Wed, 7 Aug 2024 14:13:16 +0545 Subject: [PATCH 02/35] fix(projectById): remove first argument from projectById action --- src/frontend/src/views/ProjectDetailsV2.tsx | 4 ++-- src/frontend/src/views/ProjectSubmissions.tsx | 4 ++-- src/frontend/src/views/Submissions.tsx | 4 ++-- src/frontend/src/views/Tasks.tsx | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/frontend/src/views/ProjectDetailsV2.tsx b/src/frontend/src/views/ProjectDetailsV2.tsx index 9b23bf358a..7327fafa68 100644 --- a/src/frontend/src/views/ProjectDetailsV2.tsx +++ b/src/frontend/src/views/ProjectDetailsV2.tsx @@ -105,10 +105,10 @@ const ProjectDetailsV2 = () => { dispatch(ProjectActions.SetNewProjectTrigger()); if (state.projectTaskBoundries.findIndex((project) => project.id.toString() === projectId) == -1) { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, projectId)); + dispatch(ProjectById(projectId)); } else { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, projectId)); + dispatch(ProjectById(projectId)); } if (Object.keys(state.projectInfo)?.length == 0) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); diff --git a/src/frontend/src/views/ProjectSubmissions.tsx b/src/frontend/src/views/ProjectSubmissions.tsx index 56ba67c078..afa74d3c7d 100644 --- a/src/frontend/src/views/ProjectSubmissions.tsx +++ b/src/frontend/src/views/ProjectSubmissions.tsx @@ -27,10 +27,10 @@ const ProjectSubmissions = () => { dispatch(ProjectActions.SetNewProjectTrigger()); if (state.projectTaskBoundries.findIndex((project) => project.id == projectId) == -1) { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, projectId)); + dispatch(ProjectById(projectId)); } else { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, projectId)); + dispatch(ProjectById(projectId)); } if (Object.keys(state.projectInfo).length == 0) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); diff --git a/src/frontend/src/views/Submissions.tsx b/src/frontend/src/views/Submissions.tsx index 6ade0fdd7f..b8fa478d95 100755 --- a/src/frontend/src/views/Submissions.tsx +++ b/src/frontend/src/views/Submissions.tsx @@ -29,10 +29,10 @@ const Submissions = () => { // Requesting Task Boundaries on Page Load useEffect(() => { if (state.projectTaskBoundries.findIndex((project) => project.id == projectId) == -1) { - dispatch(ProjectById(state.projectTaskBoundries, projectId)); + dispatch(ProjectById(projectId)); } else { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, projectId)); + dispatch(ProjectById(projectId)); } if (Object.keys(state.projectInfo).length == 0) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); diff --git a/src/frontend/src/views/Tasks.tsx b/src/frontend/src/views/Tasks.tsx index a4ee1243cf..1d239e3add 100644 --- a/src/frontend/src/views/Tasks.tsx +++ b/src/frontend/src/views/Tasks.tsx @@ -44,7 +44,7 @@ const TasksSubmission = () => { //Fetch project for the first time useEffect(() => { if (state.projectTaskBoundries.findIndex((project) => project.id == projectId) == -1) { - dispatch(ProjectById(state.projectTaskBoundries, projectId)); + dispatch(ProjectById(projectId)); // dispatch( // ProjectDataExtractService( // `${import.meta.env.VITE_API_URL}/projects/${projectId}/features`, @@ -52,7 +52,7 @@ const TasksSubmission = () => { // ); } else { dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(state.projectTaskBoundries, projectId)); + dispatch(ProjectById(projectId)); } if (Object.keys(state.projectInfo).length == 0) { dispatch(ProjectActions.SetProjectInfo(projectInfo)); From 279b955788789540be032f676200713ee6f0185e Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Wed, 7 Aug 2024 15:39:31 +0545 Subject: [PATCH 03/35] fix(projectOptions): types add --- .../src/components/ProjectDetailsV2/ProjectOptions.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/ProjectDetailsV2/ProjectOptions.tsx b/src/frontend/src/components/ProjectDetailsV2/ProjectOptions.tsx index 859534c334..31c96a182c 100644 --- a/src/frontend/src/components/ProjectDetailsV2/ProjectOptions.tsx +++ b/src/frontend/src/components/ProjectDetailsV2/ProjectOptions.tsx @@ -6,7 +6,7 @@ import Button from '@/components/common/Button'; import { useAppSelector } from '@/types/reduxTypes'; type projectOptionPropTypes = { - projectName: string | undefined; + projectName: string; }; const ProjectOptions = ({ projectName }: projectOptionPropTypes) => { @@ -19,7 +19,7 @@ const ProjectOptions = ({ projectName }: projectOptionPropTypes) => { const projectId: string = params.id; - const handleDownload = (downloadType) => { + const handleDownload = (downloadType: 'form' | 'geojson') => { if (downloadType === 'form') { dispatch( DownloadProjectForm( From a07b1c103a1737dedb1d774f255c33a612485423 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Wed, 7 Aug 2024 15:41:02 +0545 Subject: [PATCH 04/35] fix(project): ts types add to project services --- src/frontend/src/api/Project.ts | 79 ++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/src/frontend/src/api/Project.ts b/src/frontend/src/api/Project.ts index ec49fdec2f..99f4219c7e 100755 --- a/src/frontend/src/api/Project.ts +++ b/src/frontend/src/api/Project.ts @@ -3,15 +3,16 @@ import { CommonActions } from '@/store/slices/CommonSlice'; import CoreModules from '@/shared/CoreModules'; import { task_status } from '@/types/enums'; import { writeBinaryToOPFS } from '@/api/Files'; +import { projectInfoType } from '@/models/project/projectModel'; -export const ProjectById = (projectId) => { +export const ProjectById = (projectId: string) => { return async (dispatch) => { - const fetchProjectById = async (projectId) => { + const fetchProjectById = async (projectId: string) => { try { dispatch(ProjectActions.SetProjectDetialsLoading(true)); const project = await CoreModules.axios.get(`${import.meta.env.VITE_API_URL}/projects/${projectId}`); - const projectResp = project.data; - const persistingValues = projectResp.tasks.map((data) => { + const projectResp: Record = project.data; + const persistingValues: Record = projectResp.tasks.map((data) => { return { id: data.id, index: data.project_task_index, @@ -69,14 +70,14 @@ export const ProjectById = (projectId) => { }; }; -export const DownloadProjectForm = (url, payload, projectId) => { +export const DownloadProjectForm = (url: string, downloadType: 'form' | 'geojson', projectId: string) => { return async (dispatch) => { - dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: payload, loading: true })); + dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: downloadType, loading: true })); - const fetchProjectForm = async (url, payload, projectId) => { + const fetchProjectForm = async (url: string, downloadType: 'form' | 'geojson', projectId: string) => { try { let response; - if (payload === 'form') { + if (downloadType === 'form') { response = await CoreModules.axios.get(url, { responseType: 'blob' }); } else { response = await CoreModules.axios.get(url, { @@ -85,26 +86,28 @@ export const DownloadProjectForm = (url, payload, projectId) => { } const a = document.createElement('a'); a.href = window.URL.createObjectURL(response.data); - a.download = `${payload === 'form' ? `project_form_${projectId}.xls` : `task_polygons_${projectId}.geojson`}`; + a.download = `${ + downloadType === 'form' ? `project_form_${projectId}.xls` : `task_polygons_${projectId}.geojson` + }`; a.click(); - dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: payload, loading: false })); + dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: downloadType, loading: false })); } catch (error) { - dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: payload, loading: false })); + dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: downloadType, loading: false })); } finally { - dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: payload, loading: false })); + dispatch(ProjectActions.SetDownloadProjectFormLoading({ type: downloadType, loading: false })); } }; - await fetchProjectForm(url, payload, projectId); + await fetchProjectForm(url, downloadType, projectId); }; }; -export const DownloadDataExtract = (url, payload) => { + +export const DownloadDataExtract = (url: string) => { return async (dispatch) => { dispatch(ProjectActions.SetDownloadDataExtractLoading(true)); - const getDownloadExtract = async (url, payload) => { + const getDownloadExtract = async (url: string) => { try { let response; - response = await CoreModules.axios.get(url, { responseType: 'blob', }); @@ -119,14 +122,15 @@ export const DownloadDataExtract = (url, payload) => { dispatch(ProjectActions.SetDownloadDataExtractLoading(false)); } }; - await getDownloadExtract(url, payload); + await getDownloadExtract(url); }; }; -export const GetTilesList = (url) => { + +export const GetTilesList = (url: string) => { return async (dispatch) => { dispatch(ProjectActions.SetTilesListLoading(true)); - const fetchTilesList = async (url) => { + const fetchTilesList = async (url: string) => { try { const response = await CoreModules.axios.get(url); dispatch(ProjectActions.SetTilesList(response.data)); @@ -140,11 +144,12 @@ export const GetTilesList = (url) => { await fetchTilesList(url); }; }; -export const GenerateProjectTiles = (url, payload) => { + +export const GenerateProjectTiles = (url: string, payload: string) => { return async (dispatch) => { dispatch(ProjectActions.SetGenerateProjectTilesLoading(true)); - const generateProjectTiles = async (url, payload) => { + const generateProjectTiles = async (url: string, payload: string) => { try { const response = await CoreModules.axios.get(url); dispatch(GetTilesList(`${import.meta.env.VITE_API_URL}/projects/${payload}/tiles-list/`)); @@ -159,11 +164,11 @@ export const GenerateProjectTiles = (url, payload) => { }; }; -export const DownloadTile = (url, payload, toOpfs = false) => { +export const DownloadTile = (url: string, payload: Partial, toOpfs: boolean = false) => { return async (dispatch) => { dispatch(ProjectActions.SetDownloadTileLoading({ type: payload, loading: true })); - const getDownloadTile = async (url, payload, toOpfs) => { + const getDownloadTile = async (url: string, payload: Partial, toOpfs: boolean) => { try { const response = await CoreModules.axios.get(url, { responseType: 'arraybuffer', @@ -207,9 +212,9 @@ export const DownloadTile = (url, payload, toOpfs = false) => { }; }; -export const GetProjectDashboard = (url) => { +export const GetProjectDashboard = (url: string) => { return async (dispatch) => { - const getProjectDashboard = async (url) => { + const getProjectDashboard = async (url: string) => { try { dispatch(ProjectActions.SetProjectDashboardLoading(true)); const response = await CoreModules.axios.get(url); @@ -225,9 +230,9 @@ export const GetProjectDashboard = (url) => { }; }; -export const GetEntityInfo = (url) => { +export const GetEntityInfo = (url: string) => { return async (dispatch) => { - const getEntityOsmMap = async (url) => { + const getEntityOsmMap = async (url: string) => { try { dispatch(ProjectActions.SetEntityToOsmIdMappingLoading(true)); dispatch(CoreModules.TaskActions.SetTaskSubmissionStatesLoading(true)); @@ -247,9 +252,9 @@ export const GetEntityInfo = (url) => { }; }; -export const GetProjectComments = (url) => { +export const GetProjectComments = (url: string) => { return async (dispatch) => { - const getProjectComments = async (url) => { + const getProjectComments = async (url: string) => { try { dispatch(ProjectActions.SetProjectGetCommentsLoading(true)); const response = await CoreModules.axios.get(url); @@ -265,9 +270,9 @@ export const GetProjectComments = (url) => { }; }; -export const PostProjectComments = (url, payload) => { +export const PostProjectComments = (url: string, payload: { task_id: number; project_id: any; comment: string }) => { return async (dispatch) => { - const postProjectComments = async (url) => { + const postProjectComments = async (url: string) => { try { dispatch(ProjectActions.SetPostProjectCommentsLoading(true)); const response = await CoreModules.axios.post(url, payload); @@ -283,9 +288,9 @@ export const PostProjectComments = (url, payload) => { }; }; -export const GetProjectTaskActivity = (url) => { +export const GetProjectTaskActivity = (url: string) => { return async (dispatch) => { - const getProjectActivity = async (url) => { + const getProjectActivity = async (url: string) => { try { dispatch(ProjectActions.SetProjectTaskActivityLoading(true)); const response = await CoreModules.axios.get(url); @@ -301,9 +306,9 @@ export const GetProjectTaskActivity = (url) => { }; }; -export const UpdateEntityStatus = (url, payload) => { +export const UpdateEntityStatus = (url: string, payload: { entity_id: string; status: number; label: string }) => { return async (dispatch) => { - const updateEntityStatus = async (url, payload) => { + const updateEntityStatus = async (url: string, payload: { entity_id: string; status: number; label: string }) => { try { dispatch(ProjectActions.UpdateEntityStatusLoading(true)); const response = await CoreModules.axios.post(url, payload); @@ -317,11 +322,11 @@ export const UpdateEntityStatus = (url, payload) => { }; }; -export const DownloadSubmissionGeojson = (url, projectName) => { +export const DownloadSubmissionGeojson = (url: string, projectName: string) => { return async (dispatch) => { dispatch(ProjectActions.SetDownloadSubmissionGeojsonLoading(true)); - const downloadSubmissionGeojson = async (url) => { + const downloadSubmissionGeojson = async (url: string) => { try { const response = await CoreModules.axios.get(url, { responseType: 'blob' }); const a = document.createElement('a'); From 3ee498ee36856120c5989eba8d0e184a42430084 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Wed, 7 Aug 2024 16:44:44 +0545 Subject: [PATCH 05/35] fix(submissions): store filterType seperately --- .../ProjectSubmissions/SubmissionsTable.tsx | 11 ++--------- src/frontend/src/store/types/ISubmissions.ts | 7 +++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx index 90637ee404..df4f92e9f2 100644 --- a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx +++ b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx @@ -13,22 +13,15 @@ import CustomDatePicker from '@/components/common/CustomDatePicker'; import { format } from 'date-fns'; import Button from '@/components/common/Button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/common/Dropdown'; -import { ConvertXMLToJOSM, getDownloadProjectSubmission, getDownloadProjectSubmissionJson } from '@/api/task'; +import { ConvertXMLToJOSM, getDownloadProjectSubmission } from '@/api/task'; import { Modal } from '@/components/common/Modal'; import { useNavigate, useSearchParams } from 'react-router-dom'; import filterParams from '@/utilfunctions/filterParams'; import UpdateReviewStatusModal from '@/components/ProjectSubmissions/UpdateReviewStatusModal'; -import { projectInfoType } from '@/models/project/projectModel'; import { useAppSelector } from '@/types/reduxTypes'; import { camelToFlat } from '@/utilfunctions/commonUtils'; import useDocumentTitle from '@/utilfunctions/useDocumentTitle'; - -type filterType = { - task_id: string | null; - submitted_by: string | null; - review_state: string | null; - submitted_date: string | null; -}; +import { filterType } from '@/store/types/ISubmissions'; const SubmissionsTable = ({ toggleView }) => { useDocumentTitle('Submission Table'); diff --git a/src/frontend/src/store/types/ISubmissions.ts b/src/frontend/src/store/types/ISubmissions.ts index 6a26defc32..dde7ec2a05 100644 --- a/src/frontend/src/store/types/ISubmissions.ts +++ b/src/frontend/src/store/types/ISubmissions.ts @@ -26,3 +26,10 @@ type updateReviewStatusModal = { reviewState: string; taskUId: string | null; }; + +export type filterType = { + task_id: string | null; + submitted_by: string | null; + review_state: string | null; + submitted_date: string | null; +}; From d051a938b1f0b62cc76216c607bbbf75f993b353 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Wed, 7 Aug 2024 16:46:14 +0545 Subject: [PATCH 06/35] feat(api): add ts types to remaining services --- src/frontend/src/api/CreateProjectService.ts | 48 ++++++++++---------- src/frontend/src/api/HomeService.ts | 2 +- src/frontend/src/api/Login.ts | 2 +- src/frontend/src/api/OrganisationService.ts | 10 ++-- src/frontend/src/api/ProjectTaskStatus.ts | 2 +- src/frontend/src/api/Submission.ts | 2 +- src/frontend/src/api/SubmissionService.ts | 7 ++- 7 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/frontend/src/api/CreateProjectService.ts b/src/frontend/src/api/CreateProjectService.ts index 9b7e9702b2..b2ee671d05 100755 --- a/src/frontend/src/api/CreateProjectService.ts +++ b/src/frontend/src/api/CreateProjectService.ts @@ -10,7 +10,7 @@ import { CommonActions } from '@/store/slices/CommonSlice'; import { ValidateCustomFormResponse } from '@/store/types/ICreateProject'; import { isStatusSuccess } from '@/utilfunctions/commonUtils'; -const CreateProjectService: Function = ( +const CreateProjectService = ( url: string, projectData: any, taskAreaGeojson: any, @@ -110,11 +110,11 @@ const CreateProjectService: Function = ( }; }; -const FormCategoryService: Function = (url: string) => { +const FormCategoryService = (url: string) => { return async (dispatch) => { dispatch(CreateProjectActions.GetFormCategoryLoading(true)); - const getFormCategoryList = async (url) => { + const getFormCategoryList = async (url: string) => { try { const getFormCategoryListResponse = await axios.get(url); const resp: FormCategoryListModel = getFormCategoryListResponse.data; @@ -128,10 +128,10 @@ const FormCategoryService: Function = (url: string) => { }; }; -const UploadTaskAreasService: Function = (url: string, filePayload: any, projectData: any) => { +const UploadTaskAreasService = (url: string, filePayload: any, projectData: any) => { return async (dispatch) => { dispatch(CreateProjectActions.UploadAreaLoading(true)); - const postUploadArea = async (url, filePayload) => { + const postUploadArea = async (url: string, filePayload: any) => { let isAPISuccess = true; try { const areaFormData = new FormData(); @@ -169,7 +169,7 @@ const UploadTaskAreasService: Function = (url: string, filePayload: any, project }; }; -const GenerateProjectFilesService: Function = (url: string, projectData: any, formUpload: any) => { +const GenerateProjectFilesService = (url: string, projectData: any, formUpload: any) => { return async (dispatch) => { dispatch(CreateProjectActions.GenerateProjectLoading(true)); dispatch(CommonActions.SetLoading(true)); @@ -221,11 +221,11 @@ const GenerateProjectFilesService: Function = (url: string, projectData: any, fo }; }; -const OrganisationService: Function = (url: string) => { +const OrganisationService = (url: string) => { return async (dispatch) => { dispatch(CreateProjectActions.GetOrganisationListLoading(true)); - const getOrganisationList = async (url) => { + const getOrganisationList = async (url: string) => { try { const getOrganisationListResponse = await axios.get(url); const resp: OrganisationListModel = getOrganisationListResponse.data; @@ -239,11 +239,11 @@ const OrganisationService: Function = (url: string) => { }; }; -const GetDividedTaskFromGeojson: Function = (url: string, projectData: any) => { +const GetDividedTaskFromGeojson = (url: string, projectData: Record) => { return async (dispatch) => { dispatch(CreateProjectActions.SetDividedTaskFromGeojsonLoading(true)); - const getDividedTaskFromGeojson = async (url, projectData) => { + const getDividedTaskFromGeojson = async (url: string, projectData: Record) => { try { const dividedTaskFormData = new FormData(); dividedTaskFormData.append('project_geojson', projectData.geojson); @@ -265,13 +265,13 @@ const GetDividedTaskFromGeojson: Function = (url: string, projectData: any) => { }; }; -const GetIndividualProjectDetails: Function = (url: string, projectData: any) => { +const GetIndividualProjectDetails = (url: string) => { return async (dispatch) => { dispatch(CreateProjectActions.SetIndividualProjectDetailsLoading(true)); - const getIndividualProjectDetails = async (url, projectData) => { + const getIndividualProjectDetails = async (url: string) => { try { - const getIndividualProjectDetailsResponse = await axios.get(url, { params: projectData }); + const getIndividualProjectDetailsResponse = await axios.get(url); const resp: ProjectDetailsModel = getIndividualProjectDetailsResponse.data; const formattedOutlineGeojson = { type: 'FeatureCollection', features: [{ ...resp.outline_geojson, id: 1 }] }; const modifiedResponse = { @@ -292,11 +292,11 @@ const GetIndividualProjectDetails: Function = (url: string, projectData: any) => } }; - await getIndividualProjectDetails(url, projectData); + await getIndividualProjectDetails(url); }; }; -const TaskSplittingPreviewService: Function = ( +const TaskSplittingPreviewService = ( url: string, projectAoiFile: any, no_of_buildings: string, @@ -305,7 +305,7 @@ const TaskSplittingPreviewService: Function = ( return async (dispatch) => { dispatch(CreateProjectActions.GetTaskSplittingPreviewLoading(true)); - const getTaskSplittingGeojson = async (url, projectAoiFile, dataExtractFile) => { + const getTaskSplittingGeojson = async (url: string, projectAoiFile: any, dataExtractFile: any) => { try { const taskSplittingFileFormData = new FormData(); taskSplittingFileFormData.append('project_geojson', projectAoiFile); @@ -343,11 +343,11 @@ const TaskSplittingPreviewService: Function = ( await getTaskSplittingGeojson(url, projectAoiFile, dataExtractFile); }; }; -const PatchProjectDetails: Function = (url: string, projectData: any) => { +const PatchProjectDetails = (url: string, projectData: Record) => { return async (dispatch) => { dispatch(CreateProjectActions.SetPatchProjectDetailsLoading(true)); - const patchProjectDetails = async (url, projectData) => { + const patchProjectDetails = async (url: string, projectData: Record) => { try { const getIndividualProjectDetailsResponse = await axios.patch(url, projectData); const resp: ProjectDetailsModel = getIndividualProjectDetailsResponse.data; @@ -373,11 +373,11 @@ const PatchProjectDetails: Function = (url: string, projectData: any) => { }; }; -const PostFormUpdate: Function = (url: string, projectData: any) => { +const PostFormUpdate = (url: string, projectData: Record) => { return async (dispatch) => { dispatch(CreateProjectActions.SetPostFormUpdateLoading(true)); - const postFormUpdate = async (url, projectData) => { + const postFormUpdate = async (url: string, projectData: Record) => { try { const formFormData = new FormData(); formFormData.append('xform_id', projectData.xformId); @@ -415,11 +415,11 @@ const PostFormUpdate: Function = (url: string, projectData: any) => { await postFormUpdate(url, projectData); }; }; -const EditProjectBoundaryService: Function = (url: string, geojsonUpload: any, dimension: any) => { +const EditProjectBoundaryService = (url: string, geojsonUpload: any, dimension: any) => { return async (dispatch) => { dispatch(CreateProjectActions.SetEditProjectBoundaryServiceLoading(true)); - const postFormUpdate = async (url, geojsonUpload, dimension) => { + const postFormUpdate = async (url: string, geojsonUpload: any, dimension: any) => { try { const editBoundaryFormData = new FormData(); editBoundaryFormData.append('project_geojson', geojsonUpload); @@ -450,7 +450,7 @@ const EditProjectBoundaryService: Function = (url: string, geojsonUpload: any, d }; }; -const ValidateCustomForm: Function = (url: string, formUpload: any) => { +const ValidateCustomForm = (url: string, formUpload: any) => { return async (dispatch) => { dispatch(CreateProjectActions.ValidateCustomFormLoading(true)); @@ -492,7 +492,7 @@ const ValidateCustomForm: Function = (url: string, formUpload: any) => { }; }; -const DeleteProjectService: Function = (url: string, hasRedirect: boolean = true) => { +const DeleteProjectService = (url: string, hasRedirect: boolean = true) => { return async (dispatch) => { const deleteProject = async (url: string) => { try { diff --git a/src/frontend/src/api/HomeService.ts b/src/frontend/src/api/HomeService.ts index cb7b1741a1..783a6f228e 100755 --- a/src/frontend/src/api/HomeService.ts +++ b/src/frontend/src/api/HomeService.ts @@ -5,7 +5,7 @@ export const HomeSummaryService: Function = (url: string) => { return async (dispatch) => { dispatch(HomeActions.HomeProjectLoading(true)); - const fetchHomeSummaries = async (url) => { + const fetchHomeSummaries = async (url: string) => { try { const fetchHomeData = await axios.get(url); const projectSummaries: any = fetchHomeData.data.results; diff --git a/src/frontend/src/api/Login.ts b/src/frontend/src/api/Login.ts index bd559c0af7..e954220ffb 100644 --- a/src/frontend/src/api/Login.ts +++ b/src/frontend/src/api/Login.ts @@ -5,7 +5,7 @@ import { LoginActions } from '@/store/slices/LoginSlice'; export const TemporaryLoginService: Function = (url: string) => { return async (dispatch) => { - const getTemporaryLogin = async (url) => { + const getTemporaryLogin = async (url: string) => { // Sets a cookie in the browser that is used for auth await axios.get(url); diff --git a/src/frontend/src/api/OrganisationService.ts b/src/frontend/src/api/OrganisationService.ts index 341876f393..7bb22728ad 100644 --- a/src/frontend/src/api/OrganisationService.ts +++ b/src/frontend/src/api/OrganisationService.ts @@ -6,7 +6,7 @@ import { OrganisationAction } from '@/store/slices/organisationSlice'; import { API } from '.'; import { LoginActions } from '@/store/slices/LoginSlice'; -function appendObjectToFormData(formData, object) { +function appendObjectToFormData(formData: FormData, object: Record) { for (const [key, value] of Object.entries(object)) { // if (key === 'logo') { // formData.append(key, value[0]) @@ -19,7 +19,7 @@ export const OrganisationService: Function = (url: string, payload: Organisation return async (dispatch) => { dispatch(CommonActions.PostOrganisationLoading(true)); - const postOrganisation = async (url, payload) => { + const postOrganisation = async (url: string, payload: OrganisationModal) => { try { const generateApiFormData = new FormData(); appendObjectToFormData(generateApiFormData, payload); @@ -43,7 +43,7 @@ export const OrganisationService: Function = (url: string, payload: Organisation export const OrganisationDataService: Function = (url: string) => { return async (dispatch) => { dispatch(OrganisationAction.GetOrganisationDataLoading(true)); - const getOrganisationData = async (url) => { + const getOrganisationData = async (url: string) => { try { const getOrganisationDataResponse = await API.get(url); const response: GetOrganisationDataModel = getOrganisationDataResponse.data; @@ -63,7 +63,7 @@ export const OrganisationDataService: Function = (url: string) => { export const MyOrganisationDataService: Function = (url: string) => { return async (dispatch) => { dispatch(OrganisationAction.GetMyOrganisationDataLoading(true)); - const getMyOrganisationData = async (url) => { + const getMyOrganisationData = async (url: string) => { try { const getMyOrganisationDataResponse = await API.get(url); const response: GetOrganisationDataModel[] = getMyOrganisationDataResponse.data; @@ -126,7 +126,7 @@ export const PostOrganisationDataService: Function = (url: string, payload: any) export const GetIndividualOrganizationService: Function = (url: string) => { return async (dispatch) => { dispatch(OrganisationAction.SetOrganisationFormData({})); - const getOrganisationData = async (url) => { + const getOrganisationData = async (url: string) => { try { const getOrganisationDataResponse = await axios.get(url); const response: GetOrganisationDataModel = getOrganisationDataResponse.data; diff --git a/src/frontend/src/api/ProjectTaskStatus.ts b/src/frontend/src/api/ProjectTaskStatus.ts index df747bef00..a87aff019a 100755 --- a/src/frontend/src/api/ProjectTaskStatus.ts +++ b/src/frontend/src/api/ProjectTaskStatus.ts @@ -15,7 +15,7 @@ const UpdateTaskStatus = ( params: { project_id: string }, ) => { return async (dispatch) => { - const updateTask = async (url: string, body: any, feature: Record, params: string) => { + const updateTask = async (url: string, body: any, feature: Record, params: { project_id: string }) => { try { dispatch(CommonActions.SetLoading(true)); diff --git a/src/frontend/src/api/Submission.ts b/src/frontend/src/api/Submission.ts index 6ba74b31dc..5ec195a0be 100644 --- a/src/frontend/src/api/Submission.ts +++ b/src/frontend/src/api/Submission.ts @@ -4,7 +4,7 @@ import { SubmissionActions } from '@/store/slices/SubmissionSlice'; export const SubmissionService: Function = (url: string) => { return async (dispatch) => { dispatch(SubmissionActions.SetSubmissionDetailsLoading(true)); - const getSubmissionDetails = async (url) => { + const getSubmissionDetails = async (url: string) => { try { const getSubmissionDetailsResponse = await axios.get(url); const response: any = getSubmissionDetailsResponse.data; diff --git a/src/frontend/src/api/SubmissionService.ts b/src/frontend/src/api/SubmissionService.ts index 89193a6931..02c9b770c9 100644 --- a/src/frontend/src/api/SubmissionService.ts +++ b/src/frontend/src/api/SubmissionService.ts @@ -1,9 +1,8 @@ import CoreModules from '@/shared/CoreModules'; import { CommonActions } from '@/store/slices/CommonSlice'; import { ProjectActions } from '@/store/slices/ProjectSlice'; -// import { HomeProjectCardModel } from '@/models/home/homeModel'; import { SubmissionActions } from '@/store/slices/SubmissionSlice'; -import { basicGeojsonTemplate } from '@/utilities/mapUtils'; +import { filterType } from '@/store/types/ISubmissions'; export const ProjectSubmissionService: Function = (url: string) => { return async (dispatch) => { @@ -62,9 +61,9 @@ export const SubmissionFormFieldsService: Function = (url: string) => { }; }; -export const SubmissionTableService: Function = (url: string, payload) => { +export const SubmissionTableService: Function = (url: string, payload: filterType) => { return async (dispatch) => { - const fetchSubmissionTable = async (url: string, payload) => { + const fetchSubmissionTable = async (url: string, payload: filterType) => { try { dispatch(SubmissionActions.SetSubmissionTableLoading(true)); const response = await CoreModules.axios.get(url, { params: payload }); From 7be275c870d99a11bdf6742beeb0501244487019 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Wed, 7 Aug 2024 17:41:19 +0545 Subject: [PATCH 07/35] fix(dropdown): props fix --- src/frontend/src/components/common/Dropdown.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/components/common/Dropdown.tsx b/src/frontend/src/components/common/Dropdown.tsx index 6a586621b8..cd53bc30ac 100644 --- a/src/frontend/src/components/common/Dropdown.tsx +++ b/src/frontend/src/components/common/Dropdown.tsx @@ -39,10 +39,9 @@ const DropdownMenuSubContent = ({ className, ref, ...props }) => ( ); DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName; -const DropdownMenuContent = ({ className, sideOffset = 4, ref, ...props }) => ( +const DropdownMenuContent = ({ className, sideOffset = 4, ...props }) => ( ( ); DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; -const DropdownMenuItem = ({ className, inset, ref, ...props }) => ( +const DropdownMenuItem = ({ ...props }) => ( From 224549ed6b16bbda542d4d86fe7c0275a932b5fc Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Wed, 7 Aug 2024 17:42:35 +0545 Subject: [PATCH 08/35] fix(submissionsTable): customSelect value props ts error fix --- .../src/components/ProjectSubmissions/SubmissionsTable.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx index df4f92e9f2..17ed993eb1 100644 --- a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx +++ b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx @@ -255,7 +255,7 @@ const SubmissionsTable = ({ toggleView }) => { placeholder="Select" data={taskInfo} dataKey="value" - value={filter?.task_id?.toString() || null} + value={filter?.task_id?.toString() || undefined} valueKey="task_id" label="task_id" onValueChange={(value) => value && setFilter((prev) => ({ ...prev, task_id: value.toString() }))} @@ -268,7 +268,7 @@ const SubmissionsTable = ({ toggleView }) => { placeholder="Select" data={reviewStateData} dataKey="value" - value={filter?.review_state} + value={filter?.review_state || undefined} valueKey="value" label="label" onValueChange={(value) => From b13560e91da0c270578bdb049ace46a4724ea31f Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 09:21:49 +0545 Subject: [PATCH 09/35] fix(tasks): unused component remove --- src/frontend/src/routes.jsx | 14 -- src/frontend/src/views/Tasks.tsx | 275 ------------------------------- 2 files changed, 289 deletions(-) delete mode 100644 src/frontend/src/views/Tasks.tsx diff --git a/src/frontend/src/routes.jsx b/src/frontend/src/routes.jsx index 7d9dfc4ef9..5b625ea077 100755 --- a/src/frontend/src/routes.jsx +++ b/src/frontend/src/routes.jsx @@ -18,7 +18,6 @@ import ProjectSubmissions from '@/views/ProjectSubmissions'; import ManageProject from '@/views/ManageProject'; const Submissions = React.lazy(() => import('./views/Submissions')); -const Tasks = React.lazy(() => import('./views/Tasks')); const routes = createBrowserRouter([ { @@ -90,19 +89,6 @@ const routes = createBrowserRouter([ ), }, - - { - path: '/project/:projectId/tasks/:taskId', - element: ( - - }> - - - - - - ), - }, { path: '/project/:projectId/tasks/:taskId/submission/:instanceId', element: ( diff --git a/src/frontend/src/views/Tasks.tsx b/src/frontend/src/views/Tasks.tsx deleted file mode 100644 index 1d239e3add..0000000000 --- a/src/frontend/src/views/Tasks.tsx +++ /dev/null @@ -1,275 +0,0 @@ -// TODO should this be deleted?? - -import React, { useEffect, useState } from 'react'; -// import '../styles/home.css' -import CoreModules from '@/shared/CoreModules'; -import AssetModules from '@/shared/AssetModules'; -// import { useLocation, useNavigate } from 'react-router-dom'; -// import { styled, alpha } from '@mui/material'; - -import Avatar from '@/assets/images/avatar.png'; -import { ProjectSubmissionService } from '@/api/SubmissionService'; -import { ProjectActions } from '@/store/slices/ProjectSlice'; -import { ProjectById } from '@/api/Project'; -import { getDownloadProjectSubmission } from '@/api/task'; -import { downloadProjectFormLoadingType } from '@/models/project/projectModel'; -const basicGeojsonTemplate = { - type: 'FeatureCollection', - features: [], -}; - -const TasksSubmission = () => { - const dispatch = CoreModules.useAppDispatch(); - const state = CoreModules.useAppSelector((state) => state.project); - const projectInfo = CoreModules.useAppSelector((state) => state.home.selectedProject); - const projectSubmissionState = CoreModules.useAppSelector((state) => state.project.projectSubmission); - const projectState = CoreModules.useAppSelector((state) => state.project.project); - // const projectTaskBoundries = CoreModules.useAppSelector((state) => state.project.projectTaskBoundries); - // const projectBuildingGeojson = CoreModules.useAppSelector((state) => state.project.projectBuildingGeojson); - const params = CoreModules.useParams(); - 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=${projectId}&task_id=${taskId}`), - ); - // dispatch( - // ProjectDataExtractService( - // `${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 == projectId) == -1) { - dispatch(ProjectById(projectId)); - // dispatch( - // ProjectDataExtractService( - // `${import.meta.env.VITE_API_URL}/projects/${projectId}/features`, - // ), - // ); - } else { - dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(projectId)); - } - if (Object.keys(state.projectInfo).length == 0) { - dispatch(ProjectActions.SetProjectInfo(projectInfo)); - } else { - if (state.projectInfo.id != projectId) { - dispatch(ProjectActions.SetProjectInfo(projectInfo)); - } - } - }, [params.id]); - const projectTaskBoundries = CoreModules.useAppSelector((state) => state.project.projectTaskBoundries); - const projectBuildingGeojson = CoreModules.useAppSelector((state) => state.project.projectBuildingGeojson); - const [projectBoundaries, setProjectBoundaries] = useState(null); - const [buildingBoundaries, setBuildingBoundaries] = useState(null); - - if (projectTaskBoundries?.length > 0 && projectBoundaries === null) { - const taskGeojsonFeatureCollection = { - ...basicGeojsonTemplate, - features: [ - ...projectTaskBoundries?.[0]?.taskBoundries - ?.filter((task) => task.id == taskId) - .map((task) => ({ - ...task.outline_geojson, - id: task.outline_geojson.properties.uid, - })), - ], - }; - setProjectBoundaries(taskGeojsonFeatureCollection); - } - if (projectBuildingGeojson?.length > 0 && buildingBoundaries === null) { - const buildingGeojsonFeatureCollection = { - ...basicGeojsonTemplate, - features: [ - ...projectBuildingGeojson - ?.filter((task) => task.task_id == taskId) - .map((task) => ({ ...task.geometry, id: task.id })), - ], - // features: projectBuildingGeojson.map((feature) => ({ ...feature.geometry, id: feature.id })) - }; - setBuildingBoundaries(buildingGeojsonFeatureCollection); - } - - const StyledMenu = AssetModules.styled((props) => ( - - ))(({ theme }) => ({ - '& .MuiPaper-root': { - borderRadius: 6, - marginTop: theme.spacing(1), - minWidth: 180, - color: theme.palette.mode === 'light' ? 'rgb(55, 65, 81)' : theme.palette.grey[300], - boxShadow: - 'rgb(255, 255, 255) 0px 0px 0px 0px, rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px', - '& .MuiMenu-list': { - padding: '4px 0', - }, - '& .MuiMenuItem-root': { - '& .MuiSvgIcon-root': { - fontSize: 18, - color: theme.palette.text.secondary, - marginRight: theme.spacing(1.5), - }, - '&:active': { - backgroundColor: AssetModules.alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity), - }, - }, - }, - })); - - const handleDownload = (downloadType) => { - if (downloadType === 'csv') { - dispatch( - getDownloadProjectSubmission( - `${ - import.meta.env.VITE_API_URL - }/submission/download?project_id=${projectId}&task_id=${taskId}&export_json=false`, - ), - ); - } else if (downloadType === 'json') { - dispatch( - getDownloadProjectSubmission( - `${ - import.meta.env.VITE_API_URL - }/submission/download?project_id=${projectId}&task_id=${taskId}&export_json=true`, - ), - ); - } - }; - - const downloadSubmissionLoading: downloadProjectFormLoadingType = CoreModules.useAppSelector( - (state) => state.task.downloadSubmissionLoading, - ); - - return ( - - - - - {/* Project Details SideBar Button for Creating Project */} - - Monitoring - - - {/* END */} - - {/* Upload Area SideBar Button for uploading Area page */} - - Convert - - handleDownload('csv')} - sx={{ width: 'unset' }} - loading={downloadSubmissionLoading.type === 'csv' && downloadSubmissionLoading.loading} - loadingPosition="end" - endIcon={} - variant="contained" - color="error" - > - CSV - - - handleDownload('json')} - sx={{ width: 'unset' }} - loading={downloadSubmissionLoading.type === 'json' && downloadSubmissionLoading.loading} - loadingPosition="end" - endIcon={} - variant="contained" - color="error" - > - JSON - - - {/* END */} - - - {projectSubmissionState?.map((submission) => { - const date = new Date(submission.createdAt); - - const dateOptions = { - minute: 'numeric', - hour: 'numeric', - day: 'numeric', - weekday: 'long', - year: 'numeric', - month: 'long', - }; - - const formattedDate = date.toLocaleDateString('en-US', dateOptions); - return ( - - - - {' '} - - - - {submission.submitted_by} - - - Submitted {projectState?.project} at {formattedDate} - - - - - ); - })} - - - - {/* */} - - - - ); -}; - -export default TasksSubmission; From 126cbf75ad957d7ed5fe4a411e932716b1759797 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 10:17:37 +0545 Subject: [PATCH 10/35] fix(stepFormConstants): export interface --- src/frontend/src/constants/StepFormConstants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/constants/StepFormConstants.ts b/src/frontend/src/constants/StepFormConstants.ts index 658fb82d58..d15513bd4f 100644 --- a/src/frontend/src/constants/StepFormConstants.ts +++ b/src/frontend/src/constants/StepFormConstants.ts @@ -1,4 +1,4 @@ -interface ICreateProjectSteps { +export interface ICreateProjectSteps { url: string; step: number; label: string; From e6c9d5aeb565614e9555e4c0c3ab99792ef8b487 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 10:19:06 +0545 Subject: [PATCH 11/35] fix(stepSwitcher): add stepSwitcher props type --- .../src/components/common/StepSwitcher.tsx | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/frontend/src/components/common/StepSwitcher.tsx b/src/frontend/src/components/common/StepSwitcher.tsx index c16cdcf866..47bcf627ba 100644 --- a/src/frontend/src/components/common/StepSwitcher.tsx +++ b/src/frontend/src/components/common/StepSwitcher.tsx @@ -3,15 +3,22 @@ import AssetModules from '@/shared/AssetModules.js'; import { CommonActions } from '@/store/slices/CommonSlice'; import CoreModules from '@/shared/CoreModules.js'; import { useNavigate } from 'react-router-dom'; +import { ICreateProjectSteps } from '@/constants/StepFormConstants'; -const StepSwitcher = ({ data, flag, switchSteps }) => { - interface IIndividualStep { - url: string; - step: number; - label: string; - name: string; - } +type stepSwitcherPropType = { + data: ICreateProjectSteps[]; + flag: string; + switchSteps: boolean; +}; + +interface IIndividualStep { + url: string; + step: number; + label: string; + name: string; +} +const StepSwitcher = ({ data, flag, switchSteps }: stepSwitcherPropType) => { const dispatch = CoreModules.useAppDispatch(); const navigate = useNavigate(); const currentStep = CoreModules.useAppSelector((state) => state.common.currentStepFormStep[flag]); From 0f075774a5f5abef2b0cc82f63f595926660e7f9 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 10:53:01 +0545 Subject: [PATCH 12/35] fix(uploadArea): uploadArea prop type add --- .../ManageProject/EditTab/FormUpdateTab.tsx | 2 +- .../src/components/common/UploadArea.tsx | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/components/ManageProject/EditTab/FormUpdateTab.tsx b/src/frontend/src/components/ManageProject/EditTab/FormUpdateTab.tsx index 467800de7e..6271f7d4ee 100644 --- a/src/frontend/src/components/ManageProject/EditTab/FormUpdateTab.tsx +++ b/src/frontend/src/components/ManageProject/EditTab/FormUpdateTab.tsx @@ -110,7 +110,7 @@ const FormUpdateTab = ({ projectId }) => { multiple={false} data={uploadForm || []} filterKey="url" - onUploadFile={(updatedFiles) => { + onUploadFile={(updatedFiles: FileType[]) => { dispatch(CreateProjectActions.SetCustomFileValidity(false)); setUploadForm(updatedFiles); }} diff --git a/src/frontend/src/components/common/UploadArea.tsx b/src/frontend/src/components/common/UploadArea.tsx index e24c565b8f..2c6649966f 100644 --- a/src/frontend/src/components/common/UploadArea.tsx +++ b/src/frontend/src/components/common/UploadArea.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useRef, useState } from 'react'; import { useDispatch } from 'react-redux'; -import { CommonActions } from '../../store/slices/CommonSlice'; -import AssetModules from '../../shared/AssetModules.js'; +import { CommonActions } from '@/store/slices/CommonSlice'; +import AssetModules from '@/shared/AssetModules'; import { v4 as uuidv4 } from 'uuid'; type FileType = { @@ -11,7 +11,17 @@ type FileType = { isDeleted: boolean; }; -const UploadArea = ({ title, label, acceptedInput, data, onUploadFile, multiple, filterKey }) => { +type uploadAreaPropType = { + title: string; + label: string; + multiple: boolean; + data: FileType[]; + filterKey: string; + onUploadFile: (updatedFiles: FileType[]) => void; + acceptedInput: string; +}; + +const UploadArea = ({ title, label, acceptedInput, data, onUploadFile, multiple, filterKey }: uploadAreaPropType) => { const fileInputRef = useRef(null); const dispatch = useDispatch(); const [selectedFiles, setSelectedFiles] = useState([]); @@ -83,7 +93,7 @@ const UploadArea = ({ title, label, acceptedInput, data, onUploadFile, multiple, const id = uuidv4(); return fileList.push({ id, name, [filterKey]: file, isDeleted }); } - if (acceptedInput.includes(fileType)) { + if (fileType && acceptedInput.includes(fileType)) { const id = uuidv4(); const isDeleted = false; return fileList.push({ id, name, [filterKey]: file, isDeleted }); @@ -102,7 +112,7 @@ const UploadArea = ({ title, label, acceptedInput, data, onUploadFile, multiple, if (multiple) { onUploadFile([...fileList, ...data]); } else { - onUploadFile([fileList.at(fileList.length - 1)]); + onUploadFile([fileList.at(fileList.length - 1) as FileType]); } } else { onUploadFile(data); From db161acb4e9e7ce551bc05e47b5779a3d15fefb9 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 11:31:53 +0545 Subject: [PATCH 13/35] fix(kebabMenu): direction type add to getPosition function --- src/frontend/src/components/common/KebabMenu.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/common/KebabMenu.tsx b/src/frontend/src/components/common/KebabMenu.tsx index 08ccf2d142..49cc32b43e 100644 --- a/src/frontend/src/components/common/KebabMenu.tsx +++ b/src/frontend/src/components/common/KebabMenu.tsx @@ -3,17 +3,19 @@ import AssetModules from '../../shared/AssetModules.js'; type optionType = { id: number | string; icon: React.ReactNode; label: string; onClick: any }; +type directionType = 'left-top' | 'left-bottom' | 'right-bottom' | 'right-top' | 'top-left' | 'top-right'; + type kebabMenuType = { options: optionType[]; stopPropagation: boolean; - direction?: 'left-top' | 'left-bottom' | 'right-bottom' | 'right-top' | 'top-left' | 'top-right'; + direction?: directionType; data: {}; pid: string | number; openedModalId: string | number; onDropdownOpen: () => void; }; -function getPosition(direction) { +function getPosition(direction: directionType) { switch (direction) { case 'left-top': return 'fmtm-top-[2px] fmtm-right-[40px]'; From 4135ac1d08a29d95c9818d8d86d4af7c15b0b405 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 11:32:44 +0545 Subject: [PATCH 14/35] fix(fileInputComponent): prop type add --- .../src/components/common/FileInputComponent.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/components/common/FileInputComponent.tsx b/src/frontend/src/components/common/FileInputComponent.tsx index e7865637c4..7e6a965175 100644 --- a/src/frontend/src/components/common/FileInputComponent.tsx +++ b/src/frontend/src/components/common/FileInputComponent.tsx @@ -1,6 +1,16 @@ import React, { useRef } from 'react'; import AssetModules from '@/shared/AssetModules.js'; +type fileInputComponentType = { + accept: string; + customFile: any; + onChange: (e: React.ChangeEvent) => void; + onResetFile: () => void; + btnText: string; + fileDescription: string; + errorMsg: string; +}; + const FileInputComponent = ({ accept = '.geojson, .json', customFile, @@ -9,7 +19,7 @@ const FileInputComponent = ({ btnText = 'Select File', fileDescription = '*The supported file formats are zipped shapefile, geojson or kml files.', errorMsg, -}) => { +}: fileInputComponentType) => { const customFileRef = useRef(null); return (
From 71f638216176dd09fe372c56306e1f52905f6144 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 11:48:46 +0545 Subject: [PATCH 15/35] fix(bottomSheet): prop type add --- src/frontend/src/components/common/BottomSheet.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/common/BottomSheet.tsx b/src/frontend/src/components/common/BottomSheet.tsx index ceb5156b51..997730cd0d 100644 --- a/src/frontend/src/components/common/BottomSheet.tsx +++ b/src/frontend/src/components/common/BottomSheet.tsx @@ -1,7 +1,12 @@ import React, { useEffect, useRef, useState } from 'react'; import FmtmLogo from '@/assets/images/hotLog.png'; -const BottomSheet = ({ body, onClose }) => { +type bottomSheetType = { + body: React.ReactElement; + onClose: () => void; +}; + +const BottomSheet = ({ body, onClose }: bottomSheetType) => { const sheetContentRef: any = useRef(null); const bottomSheetRef: any = useRef(null); const logoRef: any = useRef(null); @@ -19,7 +24,7 @@ const BottomSheet = ({ body, onClose }) => { updateSheetHeight(50); }, []); - const updateSheetHeight = (height) => { + const updateSheetHeight = (height: number) => { if (sheetContentRef.current) { sheetContentRef.current.style.height = `${height}vh`; const top = sheetContentRef.current.getBoundingClientRect().top; From 9b153dbe5077d82994943930f6b7c7d460ad727e Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 11:49:14 +0545 Subject: [PATCH 16/35] fix(checkbox): ts error solve --- src/frontend/src/components/common/Checkbox.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/components/common/Checkbox.tsx b/src/frontend/src/components/common/Checkbox.tsx index 646cf4f6c0..f8f117a939 100644 --- a/src/frontend/src/components/common/Checkbox.tsx +++ b/src/frontend/src/components/common/Checkbox.tsx @@ -52,7 +52,13 @@ export const CustomCheckbox = ({ return (
- +

Date: Thu, 8 Aug 2024 11:49:40 +0545 Subject: [PATCH 17/35] fix(chips): prop type add --- src/frontend/src/components/common/Chips.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/common/Chips.tsx b/src/frontend/src/components/common/Chips.tsx index 177f9597bd..dc4adfba3a 100644 --- a/src/frontend/src/components/common/Chips.tsx +++ b/src/frontend/src/components/common/Chips.tsx @@ -1,10 +1,15 @@ import React from 'react'; import AssetModule from '../../shared/AssetModules.js'; -const Chips = ({ data, clearChip }) => { +type chipsType = { + data: string[]; + clearChip: (i: number) => void; +}; + +const Chips = ({ data, clearChip }: chipsType) => { return (

- {data.map((item, i) => ( + {data.map((item: string, i: number) => (
Date: Thu, 8 Aug 2024 13:12:16 +0545 Subject: [PATCH 18/35] fix(barChart): prop type add --- src/frontend/src/components/common/BarChart.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/components/common/BarChart.tsx b/src/frontend/src/components/common/BarChart.tsx index a087a5a3d6..ce76270d1d 100644 --- a/src/frontend/src/components/common/BarChart.tsx +++ b/src/frontend/src/components/common/BarChart.tsx @@ -1,7 +1,15 @@ import React, { useState } from 'react'; import { BarChart, Bar, XAxis, YAxis, Tooltip, ResponsiveContainer } from 'recharts'; -const CustomBarChart = ({ data, xLabel, yLabel, dataKey, nameKey }) => { +type customBarChartType = { + data: Record[]; + xLabel: string; + yLabel: string; + dataKey: string; + nameKey: string; +}; + +const CustomBarChart = ({ data, xLabel, yLabel, dataKey, nameKey }: customBarChartType) => { const [size, setSize] = useState({ width: 0, height: 0 }); return ( From 7ac10757cab748081dd676958fa4c62b99523c0c Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 13:12:41 +0545 Subject: [PATCH 19/35] fix(lineChart): prop type add --- src/frontend/src/components/common/LineChart.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/components/common/LineChart.tsx b/src/frontend/src/components/common/LineChart.tsx index 137a8142f5..475c561a87 100644 --- a/src/frontend/src/components/common/LineChart.tsx +++ b/src/frontend/src/components/common/LineChart.tsx @@ -1,7 +1,16 @@ import React, { useState } from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; -const CustomLineChart = ({ data, xAxisDataKey, lineOneKey, lineTwoKey, xLabel, yLabel }) => { +type customLineChartType = { + data: Record[]; + xAxisDataKey: string; + lineOneKey: string; + lineTwoKey: string; + xLabel?: string; + yLabel?: string; +}; + +const CustomLineChart = ({ data, xAxisDataKey, lineOneKey, lineTwoKey, xLabel, yLabel }: customLineChartType) => { const [size, setSize] = useState({ width: 0, height: 0 }); return ( From 435be028ad1c240a6679b7bddb56c164de021b5b Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 13:13:09 +0545 Subject: [PATCH 20/35] fix(pieChart): prop type add --- src/frontend/src/components/common/PieChart.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/components/common/PieChart.tsx b/src/frontend/src/components/common/PieChart.tsx index 36a208355a..06b0e2d03e 100644 --- a/src/frontend/src/components/common/PieChart.tsx +++ b/src/frontend/src/components/common/PieChart.tsx @@ -1,6 +1,12 @@ import React, { useState } from 'react'; import { PieChart, Pie, Cell, ResponsiveContainer, Tooltip, Legend } from 'recharts'; +type customPieChartType = { + data: Record[]; + dataKey: string; + nameKey: string; +}; + const COLORS = ['#F19C3C', '#D73F3F', '#FFB74D', '#EC407A']; const RADIAN = Math.PI / 180; @@ -17,7 +23,7 @@ const renderCustomizedLabel = ({ cx, cy, midAngle, innerRadius, outerRadius, per ); }; -const renderColorfulLegendText = (value, entry) => ( +const renderColorfulLegendText = (value: string, entry: any) => ( {value} ); @@ -45,7 +51,7 @@ const CustomLegend = ({ payload }) => (
); -const CustomPieChart = ({ data, dataKey, nameKey }) => { +const CustomPieChart = ({ data, dataKey, nameKey }: customPieChartType) => { const [size, setSize] = useState({ width: 0, height: 0 }); return ( @@ -79,7 +85,7 @@ const CustomPieChart = ({ data, dataKey, nameKey }) => { verticalAlign="bottom" iconSize={10} formatter={renderColorfulLegendText} - content={ COLORS[index % COLORS.length])} />} + content={ COLORS[index % COLORS.length])} />} /> From 479b1cca3192a8b0313a47b48269877414f4f886 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 13:16:47 +0545 Subject: [PATCH 21/35] fix(toolbar): ts type add to function --- src/frontend/src/components/common/Editor/Toolbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/components/common/Editor/Toolbar.tsx b/src/frontend/src/components/common/Editor/Toolbar.tsx index e5b508222f..5bc4fc28b0 100644 --- a/src/frontend/src/components/common/Editor/Toolbar.tsx +++ b/src/frontend/src/components/common/Editor/Toolbar.tsx @@ -19,7 +19,7 @@ export const Toolbar = ({ editor }: ToolbarProps) => { const [imageURL, setImageURL] = useState(''); const [imageDropdownOpen, setImageDropdownOpen] = useState(false); - const isEditorActive = (editorItem) => { + const isEditorActive = (editorItem: string) => { if (editor?.isActive(editorItem)) { return 'fmtm-text-primaryRed fmtm-bg-red-100'; } From f9917c038c900f98739210a2e093f0f0d7e4744e Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 14:40:37 +0545 Subject: [PATCH 22/35] fix(checkWGS84Projection): convert js to ts --- .../{checkWGS84Projection.js => checkWGS84Projection.ts} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename src/frontend/src/utilfunctions/{checkWGS84Projection.js => checkWGS84Projection.ts} (81%) diff --git a/src/frontend/src/utilfunctions/checkWGS84Projection.js b/src/frontend/src/utilfunctions/checkWGS84Projection.ts similarity index 81% rename from src/frontend/src/utilfunctions/checkWGS84Projection.js rename to src/frontend/src/utilfunctions/checkWGS84Projection.ts index 638126b19c..e2998691b3 100644 --- a/src/frontend/src/utilfunctions/checkWGS84Projection.js +++ b/src/frontend/src/utilfunctions/checkWGS84Projection.ts @@ -1,8 +1,9 @@ import OLVectorLayer from 'ol/layer/Vector'; import GeoJSON from 'ol/format/GeoJSON'; import { Vector as VectorSource } from 'ol/source'; +import { DrawnGeojsonTypes } from '@/store/types/ICreateProject'; -function checkWGS84Projection(drawnGeojson) { +function checkWGS84Projection(drawnGeojson: DrawnGeojsonTypes | null) { const vectorLyr = new OLVectorLayer({ source: new VectorSource({ features: new GeoJSON().readFeatures(drawnGeojson), @@ -13,7 +14,7 @@ function checkWGS84Projection(drawnGeojson) { const extent = vectorLyr.getSource()?.getExtent(); try { - if (extent?.length > 0) { + if (extent && extent?.length > 0) { const longitude = extent[0]; const latitude = extent[1]; if ( From d350c82307cec4f09c033f8aef84d7c8e4639b71 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 14:41:16 +0545 Subject: [PATCH 23/35] fix(compareUtils): convert js to ts --- .../utilfunctions/{compareUtils.js => compareUtils.ts} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename src/frontend/src/utilfunctions/{compareUtils.js => compareUtils.ts} (60%) diff --git a/src/frontend/src/utilfunctions/compareUtils.js b/src/frontend/src/utilfunctions/compareUtils.ts similarity index 60% rename from src/frontend/src/utilfunctions/compareUtils.js rename to src/frontend/src/utilfunctions/compareUtils.ts index ba6d7e1bf4..a484a8fa43 100755 --- a/src/frontend/src/utilfunctions/compareUtils.js +++ b/src/frontend/src/utilfunctions/compareUtils.ts @@ -1,4 +1,4 @@ -function diffObject(firstObject, secondObject) { +const diffObject = (firstObject: Record, secondObject: Record): Record => { const diffObj = Object.keys(secondObject).reduce((diff, key) => { if (firstObject[key] === secondObject[key]) return diff; return { @@ -7,9 +7,10 @@ function diffObject(firstObject, secondObject) { }; }, {}); return diffObj; -} -function diffArray(array1, array2) { +}; + +const diffArray = (array1: Record[], array2: Record[]): Record[] => { return array1.filter((object1) => !array2.some((object2) => object1.id === object2.id)); -} +}; export { diffArray, diffObject }; From 5855b2ae2a7d4d5266ecc884f9a2f3922e412230 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 14:42:28 +0545 Subject: [PATCH 24/35] fix(getTaskStatusStyle): convert js to ts --- ...etTaskStatusStyle.js => getTaskStatusStyle.ts} | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) rename src/frontend/src/utilfunctions/{getTaskStatusStyle.js => getTaskStatusStyle.ts} (91%) diff --git a/src/frontend/src/utilfunctions/getTaskStatusStyle.js b/src/frontend/src/utilfunctions/getTaskStatusStyle.ts similarity index 91% rename from src/frontend/src/utilfunctions/getTaskStatusStyle.js rename to src/frontend/src/utilfunctions/getTaskStatusStyle.ts index 94a5cb8fda..ccab75f1d8 100644 --- a/src/frontend/src/utilfunctions/getTaskStatusStyle.js +++ b/src/frontend/src/utilfunctions/getTaskStatusStyle.ts @@ -3,8 +3,9 @@ import { getCenter } from 'ol/extent'; import { Point } from 'ol/geom'; import AssetModules from '@/shared/AssetModules'; import { task_status } from '@/types/enums'; +import { EntityOsmMap } from '@/store/types/IProject'; -function createPolygonStyle(fillColor, strokeColor) { +function createPolygonStyle(fillColor: string, strokeColor: string) { return new Style({ stroke: new Stroke({ color: strokeColor, @@ -16,7 +17,8 @@ function createPolygonStyle(fillColor, strokeColor) { zIndex: 10, }); } -function createIconStyle(iconSrc) { + +function createIconStyle(iconSrc: string) { return new Style({ image: new Icon({ anchor: [0.5, 1], @@ -35,7 +37,7 @@ function createIconStyle(iconSrc) { const strokeColor = 'rgb(0,0,0,0.3)'; const secondaryStrokeColor = 'rgb(0,0,0,1)'; -const getTaskStatusStyle = (feature, mapTheme, taskLockedByUser) => { +const getTaskStatusStyle = (feature: Record, mapTheme: Record, taskLockedByUser: boolean) => { let id = feature.getId().toString().replace('_', ','); const status = id.split(',')[1]; @@ -115,9 +117,10 @@ const getTaskStatusStyle = (feature, mapTheme, taskLockedByUser) => { return geojsonStyles[status]; }; -export const getFeatureStatusStyle = (osmId, mapTheme, entityOsmMap) => { - const entity = entityOsmMap?.find((entity) => entity?.osm_id === osmId); - const status = task_status[entity?.status]; +export const getFeatureStatusStyle = (osmId: string, mapTheme: Record, entityOsmMap: EntityOsmMap[]) => { + const entity = entityOsmMap?.find((entity) => entity?.osm_id === osmId) as EntityOsmMap; + let status = task_status[entity?.status]; + const borderStrokeColor = '#FF0000'; const lockedPolygonStyle = createPolygonStyle( From fc495ad2209886cea9c7c5fdfea4941857971418 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 14:43:00 +0545 Subject: [PATCH 25/35] fix(commonUtils): add ts types --- src/frontend/src/utilfunctions/commonUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/utilfunctions/commonUtils.ts b/src/frontend/src/utilfunctions/commonUtils.ts index 3df243017b..2ebf3d7f69 100644 --- a/src/frontend/src/utilfunctions/commonUtils.ts +++ b/src/frontend/src/utilfunctions/commonUtils.ts @@ -10,7 +10,7 @@ export const camelToFlat = (word: string): string => ( (word = word.replace(/[A-Z]/g, ' $&')), word[0].toUpperCase() + word.slice(1) ); -export const isStatusSuccess = (status: number) => { +export const isStatusSuccess = (status: number): boolean => { if (status < 300) { return true; } @@ -18,12 +18,12 @@ export const isStatusSuccess = (status: number) => { }; // get date N days ago -export const dateNDaysAgo = (NDays: number) => { +export const dateNDaysAgo = (NDays: number): string => { return new Date(new Date().getTime() - NDays * 24 * 60 * 60 * 1000).toISOString(); }; // extract month & day in MM/DD format for chart date labels -export const getMonthDate = (date: string) => { +export const getMonthDate = (date: string): string => { const splittedDate = date?.split('T')[0]?.split('-'); return `${splittedDate[1]}/${splittedDate[2]}`; }; From fe92d2d3f71e9de89f0b47729922ceb59bede9e6 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 14:43:26 +0545 Subject: [PATCH 26/35] fix(filterParam): convert js to ts --- src/frontend/src/utilfunctions/filterParams.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/utilfunctions/filterParams.ts b/src/frontend/src/utilfunctions/filterParams.ts index cba95024e9..93b9c3c798 100644 --- a/src/frontend/src/utilfunctions/filterParams.ts +++ b/src/frontend/src/utilfunctions/filterParams.ts @@ -1,4 +1,4 @@ -function filterParams(params: {}): {} { +const filterParams = (params: Record): Record => { const filteredParams = {}; Object.keys(params).forEach((key: string) => { if (params[key] !== null && params[key] !== '') { @@ -6,6 +6,6 @@ function filterParams(params: {}): {} { } }); return filteredParams; -} +}; export default filterParams; From e9f34c770678c90cde432ae77a711abe3372b3b1 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 14:51:42 +0545 Subject: [PATCH 27/35] refactor(submissions): remove unused component --- src/frontend/src/routes.jsx | 14 --- src/frontend/src/views/Submissions.tsx | 134 ------------------------- 2 files changed, 148 deletions(-) delete mode 100755 src/frontend/src/views/Submissions.tsx diff --git a/src/frontend/src/routes.jsx b/src/frontend/src/routes.jsx index 5cc9e5cf11..4e0e351fc8 100755 --- a/src/frontend/src/routes.jsx +++ b/src/frontend/src/routes.jsx @@ -17,8 +17,6 @@ import ProjectDetailsV2 from '@/views/ProjectDetailsV2'; import ProjectSubmissions from '@/views/ProjectSubmissions'; import ManageProject from '@/views/ManageProject'; -const Submissions = React.lazy(() => import('./views/Submissions')); - const routes = createBrowserRouter([ { element: , @@ -101,18 +99,6 @@ const routes = createBrowserRouter([ ), }, - { - path: '/submissions/:id', - element: ( - -
}> - - - - - - ), - }, { path: '/project/:id', element: ( diff --git a/src/frontend/src/views/Submissions.tsx b/src/frontend/src/views/Submissions.tsx deleted file mode 100755 index b8fa478d95..0000000000 --- a/src/frontend/src/views/Submissions.tsx +++ /dev/null @@ -1,134 +0,0 @@ -// TODO should this be deleted?? - -import React, { useEffect } from 'react'; -// import '../styles/home.css' -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 { ProjectActions } from '@/store/slices/ProjectSlice'; -import { ProjectById } from '@/api/Project'; - -const Submissions = () => { - const dispatch = CoreModules.useAppDispatch(); - const state = CoreModules.useAppSelector((state) => state.project); - const projectInfo = CoreModules.useAppSelector((state) => state.home.selectedProject); - const projectSubmissionState = CoreModules.useAppSelector((state) => state.project.projectSubmission); - const projectState = CoreModules.useAppSelector((state) => state.project.project); - // const projectTaskBoundries = CoreModules.useAppSelector((state) => state.project.projectTaskBoundries); - // const projectBuildingGeojson = CoreModules.useAppSelector((state) => state.project.projectBuildingGeojson); - const params = CoreModules.useParams(); - const projectId = params.id; - // const theme = CoreModules.useAppSelector(state => state.theme.hotTheme) - useEffect(() => { - 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 == projectId) == -1) { - dispatch(ProjectById(projectId)); - } else { - dispatch(ProjectActions.SetProjectTaskBoundries([])); - dispatch(ProjectById(projectId)); - } - if (Object.keys(state.projectInfo).length == 0) { - dispatch(ProjectActions.SetProjectInfo(projectInfo)); - } else { - if (state.projectInfo.id != projectId) { - dispatch(ProjectActions.SetProjectInfo(projectInfo)); - } - } - }, [params.id]); - return ( - - - - - {/* Project Details SideBar Button for Creating Project */} - - Monitoring - - - {/* END */} - - {/* Upload Area SideBar Button for uploading Area page */} - - Convert - - - - Download CSV - - - {/* END */} - - - {projectSubmissionState?.map((submission) => { - const date = new Date(submission.createdAt); - - const dateOptions = { - minute: 'numeric', - hour: 'numeric', - day: 'numeric', - weekday: 'long', - year: 'numeric', - month: 'long', - }; - - const formattedDate = date.toLocaleDateString('en-US', dateOptions); - return ( - - - {' '} - - - - {submission.submitted_by} - - - Submitted {projectState?.project} at {formattedDate} - - - - ); - })} - - - - {/* */} - - - - ); -}; - -export default Submissions; From 79068521553b450a50c9e9358fa999af4a6e4a54 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 14:56:12 +0545 Subject: [PATCH 28/35] refactor(tabbed): remove unused tabbed component --- src/frontend/src/routes.jsx | 7 -- src/frontend/src/views/Tabbed.tsx | 112 ------------------------------ 2 files changed, 119 deletions(-) delete mode 100755 src/frontend/src/views/Tabbed.tsx diff --git a/src/frontend/src/routes.jsx b/src/frontend/src/routes.jsx index 4e0e351fc8..b010f0066a 100755 --- a/src/frontend/src/routes.jsx +++ b/src/frontend/src/routes.jsx @@ -1,7 +1,6 @@ import React, { Suspense } from 'react'; import { createBrowserRouter } from 'react-router-dom'; import Home from '@/views/Home'; -import Tabbed from '@/views/Tabbed'; import MainView from '@/views/MainView'; import ProtectedRoute from '@/utilities/ProtectedRoute'; import NotFoundPage from '@/views/NotFound404'; @@ -68,12 +67,6 @@ const routes = createBrowserRouter([ ), - path: '/tabbed', - element: ( - - - - ), }, { path: '/project-submissions/:projectId', diff --git a/src/frontend/src/views/Tabbed.tsx b/src/frontend/src/views/Tabbed.tsx deleted file mode 100755 index 150b69f48b..0000000000 --- a/src/frontend/src/views/Tabbed.tsx +++ /dev/null @@ -1,112 +0,0 @@ -import * as React from 'react'; -import { styled } from '@mui/system'; -import { Tabs as TabsUnstyled } from '@mui/base/Tabs'; -import { TabsList as TabsListUnstyled } from '@mui/base/TabsList'; -import { TabPanel as TabPanelUnstyled } from '@mui/base/TabPanel'; -import { buttonClasses as buttonUnstyledClasses } from '@mui/base/Button'; -import { Tab as TabUnstyled, tabClasses as tabUnstyledClasses } from '@mui/base/Tab'; - -const blue = { - 50: '#F0F7FF', - 100: '#C2E0FF', - 200: '#80BFFF', - 300: '#66B2FF', - 400: '#3399FF', - 500: '#d73f3f', - 600: '#0072E5', - 700: '#0059B2', - 800: '#004C99', - 900: '#003A75', -}; - -const grey = { - 50: '#f6f8fa', - 100: '#eaeef2', - 200: '#d0d7de', - 300: '#afb8c1', - 400: '#8c959f', - 500: '#6e7781', - 600: '#57606a', - 700: '#424a53', - 800: '#32383f', - 900: '#24292f', -}; - -const Tab = styled(TabUnstyled)` - font-family: - IBM Plex Sans, - sans-serif; - color: #fff; - cursor: pointer; - font-size: 0.875rem; - font-weight: 600; - background-color: transparent; - width: 100%; - padding: 10px 12px; - margin: 6px 6px; - border: none; - border-radius: 7px; - display: flex; - justify-content: center; - - &:hover { - background-color: ${blue[400]}; - } - - &:focus { - color: #fff; - outline: 3px solid ${blue[200]}; - } - - &.${tabUnstyledClasses.selected} { - background-color: #fff; - color: ${blue[600]}; - } - - &.${buttonUnstyledClasses.disabled} { - opacity: 0.5; - cursor: not-allowed; - } -`; - -const TabPanel = styled(TabPanelUnstyled)( - ({ theme }) => ` - width: 100%; - font-family: IBM Plex Sans, sans-serif; - font-size: 0.875rem; - padding: 20px 12px; - background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; - border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; - border-radius: 12px; - opacity: 0.6; - `, -); - -const TabsList = styled(TabsListUnstyled)( - ({ theme }) => ` - min-width: 400px; - background-color: ${blue[500]}; - border-radius: 12px; - margin-bottom: 16px; - display: flex; - align-items: center; - justify-content: center; - align-content: space-between; - box-shadow: 0px 4px 30px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; - `, -); - -export default function Tabbed() { - return ( - - - My Contributions - Explore Projects - Learn - - My contributions - Explore Projects - Learn - - ); -} From dfeee0639f81b264d4b08c044c9ade0e958d3648 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 17:09:21 +0545 Subject: [PATCH 29/35] fix(customizedModal): prop type add --- src/frontend/src/utilities/CustomizedModal.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/utilities/CustomizedModal.tsx b/src/frontend/src/utilities/CustomizedModal.tsx index 8bf149a42b..caeb05ddf4 100644 --- a/src/frontend/src/utilities/CustomizedModal.tsx +++ b/src/frontend/src/utilities/CustomizedModal.tsx @@ -3,7 +3,14 @@ import clsx from 'clsx'; import { styled, Box, Theme } from '@mui/system'; import { Modal } from '@mui/base/Modal'; -export default function CustomizedModal({ style = defaultStyle, children, isOpen, toggleOpen }) { +type customizeModal = { + style: Record; + children: React.ReactNode; + isOpen: boolean; + toggleOpen: (flag: boolean) => void; +}; + +export default function CustomizedModal({ style = defaultStyle, children, isOpen, toggleOpen }: customizeModal) { const handleClose = () => toggleOpen(false); return ( From ff65383593f4815112707dc598749eea4c3cfafa Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 17:11:34 +0545 Subject: [PATCH 30/35] fix(appLoader): remove unused imports --- .../src/utilities/{AppLoader.jsx => AppLoader.tsx} | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) rename src/frontend/src/utilities/{AppLoader.jsx => AppLoader.tsx} (69%) diff --git a/src/frontend/src/utilities/AppLoader.jsx b/src/frontend/src/utilities/AppLoader.tsx similarity index 69% rename from src/frontend/src/utilities/AppLoader.jsx rename to src/frontend/src/utilities/AppLoader.tsx index b4da0ebf9f..758d6c4f77 100644 --- a/src/frontend/src/utilities/AppLoader.jsx +++ b/src/frontend/src/utilities/AppLoader.tsx @@ -1,16 +1,5 @@ import React from 'react'; -import { useState, CSSProperties } from 'react'; -import ClipLoader from 'react-spinners/ClipLoader'; -import { - SyncLoader, - PropagateLoader, - ClockLoader, - RotateLoader, - MoonLoader, - PulseLoader, - ScaleLoader, - DotLoader, -} from 'react-spinners'; +import { DotLoader } from 'react-spinners'; import CoreModules from '@/shared/CoreModules'; const override = { @@ -18,6 +7,7 @@ const override = { margin: '2 auto', borderColor: 'red', }; + const Loader = () => { const appLoading = CoreModules.useAppSelector((state) => state.common.loading); const defaultTheme = CoreModules.useAppSelector((state) => state.theme.hotTheme); From 3e5ffbc6d2ea834a55399eef514b1e4bcba2e0b5 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 17:16:06 +0545 Subject: [PATCH 31/35] refactor(geojsonObjectModal): remove redundant file, add ts type --- src/frontend/src/constants/geojsonObjectModal.ts | 13 ++++++++++++- src/frontend/src/models/geojsonObjectModel.js | 10 ---------- 2 files changed, 12 insertions(+), 11 deletions(-) delete mode 100755 src/frontend/src/models/geojsonObjectModel.js diff --git a/src/frontend/src/constants/geojsonObjectModal.ts b/src/frontend/src/constants/geojsonObjectModal.ts index 89d8b06cbf..a3e28bf1ce 100644 --- a/src/frontend/src/constants/geojsonObjectModal.ts +++ b/src/frontend/src/constants/geojsonObjectModal.ts @@ -1,4 +1,15 @@ -export const geojsonObjectModel = { +export type geojsonObjectModelType = { + features: { geometry: any; properties: any; type: any }[]; + type: string; + SRID: { + type: string; + properties: { + name: string; + }; + }; +}; + +export const geojsonObjectModel: geojsonObjectModelType = { type: 'FeatureCollection', SRID: { type: 'name', diff --git a/src/frontend/src/models/geojsonObjectModel.js b/src/frontend/src/models/geojsonObjectModel.js deleted file mode 100755 index 89d8b06cbf..0000000000 --- a/src/frontend/src/models/geojsonObjectModel.js +++ /dev/null @@ -1,10 +0,0 @@ -export const geojsonObjectModel = { - type: 'FeatureCollection', - SRID: { - type: 'name', - properties: { - name: 'EPSG:3857', - }, - }, - features: [], -}; From dedd3ce45920a3439d437454be25c30d1dacd83b Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 17:17:00 +0545 Subject: [PATCH 32/35] fix(projectListMap): update imports & types --- .../src/components/home/ProjectListMap.tsx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/frontend/src/components/home/ProjectListMap.tsx b/src/frontend/src/components/home/ProjectListMap.tsx index 638a2c48ac..7c432a5b0f 100644 --- a/src/frontend/src/components/home/ProjectListMap.tsx +++ b/src/frontend/src/components/home/ProjectListMap.tsx @@ -4,24 +4,13 @@ import { MapContainer as MapComponent } from '@/components/MapComponent/OpenLaye import LayerSwitcherControl from '@/components/MapComponent/OpenLayersComponent/LayerSwitcher/index.js'; import { ClusterLayer } from '@/components/MapComponent/OpenLayersComponent/Layers'; import CoreModules from '@/shared/CoreModules'; -import { geojsonObjectModel } from '@/constants/geojsonObjectModal'; -import { defaultStyles, getStyles } from '@/components/MapComponent/OpenLayersComponent/helpers/styleUtils'; +import { geojsonObjectModel, geojsonObjectModelType } from '@/constants/geojsonObjectModal'; +import { defaultStyles } from '@/components/MapComponent/OpenLayersComponent/helpers/styleUtils'; import MarkerIcon from '@/assets/images/red_marker.png'; import { useNavigate } from 'react-router-dom'; import { Style, Text, Icon, Fill } from 'ol/style'; import { projectType } from '@/models/home/homeModel'; -type HomeProjectSummaryType = { - features: { geometry: any; properties: any; type: any }[]; - type: string; - SRID: { - type: string; - properties: { - name: string; - }; - }; -}; - const getIndividualStyle = (featureProperty) => { const style = new Style({ image: new Icon({ @@ -43,7 +32,7 @@ const getIndividualStyle = (featureProperty) => { const ProjectListMap = () => { const navigate = useNavigate(); - const [projectGeojson, setProjectGeojson] = useState(null); + const [projectGeojson, setProjectGeojson] = useState(null); const { mapRef, map } = useOLMap({ // center: fromLonLat([85.3, 27.7]), center: [0, 0], @@ -54,7 +43,7 @@ const ProjectListMap = () => { const homeProjectSummary: projectType[] = CoreModules.useAppSelector((state) => state.home.homeProjectSummary); useEffect(() => { if (homeProjectSummary?.length === 0) return; - const convertedHomeProjectSummaryGeojson: HomeProjectSummaryType = { + const convertedHomeProjectSummaryGeojson: geojsonObjectModelType = { ...geojsonObjectModel, features: homeProjectSummary.map((project) => ({ type: 'Feature', From a35fb80a6127778d30b170a4bb7feb3cdcc2c644 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 17:29:59 +0545 Subject: [PATCH 33/35] fix(customizedImage): update ts types --- src/frontend/src/utilities/CustomizedImage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/utilities/CustomizedImage.tsx b/src/frontend/src/utilities/CustomizedImage.tsx index 155d52e5cc..ddbec7da3a 100755 --- a/src/frontend/src/utilities/CustomizedImage.tsx +++ b/src/frontend/src/utilities/CustomizedImage.tsx @@ -5,13 +5,13 @@ import { LazyLoadImage } from 'react-lazy-load-image-component'; type switcherType = { status: 'card' | 'logo'; - width: number; - height: number; + width: string | number; + height?: string | number; }; type CustomizedImageType = { status: 'card' | 'logo'; - style: { width: number; height: number }; + style: { width: string | number; height?: string | number }; }; const Switcher = ({ status, width, height }: switcherType) => { From 119387e78e80586181f7affb14bc31dac4665e37 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Thu, 8 Aug 2024 17:30:51 +0545 Subject: [PATCH 34/35] fix(organisationGridCard): add ts type --- .../src/components/organisation/OrganisationGridCard.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/components/organisation/OrganisationGridCard.tsx b/src/frontend/src/components/organisation/OrganisationGridCard.tsx index 1181d06207..7dd4a05655 100644 --- a/src/frontend/src/components/organisation/OrganisationGridCard.tsx +++ b/src/frontend/src/components/organisation/OrganisationGridCard.tsx @@ -3,8 +3,14 @@ import CoreModules from '@/shared/CoreModules'; import CustomizedImage from '@/utilities/CustomizedImage'; import { useNavigate } from 'react-router-dom'; import { user_roles } from '@/types/enums'; +import { GetOrganisationDataModel } from '@/models/organisation/organisationModel'; -const OrganisationGridCard = ({ filteredData, allDataLength }) => { +type organizationGridCardType = { + filteredData: GetOrganisationDataModel[]; + allDataLength: number; +}; + +const OrganisationGridCard = ({ filteredData, allDataLength }: organizationGridCardType) => { const navigate = useNavigate(); const authDetails = CoreModules.useAppSelector((state) => state.login.authDetails); const cardStyle = { From 95cdb7846a75aaab97b32c53432c1d4848819d1e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:59:23 +0000 Subject: [PATCH 35/35] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../src/components/createnewproject/DataExtract.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/components/createnewproject/DataExtract.tsx b/src/frontend/src/components/createnewproject/DataExtract.tsx index 8bfda464dc..4efe9ad4ea 100644 --- a/src/frontend/src/components/createnewproject/DataExtract.tsx +++ b/src/frontend/src/components/createnewproject/DataExtract.tsx @@ -226,13 +226,11 @@ const DataExtract = ({ flag, customDataExtractUpload, setCustomDataExtractUpload
Map Features

- - You may either choose to use OSM data, or upload your own data for the mapping project. - + You may either choose to use OSM data, or upload your own data for the mapping project. The relevant map features that exist on OSM are imported based on the select map area.{' '} - You can use these map features to use the 'select from map' functionality from ODK that allows you - to select the feature to collect data for. + You can use these map features to use the 'select from map' functionality from ODK that allows you to select + the feature to collect data for. {' '}