|
| 1 | +import*asCRfrom'typings' |
| 2 | + |
| 3 | +// temporary tutorials |
| 4 | +importbasicTutorialfrom'../../state/context/tutorials/basic' |
| 5 | + |
| 6 | +interfaceOptions{ |
| 7 | +resource:string |
| 8 | +params?:any |
| 9 | +} |
| 10 | + |
| 11 | +consttutorialsData:{[key:string]:CR.Tutorial}={ |
| 12 | +tutorialId:basicTutorial, |
| 13 | +} |
| 14 | + |
| 15 | +// TODO: replace with fetch resource |
| 16 | +exportdefaultasyncfunctionfetch(options:Options):Promise<any>{ |
| 17 | +console.log('options',options) |
| 18 | +switch(options.resource){ |
| 19 | +case'getTutorialsSummary': |
| 20 | +// list of ids with summaries |
| 21 | +letdata:{[id:string]:CR.TutorialSummary}={} |
| 22 | +for(consttutorialofObject.values(tutorialsData)){ |
| 23 | +data[tutorial.id]=tutorial.data.summary |
| 24 | +} |
| 25 | +returndata |
| 26 | +case'getTutorial': |
| 27 | +// specific tutorial by id |
| 28 | +returntutorialsData[options.params.id] |
| 29 | +default: |
| 30 | +thrownewError('Resource not found') |
| 31 | +} |
| 32 | +} |