1
1
import { Button , Step } from '@alifd/next'
2
2
import * as React from 'react'
3
- import CR from 'typings'
3
+ import * as T from 'typings/graphql '
4
4
5
5
import Markdown from '../Markdown'
6
6
import StepDescription from './StepDescription'
@@ -23,36 +23,39 @@ const styles = {
23
23
}
24
24
25
25
interface Props {
26
- stage : CR . TutorialStage
27
- steps : {
28
- [ stepId : string ] : any // CC.Step
29
- }
26
+ stage : T . Stage
30
27
complete : boolean
31
28
onContinue ( ) : void
32
29
}
33
30
34
- const Stage = ( { stage, steps, onContinue, complete } : Props ) => {
35
- const { stepList, content } = stage
36
- const { title, text } = content
31
+ const Stage = ( { stage, onContinue, complete } : Props ) => {
32
+ if ( ! stage . steps ) {
33
+ throw new Error ( 'No Stage steps found' )
34
+ }
35
+
37
36
// grab the active step
38
- const activeIndex = stepList . findIndex ( ( stepId : string ) => {
39
- return steps [ stepId ] . status . active
37
+ const activeIndex : number = stage . steps . findIndex ( ( step : T . Step | null ) => {
38
+ return step && step . status === 'ACTIVE'
40
39
} )
40
+
41
41
return (
42
42
< div style = { styles . card } >
43
43
< div style = { styles . content } >
44
- < h2 style = { styles . title } > { title } </ h2 >
45
- < Markdown > { text } </ Markdown >
44
+ < h2 style = { styles . title } > { stage . title } </ h2 >
45
+ < Markdown > { stage . text || '' } </ Markdown >
46
46
</ div >
47
47
< div style = { styles . steps } >
48
48
< Step current = { activeIndex } direction = "ver" shape = "dot" animation readOnly >
49
- { stepList . map ( ( stepId : string , index : number ) => {
50
- const step = steps [ stepId ]
49
+ { stage . steps . map ( ( step : T . Step | null , index : number ) => {
50
+ if ( ! step ) {
51
+ return null
52
+ }
53
+ const hide = status === 'INCOMPLETE'
51
54
return (
52
55
< Step . Item
53
- key = { stepId }
54
- title = { step . content . title || `Step ${ index + 1 } ` }
55
- content = { < StepDescription content = { step . content } status = { step . status } /> }
56
+ key = { step . id }
57
+ title = { step . title || `Step ${ index + 1 } ` }
58
+ content = { < StepDescription text = { step . text } hide = { hide } /> }
56
59
/>
57
60
)
58
61
} ) }
0 commit comments