Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat ts type add #1286

Merged
merged 8 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/frontend/src/store/slices/CommonSlice.ts
Original file line number Diff line number Diff line change
@@ -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 { CommonStateTypes } from '@/store/types/ICommon';

const initialState: CommonStateTypes = {
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;
Expand Down
43 changes: 28 additions & 15 deletions src/frontend/src/store/slices/HomeSlice.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import CoreModules from '@/shared/CoreModules';
import { HomeStateTypes } from '@/store/types/IHome';

const initialState: HomeStateTypes = {
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;
Expand Down
12 changes: 8 additions & 4 deletions src/frontend/src/store/slices/LoginSlice.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import CoreModules from '@/shared/CoreModules';
import storage from 'redux-persist/lib/storage';
import { LoginStateTypes } from '@/store/types/ILogin';

const initialState: LoginStateTypes = {
loginToken: {},
authDetails: {},
};

const LoginSlice = CoreModules.createSlice({
name: 'login',
initialState: {
loginToken: {},
authDetails: {},
},
initialState: initialState,
reducers: {
SetLoginToken(state, action) {
state.loginToken = action.payload;
Expand Down
54 changes: 33 additions & 21 deletions src/frontend/src/store/slices/ProjectSlice.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
import { createSlice } from '@reduxjs/toolkit';
import storage from 'redux-persist/lib/storage';
import { ProjectStateTypes } from '@/store/types/IProject';

const initialState: ProjectStateTypes = {
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;
Expand Down
31 changes: 17 additions & 14 deletions src/frontend/src/store/slices/TaskSlice.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { createSlice } from '@reduxjs/toolkit';
import { TaskStateTypes, taskInfoType } from '@/store/types/ITask';

const initialState: TaskStateTypes = {
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;
Expand All @@ -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;

Expand Down
17 changes: 17 additions & 0 deletions src/frontend/src/store/types/ICommon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export type CommonStateTypes = {
snackbar: snackbarTypes;
loading: boolean;
postOrganisationLoading: boolean;
currentStepFormStep: {
create_project: {
step: number;
};
};
};

type snackbarTypes = {
open: boolean;
message: string;
variant: 'info' | 'success' | 'error' | 'warning';
duration: number;
};
45 changes: 45 additions & 0 deletions src/frontend/src/store/types/IHome.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export type HomeStateTypes = {
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;
};
13 changes: 13 additions & 0 deletions src/frontend/src/store/types/ILogin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type LoginStateTypes = {
loginToken: logintTokenType | {};
authDetails: {} | string;
};

type logintTokenType = {
id: string;
osm_oauth_token: string;
picture: string;
role: string;
sessionToken: string | null;
username: string;
};
Loading
Loading