Skip to content

Commit f057e6f

Browse files
committed
feat(manager-dashboard): handle default custom options on project type change
1 parent dedd455 commit f057e6f

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

manager-dashboard/app/views/NewTutorial/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import {
7777
import {
7878
tileServerUrls,
7979
tutorialFormSchema,
80-
defaultFootprintCustomOptions,
80+
getDefaultOptions,
8181
TutorialFormType,
8282
PartialTutorialFormType,
8383
PartialInformationPagesType,
@@ -342,7 +342,6 @@ const defaultTutorialFormValue: PartialTutorialFormType = {
342342
name: TILE_SERVER_ESRI,
343343
credits: tileServerDefaultCredits[TILE_SERVER_ESRI],
344344
},
345-
customOptions: defaultFootprintCustomOptions,
346345
};
347346

348347
type SubmissionStatus = 'started' | 'imageUpload' | 'tutorialSubmit' | 'success' | 'failed';
@@ -717,6 +716,7 @@ function NewTutorial(props: Props) {
717716
setFieldValue(undefined, 'tutorialTasks');
718717
setFieldValue(undefined, 'scenarioPages');
719718
setFieldValue(newValue, 'projectType');
719+
setFieldValue(getDefaultOptions(newValue), 'customOptions');
720720
},
721721
[setFieldValue],
722722
);

manager-dashboard/app/views/NewTutorial/utils.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
PROJECT_TYPE_CHANGE_DETECTION,
2727
PROJECT_TYPE_COMPLETENESS,
2828
PROJECT_TYPE_FOOTPRINT,
29+
PROJECT_TYPE_STREET,
2930
IconKey,
3031
} from '#utils/common';
3132

@@ -257,6 +258,33 @@ export const defaultFootprintCustomOptions: PartialTutorialFormType['customOptio
257258
},
258259
];
259260

261+
export const defaultStreetCustomOptions: PartialTutorialFormType['customOptions'] = [
262+
{
263+
optionId: 1,
264+
value: 1,
265+
title: 'Yes',
266+
icon: 'checkmark-outline',
267+
iconColor: colorKeyToColorMap.green,
268+
description: '',
269+
},
270+
{
271+
optionId: 2,
272+
value: 0,
273+
title: 'No',
274+
icon: 'close-outline',
275+
iconColor: colorKeyToColorMap.red,
276+
description: '',
277+
},
278+
{
279+
optionId: 3,
280+
value: 2,
281+
title: 'Not Sure',
282+
icon: 'remove-outline',
283+
iconColor: colorKeyToColorMap.gray,
284+
description: 'if you\'re not sure or there is bad imagery',
285+
},
286+
];
287+
260288
export function deleteKey<T extends object, K extends keyof T>(
261289
value: T,
262290
key: K,
@@ -268,6 +296,18 @@ export function deleteKey<T extends object, K extends keyof T>(
268296
return copy;
269297
}
270298

299+
export function getDefaultOptions(projectType: ProjectType | undefined) {
300+
if (projectType === PROJECT_TYPE_FOOTPRINT) {
301+
return defaultFootprintCustomOptions;
302+
}
303+
304+
if (projectType === PROJECT_TYPE_STREET) {
305+
return defaultStreetCustomOptions;
306+
}
307+
308+
return undefined;
309+
}
310+
271311
export interface BuildAreaProperties {
272312
reference: number;
273313
screen: number;

0 commit comments

Comments
 (0)