Skip to content

Commit

Permalink
refactor(frontend): update create_project json structure
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Jan 31, 2024
1 parent dd96fe3 commit e0e7b84
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 30 deletions.
13 changes: 3 additions & 10 deletions src/frontend/src/components/createnewproject/SplitTasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customLineUpload, custo
const drawnGeojson = CoreModules.useAppSelector((state) => state.createproject.drawnGeojson);
const projectDetails = CoreModules.useAppSelector((state) => state.createproject.projectDetails);
const dataExtractGeojson = useAppSelector((state) => state.createproject.dataExtractGeojson);
const userDetails: any = CoreModules.useAppSelector((state) => state.login.loginToken);

const generateQrSuccess: any = CoreModules.useAppSelector((state) => state.createproject.generateQrSuccess);
const projectDetailsResponse = CoreModules.useAppSelector((state) => state.createproject.projectDetailsResponse);
Expand Down Expand Up @@ -109,15 +108,9 @@ const SplitTasks = ({ flag, geojsonFile, setGeojsonFile, customLineUpload, custo
short_description: projectDetails.short_description,
description: projectDetails.description,
},
author: {
username: userDetails.username,
id: userDetails.id,
},
odk_central: {
odk_central_url: projectDetails.odk_central_url,
odk_central_user: projectDetails.odk_central_user,
odk_central_password: projectDetails.odk_central_password,
},
odk_central_url: projectDetails.odk_central_url,
odk_central_user: projectDetails.odk_central_user,
odk_central_password: projectDetails.odk_central_password,
// dont send xform_title if upload custom form is selected
xform_title: projectDetails.formCategorySelection,
task_split_type: splitTasksSelection,
Expand Down
14 changes: 3 additions & 11 deletions src/frontend/src/components/createproject/FormSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ const FormSelection: React.FC<any> = ({

const selectFormWaysList = ['Use Existing Category', 'Upload a Custom Form'];
const selectFormWays = selectFormWaysList.map((item) => ({ label: item, value: item }));
const userDetails: any = CoreModules.useAppSelector((state) => state.login.loginToken);
// //we use use-selector from redux to get all state of loginToken from login slice

const generateProjectLog: any = CoreModules.useAppSelector((state) => state.createproject.generateProjectLog);
// //we use use-selector from redux to get all state of loginToken from login slice
Expand Down Expand Up @@ -81,15 +79,9 @@ const FormSelection: React.FC<any> = ({
short_description: projectDetails.short_description,
description: projectDetails.description,
},
author: {
username: userDetails?.username || 'svcfmtm',
id: userDetails?.id || 20386219,
},
odk_central: {
odk_central_url: projectDetails.odk_central_url,
odk_central_user: projectDetails.odk_central_user,
odk_central_password: projectDetails.odk_central_password,
},
odk_central_url: projectDetails.odk_central_url,
odk_central_user: projectDetails.odk_central_user,
odk_central_password: projectDetails.odk_central_password,
// dont send xform_title if upload custom form is selected
xform_title: projectDetails.form_ways === 'Upload a Form' ? null : projectDetails.xform_title,
dimension: projectDetails.dimension,
Expand Down
4 changes: 0 additions & 4 deletions src/frontend/src/models/createproject/createProjectModel.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export interface ProjectDetailsModel {
id: number;
odkid: number;
author: {
username: string;
id: number;
};
default_locale: string;
project_info: {
locale: string;
Expand Down
5 changes: 0 additions & 5 deletions src/frontend/src/store/types/ICreateProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ export type CreateProjectStateTypes = {
export type ValidateCustomFormResponse = {
detail: { message: string; possible_reason: string };
};
export type AuthorTypes = {
username: string;
id: number;
};

export type GeometryTypes = {
type: string;
Expand Down Expand Up @@ -82,7 +78,6 @@ export type ProjectInfoTypes = {
type EditProjectResponseTypes = {
id: number;
odkid: number;
author: AuthorTypes;
project_info: ProjectInfoTypes[];
status: number;
outline_geojson: GeoJSONFeatureTypes;
Expand Down

0 comments on commit e0e7b84

Please sign in to comment.