11import * as React from 'react'
22import * as CR from 'typings'
3+ import * as G from 'typings/graphql'
34import { useQuery } from '@apollo/react-hooks'
45
5- import currentTutorial from '../../../services/current'
66import ErrorView from '../../../components/Error'
77import Stage from './Stage'
88import queryStage from './queryStage'
@@ -13,12 +13,12 @@ interface PageProps {
1313}
1414
1515const StageSummaryPageContainer = ( props : PageProps ) => {
16- const { tutorialId , version , position : { stageId } } = currentTutorial . get ( )
16+ const { tutorial , position , progress } = props . context
1717 const { loading, error, data } = useQuery ( queryStage , {
1818 variables : {
19- tutorialId,
20- version,
21- stageId,
19+ tutorialId : tutorial . id ,
20+ version : tutorial . version . version ,
21+ stageId : position . stageId ,
2222 } ,
2323 } )
2424 if ( loading ) {
@@ -29,9 +29,17 @@ const StageSummaryPageContainer = (props: PageProps) => {
2929 return < ErrorView error = { error } />
3030 }
3131
32- console . log ( 'data' , data )
33-
34- const { stage } = data . tutorial . version
32+ const { stage } = data . tutorial . version
33+
34+ stage . steps . forEach ( ( step : G . Step ) => {
35+ if ( step . id === position . stepId ) {
36+ step . status = 'ACTIVE'
37+ } else if ( progress . steps [ step . id ] ) {
38+ step . status = 'COMPLETE'
39+ } else {
40+ step . status = 'INCOMPLETE'
41+ }
42+ } )
3543
3644 const onContinue = ( ) : void => {
3745 props . send ( 'STAGE_NEXT' )
0 commit comments