From 4c601a9b8053fb73ce8f2fd0e415f4a22db59c2a Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Tue, 27 Feb 2024 09:31:56 +0545 Subject: [PATCH 1/7] feat taskSlice: ts types add --- src/frontend/src/store/slices/TaskSlice.ts | 31 ++++++++++++---------- src/frontend/src/store/types/ITask.ts | 31 ++++++++++++++++++++++ 2 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 src/frontend/src/store/types/ITask.ts diff --git a/src/frontend/src/store/slices/TaskSlice.ts b/src/frontend/src/store/slices/TaskSlice.ts index b15a726dc8..c70fa4ae90 100644 --- a/src/frontend/src/store/slices/TaskSlice.ts +++ b/src/frontend/src/store/slices/TaskSlice.ts @@ -1,20 +1,23 @@ import { createSlice } from '@reduxjs/toolkit'; +import { ITaskSlice, taskInfoType } from '@/store/types/ITask'; + +const initialState: ITaskSlice = { + taskLoading: false, + taskInfo: [], + selectedTask: null, + projectBoundaryLoading: false, + projectBoundary: [], + convertToOsmLoading: false, + convertToOsm: [], + downloadSubmissionLoading: { type: '', loading: false }, + convertXMLToJOSMLoading: false, + josmEditorError: null, + taskData: { feature_count: 0, submission_count: 0, task_count: 0 }, +}; const TaskSlice = createSlice({ name: 'task', - initialState: { - taskLoading: false, - taskInfo: [], - selectedTask: null, - projectBoundaryLoading: false, - projectBoundary: [], - convertToOsmLoading: null, - convertToOsm: [], - downloadSubmissionLoading: { type: '', loading: false }, - convertXMLToJOSMLoading: false, - josmEditorError: null, - taskData: { feature_count: 0, submission_count: 0, task_count: 0 }, - }, + initialState: initialState, reducers: { SetTaskLoading(state, action) { state.taskLoading = action.payload; @@ -26,7 +29,7 @@ const TaskSlice = createSlice({ state.convertToOsmLoading = action.payload; }, FetchTaskInfoDetails(state, action) { - const taskInfo = action.payload; + const taskInfo: taskInfoType[] = action.payload; state.taskInfo = taskInfo; diff --git a/src/frontend/src/store/types/ITask.ts b/src/frontend/src/store/types/ITask.ts new file mode 100644 index 0000000000..449ab8c0ea --- /dev/null +++ b/src/frontend/src/store/types/ITask.ts @@ -0,0 +1,31 @@ +export type ITaskSlice = { + taskLoading: boolean; + taskInfo: taskInfoType[]; + selectedTask: number | null; + projectBoundaryLoading: boolean; + projectBoundary: []; + convertToOsmLoading: boolean; + convertToOsm: []; + downloadSubmissionLoading: downloadSubmissionLoadingTypes; + convertXMLToJOSMLoading: boolean; + josmEditorError: null | string; + taskData: taskDataTypes; +}; + +export type taskInfoType = { + task_id: string; + submission_count: number; + last_submission: string | null; + feature_count: number; +}; + +type downloadSubmissionLoadingTypes = { + type: '' | 'json' | 'csv'; + loading: boolean; +}; + +type taskDataTypes = { + feature_count: number; + submission_count: number; + task_count: number; +}; From 5d39bc1896631fa69e011a1b7508984af7d84d4a Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Tue, 27 Feb 2024 09:58:44 +0545 Subject: [PATCH 2/7] feat submissionSlice: ts types add --- src/frontend/src/store/types/ISubmissions.ts | 32 +++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/store/types/ISubmissions.ts b/src/frontend/src/store/types/ISubmissions.ts index 1aa6a165f9..aa443085a6 100644 --- a/src/frontend/src/store/types/ISubmissions.ts +++ b/src/frontend/src/store/types/ISubmissions.ts @@ -1,15 +1,39 @@ export type SubmissionStateTypes = { submissionDetailsLoading: boolean; submissionDetails: []; - submissionInfographics: []; + submissionInfographics: submissionInfographicsTypes[]; submissionInfographicsLoading: boolean; - submissionContributors: []; + submissionContributors: submissionContributorsTypes[]; submissionContributorsLoading: boolean; - submissionFormFields: []; + submissionFormFields: submissionFormFieldsTypes[]; submissionTableData: []; submissionFormFieldsLoading: boolean; submissionTableDataLoading: boolean; submissionTableRefreshing: boolean; - validatedVsMappedInfographics: []; + validatedVsMappedInfographics: validatedVsMappedInfographicsTypes[]; validatedVsMappedLoading: boolean; }; + +type submissionInfographicsTypes = { + date: string; + count: 1; +}; + +type submissionContributorsTypes = { + user: string; + contributions: number; +}; + +type submissionFormFieldsTypes = { + path: string; + name: string; + type: string; + binary: any; + selectMultiple: any; +}; + +type validatedVsMappedInfographicsTypes = { + date: string; + validated: number; + mapped: number; +}; From e8fb093202f2ef8d0c647a50798691f837d0a03d Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Tue, 27 Feb 2024 11:36:02 +0545 Subject: [PATCH 3/7] feat projectSlice: ts types add --- src/frontend/src/store/slices/ProjectSlice.ts | 54 +++++---- src/frontend/src/store/types/IProject.ts | 114 ++++++++++++++++++ 2 files changed, 147 insertions(+), 21 deletions(-) create mode 100644 src/frontend/src/store/types/IProject.ts diff --git a/src/frontend/src/store/slices/ProjectSlice.ts b/src/frontend/src/store/slices/ProjectSlice.ts index 352cd1a377..1fa3a41de4 100755 --- a/src/frontend/src/store/slices/ProjectSlice.ts +++ b/src/frontend/src/store/slices/ProjectSlice.ts @@ -1,29 +1,41 @@ import { createSlice } from '@reduxjs/toolkit'; import storage from 'redux-persist/lib/storage'; +import { ProjectType } from '@/store/types/IProject'; + +const initialState: ProjectType = { + projectLoading: true, + projectTaskBoundries: [], + newProjectTrigger: false, + projectInfo: {}, + projectSubmissionLoading: false, + projectSubmission: [], + projectDataExtractLoading: false, + downloadProjectFormLoading: { type: 'form', loading: false }, + generateProjectTilesLoading: false, + tilesList: [], + tilesListLoading: false, + downloadTilesLoading: false, + downloadDataExtractLoading: false, + taskModalStatus: false, + mobileFooterSelection: 'explore', + geolocationStatus: false, + projectDetailsLoading: true, + projectDashboardDetail: { + project_name_prefix: '', + organisation_name: '', + total_tasks: null, + created: '', + organisation_logo: '', + total_submission: null, + total_contributors: null, + last_active: '', + }, + projectDashboardLoading: false, +}; const ProjectSlice = createSlice({ name: 'project', - initialState: { - projectLoading: true, - projectTaskBoundries: [], - newProjectTrigger: false, - projectInfo: {}, - projectSubmissionLoading: false, - projectSubmission: [], - projectDataExtractLoading: false, - downloadProjectFormLoading: { type: 'form', loading: false }, - generateProjectTilesLoading: false, - tilesList: [], - tilesListLoading: false, - downloadTilesLoading: false, - downloadDataExtractLoading: false, - taskModalStatus: false, - mobileFooterSelection: 'explore', - geolocationStatus: false, - projectDetailsLoading: true, - projectDashboardDetail: {}, - projectDashboardLoading: false, - }, + initialState: initialState, reducers: { SetProjectTaskBoundries(state, action) { state.projectTaskBoundries = action.payload; diff --git a/src/frontend/src/store/types/IProject.ts b/src/frontend/src/store/types/IProject.ts new file mode 100644 index 0000000000..0951789645 --- /dev/null +++ b/src/frontend/src/store/types/IProject.ts @@ -0,0 +1,114 @@ +export type ProjectType = { + projectLoading: boolean; + projectTaskBoundries: projectTaskBoundriesType[]; + newProjectTrigger: boolean; + projectInfo: projectInfoType | {}; + projectSubmissionLoading: boolean; + projectSubmission: []; + projectDataExtractLoading: boolean; + downloadProjectFormLoading: downloadProjectFormLoadingType; + generateProjectTilesLoading: boolean; + tilesList: tilesListTypes[]; + tilesListLoading: boolean; + downloadTilesLoading: boolean; + downloadDataExtractLoading: boolean; + taskModalStatus: boolean; + mobileFooterSelection: string; + geolocationStatus: boolean; + projectDetailsLoading: boolean; + projectDashboardDetail: projectDashboardDetailTypes; + projectDashboardLoading: boolean; +}; + +type projectTaskBoundriesType = { + id: number; + taskBoundries: taskBoundriesTypes[]; +}; + +type taskBoundriesTypes = { + bbox: [number, number]; + id: number; + locked_by_uid: null | string; + locked_by_username: null | string; + odk_token: string; + outline_geojson: { + type: string; + geometry: { + coordinates: [string, string]; + type: string; + }; + properties: Record; + id: string; + bbox: [string, string, string, string]; + }; + outline_centroid: { + type: string; + geometry: { + coordinates: [string, string]; + type: string; + }; + properties: Record; + id: string; + bbox: [string, string, string, string]; + }; + task_history: taskHistoryTypes[]; + task_status: string; +}; + +type projectInfoType = { + id: number; + outline_geojson: { + type: string; + geometry: { + type: string; + coordinates: []; + }; + properties: { + id: number; + bbox: [number, number, number, number]; + }; + id: number; + }; + priority: number; + priority_str: string; + title: string; + location_str: string; + description: string; + short_description: string; + xform_title: string; + data_extract_url: string; + num_contributors: any; + tasks_bad: any; + tasks_mapped: any; + tasks_validated: any; + total_tasks: any; +}; + +type taskHistoryTypes = { + action_date: string; + action_text: string; + id: number; + profile_img: null | string; + status: string; + username: string; +}; + +type downloadProjectFormLoadingType = { type: 'form' | 'geojson'; loading: boolean }; + +type tilesListTypes = { + id: number; + project_id: number; + status: string; + tile_source: string; +}; + +type projectDashboardDetailTypes = { + project_name_prefix: string; + organisation_name: string; + total_tasks: number | null; + created: string; + organisation_logo: string; + total_submission: number | null; + total_contributors: number | null; + last_active: string; +}; From 5e5b807d12a55786498589112ce583144c9ad9ac Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Tue, 27 Feb 2024 11:50:25 +0545 Subject: [PATCH 4/7] feat loginSlice: ts types add --- src/frontend/src/store/slices/LoginSlice.ts | 12 ++++++++---- src/frontend/src/store/types/ILogin.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 src/frontend/src/store/types/ILogin.ts diff --git a/src/frontend/src/store/slices/LoginSlice.ts b/src/frontend/src/store/slices/LoginSlice.ts index a829cc6ba5..4bf3dd1005 100755 --- a/src/frontend/src/store/slices/LoginSlice.ts +++ b/src/frontend/src/store/slices/LoginSlice.ts @@ -1,11 +1,15 @@ import CoreModules from '@/shared/CoreModules'; import storage from 'redux-persist/lib/storage'; +import { LoginType } from '@/store/types/ILogin'; + +const initialState: LoginType = { + loginToken: {}, + authDetails: {}, +}; + const LoginSlice = CoreModules.createSlice({ name: 'login', - initialState: { - loginToken: {}, - authDetails: {}, - }, + initialState: initialState, reducers: { SetLoginToken(state, action) { state.loginToken = action.payload; diff --git a/src/frontend/src/store/types/ILogin.ts b/src/frontend/src/store/types/ILogin.ts new file mode 100644 index 0000000000..3b197467c7 --- /dev/null +++ b/src/frontend/src/store/types/ILogin.ts @@ -0,0 +1,13 @@ +export type LoginType = { + loginToken: logintTokenType | {}; + authDetails: {} | string; +}; + +type logintTokenType = { + id: string; + osm_oauth_token: string; + picture: string; + role: string; + sessionToken: string | null; + username: string; +}; From ceba1f69814302bd05de1afdab9bc15f8fba296d Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Tue, 27 Feb 2024 12:29:20 +0545 Subject: [PATCH 5/7] feat homeSlice: ts types add --- src/frontend/src/store/slices/HomeSlice.ts | 43 +++++++++++++-------- src/frontend/src/store/types/IHome.ts | 45 ++++++++++++++++++++++ 2 files changed, 73 insertions(+), 15 deletions(-) create mode 100644 src/frontend/src/store/types/IHome.ts diff --git a/src/frontend/src/store/slices/HomeSlice.ts b/src/frontend/src/store/slices/HomeSlice.ts index 430a7a0f21..dd78f61e6f 100755 --- a/src/frontend/src/store/slices/HomeSlice.ts +++ b/src/frontend/src/store/slices/HomeSlice.ts @@ -1,21 +1,34 @@ import CoreModules from '@/shared/CoreModules'; +import { Home } from '@/store/types/IHome'; + +const initialState: Home = { + homeProjectSummary: [], + homeProjectLoading: true, + selectedProject: {}, + dialogStatus: false, + snackbar: { + open: false, + message: '', + variant: 'info', + duration: 0, + }, + showMapStatus: true, + projectCentroidLoading: false, + homeProjectPagination: { + has_next: false, + has_prev: false, + next_num: null, + page: null, + pages: null, + prev_num: null, + per_page: null, + total: null, + }, +}; + const HomeSlice = CoreModules.createSlice({ name: 'home', - initialState: { - homeProjectSummary: [], - homeProjectLoading: true, - selectedProject: {}, - dialogStatus: false, - snackbar: { - open: false, - message: '', - variant: 'info', - duration: 0, - }, - showMapStatus: true, - projectCentroidLoading: false, - homeProjectPagination: {}, - }, + initialState: initialState, reducers: { SetHomeProjectSummary(state, action) { state.homeProjectSummary = action.payload; diff --git a/src/frontend/src/store/types/IHome.ts b/src/frontend/src/store/types/IHome.ts new file mode 100644 index 0000000000..9cc23c71d8 --- /dev/null +++ b/src/frontend/src/store/types/IHome.ts @@ -0,0 +1,45 @@ +export type Home = { + homeProjectSummary: homeProjectSummaryType[]; + selectedProject: homeProjectSummaryType; + homeProjectLoading: boolean; + dialogStatus: boolean; + snackbar: snackbarTypes; + showMapStatus: boolean; + projectCentroidLoading: boolean; + homeProjectPagination: homeProjectPaginationTypes; +}; + +type homeProjectSummaryType = { + centroid?: [number, number]; + description?: string; + hashtags?: string | null; + id?: number; + location_str?: string; + num_contributors?: number; + organisation_id?: number; + organisation_logo?: string | null; + priority?: number; + tasks_bad?: number; + tasks_mapped?: number; + tasks_validated?: number; + title?: string; + total_tasks?: number; +}; + +type snackbarTypes = { + open: boolean; + message: string; + variant: 'info' | 'success' | 'error' | 'warning'; + duration: number; +}; + +type homeProjectPaginationTypes = { + has_next: boolean; + has_prev: boolean; + next_num: number | null; + page: number | null; + pages: number | null; + prev_num: number | null; + per_page: number | null; + total: number | null; +}; From 71c19a401919367aaf7facd7873df17a71a34246 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Tue, 27 Feb 2024 12:36:35 +0545 Subject: [PATCH 6/7] feat commonSlice: ts types add --- src/frontend/src/store/slices/CommonSlice.ts | 34 +++++++++++--------- src/frontend/src/store/types/ICommon.ts | 17 ++++++++++ 2 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 src/frontend/src/store/types/ICommon.ts diff --git a/src/frontend/src/store/slices/CommonSlice.ts b/src/frontend/src/store/slices/CommonSlice.ts index b3f9ddca23..b70a97cba5 100755 --- a/src/frontend/src/store/slices/CommonSlice.ts +++ b/src/frontend/src/store/slices/CommonSlice.ts @@ -1,21 +1,25 @@ import CoreModules from '@/shared/CoreModules'; -const CommonSlice = CoreModules.createSlice({ - name: 'common', - initialState: { - snackbar: { - open: false, - message: '', - variant: 'info', - duration: 0, - }, - loading: false, - postOrganisationLoading: false, - currentStepFormStep: { - create_project: { - step: 1, - }, +import { CommonType } from '@/store/types/ICommon'; + +const initialState: CommonType = { + snackbar: { + open: false, + message: '', + variant: 'info', + duration: 0, + }, + loading: false, + postOrganisationLoading: false, + currentStepFormStep: { + create_project: { + step: 1, }, }, +}; + +const CommonSlice = CoreModules.createSlice({ + name: 'common', + initialState: initialState, reducers: { SetSnackBar(state, action) { state.snackbar = action.payload; diff --git a/src/frontend/src/store/types/ICommon.ts b/src/frontend/src/store/types/ICommon.ts new file mode 100644 index 0000000000..0262484cbe --- /dev/null +++ b/src/frontend/src/store/types/ICommon.ts @@ -0,0 +1,17 @@ +export type CommonType = { + snackbar: snackbarTypes; + loading: boolean; + postOrganisationLoading: boolean; + currentStepFormStep: { + create_project: { + step: number; + }; + }; +}; + +type snackbarTypes = { + open: boolean; + message: string; + variant: 'info' | 'success' | 'error' | 'warning'; + duration: number; +}; From 73be8a2b0d530597add0eb01d8a344a7d4afc624 Mon Sep 17 00:00:00 2001 From: NSUWAL123 Date: Tue, 27 Feb 2024 12:48:56 +0545 Subject: [PATCH 7/7] fix sliceTypes: sliceTypes name change --- src/frontend/src/store/slices/CommonSlice.ts | 4 ++-- src/frontend/src/store/slices/HomeSlice.ts | 4 ++-- src/frontend/src/store/slices/LoginSlice.ts | 4 ++-- src/frontend/src/store/slices/ProjectSlice.ts | 4 ++-- src/frontend/src/store/slices/TaskSlice.ts | 4 ++-- src/frontend/src/store/types/ICommon.ts | 2 +- src/frontend/src/store/types/IHome.ts | 2 +- src/frontend/src/store/types/ILogin.ts | 2 +- src/frontend/src/store/types/IProject.ts | 2 +- src/frontend/src/store/types/ITask.ts | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/frontend/src/store/slices/CommonSlice.ts b/src/frontend/src/store/slices/CommonSlice.ts index b70a97cba5..7269cfd176 100755 --- a/src/frontend/src/store/slices/CommonSlice.ts +++ b/src/frontend/src/store/slices/CommonSlice.ts @@ -1,7 +1,7 @@ import CoreModules from '@/shared/CoreModules'; -import { CommonType } from '@/store/types/ICommon'; +import { CommonStateTypes } from '@/store/types/ICommon'; -const initialState: CommonType = { +const initialState: CommonStateTypes = { snackbar: { open: false, message: '', diff --git a/src/frontend/src/store/slices/HomeSlice.ts b/src/frontend/src/store/slices/HomeSlice.ts index dd78f61e6f..1cc344d8df 100755 --- a/src/frontend/src/store/slices/HomeSlice.ts +++ b/src/frontend/src/store/slices/HomeSlice.ts @@ -1,7 +1,7 @@ import CoreModules from '@/shared/CoreModules'; -import { Home } from '@/store/types/IHome'; +import { HomeStateTypes } from '@/store/types/IHome'; -const initialState: Home = { +const initialState: HomeStateTypes = { homeProjectSummary: [], homeProjectLoading: true, selectedProject: {}, diff --git a/src/frontend/src/store/slices/LoginSlice.ts b/src/frontend/src/store/slices/LoginSlice.ts index 4bf3dd1005..fddc879990 100755 --- a/src/frontend/src/store/slices/LoginSlice.ts +++ b/src/frontend/src/store/slices/LoginSlice.ts @@ -1,8 +1,8 @@ import CoreModules from '@/shared/CoreModules'; import storage from 'redux-persist/lib/storage'; -import { LoginType } from '@/store/types/ILogin'; +import { LoginStateTypes } from '@/store/types/ILogin'; -const initialState: LoginType = { +const initialState: LoginStateTypes = { loginToken: {}, authDetails: {}, }; diff --git a/src/frontend/src/store/slices/ProjectSlice.ts b/src/frontend/src/store/slices/ProjectSlice.ts index 1fa3a41de4..a620e9e1c0 100755 --- a/src/frontend/src/store/slices/ProjectSlice.ts +++ b/src/frontend/src/store/slices/ProjectSlice.ts @@ -1,8 +1,8 @@ import { createSlice } from '@reduxjs/toolkit'; import storage from 'redux-persist/lib/storage'; -import { ProjectType } from '@/store/types/IProject'; +import { ProjectStateTypes } from '@/store/types/IProject'; -const initialState: ProjectType = { +const initialState: ProjectStateTypes = { projectLoading: true, projectTaskBoundries: [], newProjectTrigger: false, diff --git a/src/frontend/src/store/slices/TaskSlice.ts b/src/frontend/src/store/slices/TaskSlice.ts index c70fa4ae90..6a3aa0ed72 100644 --- a/src/frontend/src/store/slices/TaskSlice.ts +++ b/src/frontend/src/store/slices/TaskSlice.ts @@ -1,7 +1,7 @@ import { createSlice } from '@reduxjs/toolkit'; -import { ITaskSlice, taskInfoType } from '@/store/types/ITask'; +import { TaskStateTypes, taskInfoType } from '@/store/types/ITask'; -const initialState: ITaskSlice = { +const initialState: TaskStateTypes = { taskLoading: false, taskInfo: [], selectedTask: null, diff --git a/src/frontend/src/store/types/ICommon.ts b/src/frontend/src/store/types/ICommon.ts index 0262484cbe..83ad79f385 100644 --- a/src/frontend/src/store/types/ICommon.ts +++ b/src/frontend/src/store/types/ICommon.ts @@ -1,4 +1,4 @@ -export type CommonType = { +export type CommonStateTypes = { snackbar: snackbarTypes; loading: boolean; postOrganisationLoading: boolean; diff --git a/src/frontend/src/store/types/IHome.ts b/src/frontend/src/store/types/IHome.ts index 9cc23c71d8..91a83c7a24 100644 --- a/src/frontend/src/store/types/IHome.ts +++ b/src/frontend/src/store/types/IHome.ts @@ -1,4 +1,4 @@ -export type Home = { +export type HomeStateTypes = { homeProjectSummary: homeProjectSummaryType[]; selectedProject: homeProjectSummaryType; homeProjectLoading: boolean; diff --git a/src/frontend/src/store/types/ILogin.ts b/src/frontend/src/store/types/ILogin.ts index 3b197467c7..84b59759e8 100644 --- a/src/frontend/src/store/types/ILogin.ts +++ b/src/frontend/src/store/types/ILogin.ts @@ -1,4 +1,4 @@ -export type LoginType = { +export type LoginStateTypes = { loginToken: logintTokenType | {}; authDetails: {} | string; }; diff --git a/src/frontend/src/store/types/IProject.ts b/src/frontend/src/store/types/IProject.ts index 0951789645..88a1b6f873 100644 --- a/src/frontend/src/store/types/IProject.ts +++ b/src/frontend/src/store/types/IProject.ts @@ -1,4 +1,4 @@ -export type ProjectType = { +export type ProjectStateTypes = { projectLoading: boolean; projectTaskBoundries: projectTaskBoundriesType[]; newProjectTrigger: boolean; diff --git a/src/frontend/src/store/types/ITask.ts b/src/frontend/src/store/types/ITask.ts index 449ab8c0ea..758e410e0b 100644 --- a/src/frontend/src/store/types/ITask.ts +++ b/src/frontend/src/store/types/ITask.ts @@ -1,4 +1,4 @@ -export type ITaskSlice = { +export type TaskStateTypes = { taskLoading: boolean; taskInfo: taskInfoType[]; selectedTask: number | null;