@@ -51,7 +51,7 @@ import {
5151 TabPanel ,
5252} from '#components/Tabs' ;
5353import TileServerInput , {
54- TILE_SERVER_ESRI ,
54+ TILE_SERVER_BING ,
5555 tileServerDefaultCredits ,
5656} from '#components/TileServerInput' ;
5757import InputSection from '#components/InputSection' ;
@@ -73,10 +73,10 @@ import {
7373 tutorialFormSchema ,
7474 TutorialFormType ,
7575 PartialTutorialFormType ,
76+ PartialInformationPagesType ,
7677 ScenarioPagesType ,
7778 CustomOptionType ,
7879 InformationPagesType ,
79- PartialInformationPagesType ,
8080 colorKeyToColorMap ,
8181 InformationPageTemplateKey ,
8282 infoPageTemplateoptions ,
@@ -90,6 +90,22 @@ import ScenarioPageInput from './ScenarioPageInput';
9090import InformationPageInput from './InformationPageInput' ;
9191import styles from './styles.css' ;
9292
93+ type CustomScreen = Omit < TutorialFormType [ 'scenarioPages' ] [ number ] , 'scenarioId' > ;
94+ function sanitizeScreens ( scenarioPages : TutorialFormType [ 'scenarioPages' ] ) {
95+ const screens = scenarioPages . reduce < Record < string , CustomScreen > > (
96+ ( acc , currentValue ) => {
97+ const { scenarioId, ...other } = currentValue ;
98+ acc [ scenarioId ] = {
99+ ...other ,
100+ } ;
101+
102+ return acc ;
103+ } ,
104+ { } ,
105+ ) ;
106+ return screens ;
107+ }
108+
93109const defaultCustomOptions : PartialTutorialFormType [ 'customOptions' ] = [
94110 {
95111 optionId : 1 ,
@@ -116,16 +132,17 @@ const defaultCustomOptions: PartialTutorialFormType['customOptions'] = [
116132 description : 'if you\'re not sure or there is cloud cover / bad imagery' ,
117133 } ,
118134] ;
135+
119136const defaultTutorialFormValue : PartialTutorialFormType = {
120137 projectType : PROJECT_TYPE_BUILD_AREA ,
121138 zoomLevel : 18 ,
122139 tileServer : {
123- name : TILE_SERVER_ESRI ,
124- credits : tileServerDefaultCredits [ TILE_SERVER_ESRI ] ,
140+ name : TILE_SERVER_BING ,
141+ credits : tileServerDefaultCredits [ TILE_SERVER_BING ] ,
125142 } ,
126143 tileServerB : {
127- name : TILE_SERVER_ESRI ,
128- credits : tileServerDefaultCredits [ TILE_SERVER_ESRI ] ,
144+ name : TILE_SERVER_BING ,
145+ credits : tileServerDefaultCredits [ TILE_SERVER_BING ] ,
129146 } ,
130147 customOptions : defaultCustomOptions ,
131148} ;
@@ -223,21 +240,15 @@ function NewTutorial(props: Props) {
223240 informationPages : informationPagesFromForm ,
224241 ...valuesToCopy
225242 } = finalValues ;
226- type Screens = typeof finalValues . scenarioPages ;
227- type Screen = Screens [ number ] ;
228- type CustomScreen = Omit < Screen , 'scenarioId' > ;
229-
230- const screens = scenarioPages . reduce (
231- ( acc , currentValue ) => {
232- const { scenarioId, ...other } = currentValue ;
233- acc [ scenarioId ] = {
234- ...other ,
235- } ;
236243
237- return acc ;
238- } ,
239- { } as Record < string , CustomScreen > ,
240- ) ;
244+ const screens = sanitizeScreens ( scenarioPages ) ;
245+
246+ try {
247+ await navigator . clipboard . writeText ( JSON . stringify ( screens , null , 2 ) ) ;
248+ alert ( 'Tutorial JSON copied to clipboard.' ) ;
249+ } catch ( err ) {
250+ alert ( `Tutorial JSON could not be copied ${ err } ` ) ;
251+ }
241252
242253 const storage = getStorage ( ) ;
243254 const timestamp = ( new Date ( ) ) . getTime ( ) ;
0 commit comments