@@ -32,17 +32,24 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
32
32
33
33
const currentLevel = levels [ levelIndex ]
34
34
35
+ let stepIndex = currentLevel . steps . findIndex ( ( s : TT . Step ) => s . id === position . stepId )
36
+ if ( stepIndex === - 1 ) {
37
+ stepIndex = levels [ levelIndex ] . steps . length
38
+ }
39
+
35
40
const levelUI : T . LevelUI = {
36
41
...currentLevel ,
37
42
status : progress . levels [ position . levelId ] ? 'COMPLETE' : 'ACTIVE' ,
38
- steps : currentLevel . steps . map ( ( step : TT . Step ) => {
43
+ steps : currentLevel . steps . map ( ( step : TT . Step , index ) => {
39
44
// label step status for step component
40
45
let status : T . ProgressStatus = 'INCOMPLETE'
41
46
let subtasks
42
- if ( progress . steps [ step . id ] ) {
47
+ if ( index < stepIndex || ( index === stepIndex && progress . steps [ step . id ] ) ) {
43
48
status = 'COMPLETE'
44
- } else if ( step . id === position . stepId ) {
49
+ } else if ( index === stepIndex ) {
45
50
status = 'ACTIVE'
51
+ } else {
52
+ status = 'INCOMPLETE'
46
53
}
47
54
if ( step . subtasks && step . subtasks ) {
48
55
const testSummaries = Object . keys ( testStatus ?. summary || { } )
@@ -95,10 +102,6 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
95
102
96
103
const levelsUI : T . LevelUI [ ] = [ ...completed , levelUI , ...incompleted ]
97
104
98
- let stepIndex = levelUI . steps . findIndex ( ( s : T . StepUI ) => s . status === 'ACTIVE' )
99
- if ( stepIndex === - 1 ) {
100
- stepIndex = levels [ levelIndex ] . steps . length
101
- }
102
105
return { level : levelUI , levels : levelsUI , levelIndex, stepIndex }
103
106
}
104
107
0 commit comments