11import * as React from 'react'
22import * as CR from 'typings'
3- import Router from './components/Router'
3+ import useRouter from './components/Router'
44import Workspace from './components/Workspace'
55import ContinuePage from './containers/Continue'
66import LoadingPage from './containers/LoadingPage'
@@ -9,44 +9,41 @@ import OverviewPage from './containers/Overview'
99import CompletedPage from './containers/Tutorial/CompletedPage'
1010import LevelSummaryPage from './containers/Tutorial/LevelPage'
1111
12- const { Route } = Router
13-
14- const tempSend = ( action : any ) => console . log ( 'sent' )
15-
1612const Routes = ( ) => {
13+ const { context, send, Router, Route } = useRouter ( )
1714 // TODO refactor for typescript to understand send & context passed into React.cloneElement's
1815 return (
1916 < Workspace >
2017 < Router >
2118 < Route path = { [ 'Start.Startup' , 'Start.Authenticate' , 'Start.NewOrContinue' ] } >
22- < LoadingPage text = "Launching..." context = { { } as CR . MachineContext } />
19+ < LoadingPage text = "Launching..." context = { context } />
2320 </ Route >
2421 < Route path = { 'Start.Error' } >
2522 < div > Something went wrong wrong</ div >
2623 </ Route >
2724 < Route path = "Start.SelectTutorial" >
28- < NewPage send = { tempSend } context = { { } as CR . MachineContext } />
25+ < NewPage send = { send } context = { context } />
2926 </ Route >
3027 < Route path = "Start.ContinueTutorial" >
31- < ContinuePage send = { tempSend } context = { { } as CR . MachineContext } />
28+ < ContinuePage send = { send } context = { context } />
3229 </ Route >
3330 < Route path = { 'Tutorial.Error' } >
3431 < div > Something went wrong wrong</ div >
3532 </ Route >
3633 < Route path = "Tutorial.Initialize" >
37- < LoadingPage text = "Initializing..." context = { { } as CR . MachineContext } />
34+ < LoadingPage text = "Initializing..." context = { context } />
3835 </ Route >
3936 < Route path = "Tutorial.LoadNext" >
40- < LoadingPage text = "Loading..." context = { { } as CR . MachineContext } />
37+ < LoadingPage text = "Loading..." context = { context } />
4138 </ Route >
4239 < Route path = "Tutorial.Summary" >
43- < OverviewPage send = { tempSend } context = { { } as CR . MachineContext } />
40+ < OverviewPage send = { send } context = { context } />
4441 </ Route >
4542 < Route path = "Tutorial.Level" >
46- < LevelSummaryPage send = { tempSend } context = { { } as CR . MachineContext } />
43+ < LevelSummaryPage send = { send } context = { context } />
4744 </ Route >
4845 < Route path = "Tutorial.Completed" >
49- < CompletedPage send = { tempSend } context = { { } as CR . MachineContext } />
46+ < CompletedPage send = { send } context = { context } />
5047 </ Route >
5148 </ Router >
5249 </ Workspace >
0 commit comments