Skip to content

Commit 9741642

Browse files
authored
Merge pull request #226 from mapswipe/fix/add-image-validate
fix:Add image validate
2 parents 90a8dbf + ed86cf7 commit 9741642

File tree

8 files changed

+30
-5
lines changed

8 files changed

+30
-5
lines changed

public/locales/en/data.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"build-area": "Find",
55
"footprint": "Validate",
66
"change-detection": "Compare",
7+
"validate-image": "Validate Image",
78
"project-card-progress-text": "{{progress, number}}% completed",
89
"project-card-last-update": "{{date, datetime}}",
910
"project-card-contributors-text": "{{contributors}}",

public/locales/en/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"build-area": "Find",
2525
"footprint": "Validate",
2626
"change-detection": "Compare",
27+
"validate-image": "Validate Image",
2728
"project-tab-head": "{{projectTitle}} | MapSwipe",
2829
"Location": "Location",
2930
"requesting-organization": "Requesting organization",

src/components/ProjectTypeIcon/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { _cs } from '@togglecorp/fujs';
3+
import { IoImagesOutline } from 'react-icons/io5';
34

45
import styles from './styles.module.css';
56

@@ -15,7 +16,7 @@ const sizeToStyleMap: {
1516

1617
export interface Props {
1718
className?: string;
18-
type: '1' | '2' | '3';
19+
type: '1' | '2' | '3' | '10';
1920
size?: SizeTypes;
2021
}
2122
function ProjectTypeIcon(props: Props) {
@@ -72,6 +73,9 @@ function ProjectTypeIcon(props: Props) {
7273
</g>
7374
</svg>
7475
)}
76+
{type === '10' && (
77+
<IoImagesOutline />
78+
)}
7579
</>
7680
);
7781
}

src/pages/[locale]/data/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,13 @@ function Data(props: Props) {
340340
<ProjectTypeIcon type="3" size="small" />
341341
),
342342
},
343+
{
344+
key: '10',
345+
label: t('validate-image'),
346+
icon: (
347+
<ProjectTypeIcon type="10" size="small" />
348+
),
349+
},
343350
]), [t]);
344351

345352
const projectTypeOptionsMap = useMemo(() => (

src/pages/[locale]/projects/[id].tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,13 @@ function Project(props: Props) {
269269
<ProjectTypeIcon type="3" size="small" />
270270
),
271271
},
272+
10: {
273+
key: '10',
274+
label: t('validate-image'),
275+
icon: (
276+
<ProjectTypeIcon type="10" size="small" />
277+
),
278+
},
272279
}), [t]);
273280

274281
return (

src/utils/common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66

77
export const graphqlEndpoint = process.env.MAPSWIPE_COMMUNITY_API_ENDPOINT as string;
88

9+
export const supportedProjectTypes = [1, 2, 3, 10];
10+
911
export interface Stats {
1012
communityStats: {
1113
totalContributors: number | null | undefined;
@@ -84,7 +86,7 @@ export function memoize<A extends Array<any>, R>(func: (...args: A) => R) {
8486

8587
export type ProjectStatus = 'private_active' | 'private_inactive' | 'private_finished' | 'active' | 'inactive' | 'finished' | 'archived' | 'tutorial';
8688

87-
export type ProjectType = 1 | 2 | 3 | 4;
89+
export type ProjectType = 1 | 2 | 3 | 4 | 10;
8890

8991
export interface ProjectStatusOption {
9092
key: ProjectStatus;
@@ -105,6 +107,7 @@ export const projectNameMapping: {
105107
2: 'Footprint',
106108
3: 'Change Detection',
107109
4: 'Completeness',
110+
10: 'Validate Image',
108111
};
109112

110113
const mb = 1024 * 1024;

src/utils/requests/projectCentroids.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ProjectStatus,
88
ProjectType,
99
parseProjectName,
10+
supportedProjectTypes,
1011
} from 'utils/common';
1112

1213
const readFile = util.promisify(fs.readFile);
@@ -81,10 +82,10 @@ const getProjectCentroids = memoize(async (): Promise<ProjectResponse> => {
8182
const filteredProjects = {
8283
...projects,
8384
features: projects.features.filter((feature) => {
84-
if (!feature.geometry) {
85+
if (!supportedProjectTypes.includes(feature.properties.project_type)) {
8586
return false;
8687
}
87-
if (feature.properties.project_type > 3) {
88+
if (feature.properties.project_type !== 10 && !feature.geometry) {
8889
return false;
8990
}
9091
return (

src/utils/requests/projectGeometries.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ProjectType,
88
timeIt,
99
parseProjectName,
10+
supportedProjectTypes,
1011
} from 'utils/common';
1112

1213
const readFile = util.promisify(fs.readFile);
@@ -77,7 +78,7 @@ const getProjectGeometries = memoize(async (): Promise<ProjectGeometryResponse>
7778
if (!feature.geometry) {
7879
return false;
7980
}
80-
if (feature.properties.project_type > 3) {
81+
if (!supportedProjectTypes.includes(feature.properties.project_type)) {
8182
return false;
8283
}
8384
return (

0 commit comments

Comments
 (0)