@@ -32,17 +32,24 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
3232
3333const 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+
3540const levelUI :T . LevelUI = {
3641 ...currentLevel ,
3742status :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
4045let status :T . ProgressStatus = 'INCOMPLETE'
4146let subtasks
42- if ( progress . steps [ step . id ] ) {
47+ if ( index < stepIndex || ( index === stepIndex && progress . steps [ step . id ] ) ) {
4348status = 'COMPLETE'
44- } else if ( step . id === position . stepId ) {
49+ } else if ( index === stepIndex ) {
4550status = 'ACTIVE'
51+ } else {
52+ status = 'INCOMPLETE'
4653}
4754if ( step . subtasks && step . subtasks ) {
4855const testSummaries = Object . keys ( testStatus ?. summary || { } )
@@ -95,10 +102,6 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
95102
96103const 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- }
102105return { level :levelUI , levels :levelsUI , levelIndex, stepIndex}
103106}
104107