()
| 13 | * we have to implement a custom router here |
| 14 | */ |
| 15 | const Routes = () => { |
| 16 | const { context, route, send } = useStateMachine() |
| 17 | |
| 18 | // TODO: handle only full page errors |
| 19 | if (context.error) { |
| 20 | return <ErrorView send={send} error={context.error} /> |
| 21 | } |
| 22 | |
| 23 | logger( |
| 24 | `ROUTE: "${route}": ${context.position?.complete ? 'Completed' : 'On'} level ${ |
| 25 | context.position?.levelId || 'unknown' |
| 26 | }, step ${context.position?.stepId || 'unknown'}`, |
| 27 | ) |
| 28 | |
| 29 | return ( |
| 30 | <Router route={route}> |
| 31 | {/* Setup */} |
| 32 | <Route paths={{ Setup: { Startup: true, ValidateSetup: true } }}> |
| 33 | <LoadingPage text="Launching..." processes={context.processes} /> |
| 34 | </Route> |
| 35 | <Route paths={{ Setup: { Start: true } }}> |
| 36 | <StartPage send={send} context={context} /> |
| 37 | </Route> |
| 38 | <Route paths={{ Setup: { SelectTutorial: true } }}> |
| 39 | <SelectTutorialPage send={send} context={context} /> |
| 40 | </Route> |
| 41 | <Route paths={{ Setup: { SetupNewTutorial: true, StartTutorial: true } }}> |
| 42 | <LoadingPage text="Configuring tutorial..." /> |
| 43 | </Route> |
| 44 | {/* Tutorial */} |
| 45 | <Route paths={{ Tutorial: { Level: { Load: true } } }}> |
| 46 | <LoadingPage text="Loading Level..." processes={context.processes} /> |
| 47 | </Route> |
| 48 | <Route paths={{ Tutorial: { Reset: true } }}> |
| 49 | <LoadingPage text="Resetting tutorial..." processes={context.processes} /> |
| 50 | </Route> |
| 51 | <Route paths={{ Tutorial: { Level: true, Completed: true } }}> |
| 52 | <TutorialPage send={send} context={context} state={route.replace('Tutorial.', '')} /> |
| 53 | </Route> |
| 54 | </Router> |
| 55 | ) |
| 56 | } |
| 57 | |
| 58 | export default Routes |
nothing calls this directly
no test coverage detected