@@ -32,17 +32,24 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
3232
3333 const currentLevel = levels [ levelIndex ]
3434
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+
3540 const levelUI : T . LevelUI = {
3641 ...currentLevel ,
3742 status : progress . levels [ position . levelId ] ? 'COMPLETE' : 'ACTIVE' ,
38- steps : currentLevel . steps . map ( ( step : TT . Step ) => {
43+ steps : currentLevel . steps . map ( ( step : TT . Step , index ) => {
3944 // label step status for step component
4045 let status : T . ProgressStatus = 'INCOMPLETE'
4146 let subtasks
42- if ( progress . steps [ step . id ] ) {
47+ if ( index < stepIndex || ( index === stepIndex && progress . steps [ step . id ] ) ) {
4348 status = 'COMPLETE'
44- } else if ( step . id === position . stepId ) {
49+ } else if ( index === stepIndex ) {
4550 status = 'ACTIVE'
51+ } else {
52+ status = 'INCOMPLETE'
4653 }
4754 if ( step . subtasks && step . subtasks ) {
4855 const testSummaries = Object . keys ( testStatus ?. summary || { } )
@@ -95,10 +102,6 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
95102
96103 const levelsUI : T . LevelUI [ ] = [ ...completed , levelUI , ...incompleted ]
97104
98- let stepIndex = levelUI . steps . findIndex ( ( s : T . StepUI ) => s . status === 'ACTIVE' )
99- if ( stepIndex === - 1 ) {
100- stepIndex = levels [ levelIndex ] . steps . length
101- }
102105 return { level : levelUI , levels : levelsUI , levelIndex, stepIndex }
103106}
104107
0 commit comments