File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
import _ from 'lodash'
2
2
import qs from 'qs'
3
3
import { axiosInstance } from './axiosWithAuth'
4
- import { updateChallengePhaseBeforeSendRequest , convertChallengePhaseFromSecondsToHours } from '../util/date'
4
+ import { updateChallengePhaseBeforeSendRequest , convertChallengePhaseFromSecondsToHours , sortChallengePhases } from '../util/date'
5
5
import FormData from 'form-data'
6
6
const {
7
7
CHALLENGE_API_URL ,
@@ -88,6 +88,7 @@ export async function fetchChallenge (challengeId) {
88
88
}
89
89
}
90
90
convertChallengePhaseFromSecondsToHours ( newResponse . phases )
91
+ newResponse . phases = sortChallengePhases ( newResponse . phases )
91
92
return newResponse
92
93
}
93
94
Original file line number Diff line number Diff line change @@ -56,6 +56,15 @@ export const convertChallengePhaseFromSecondsToHours = (phases) => {
56
56
}
57
57
}
58
58
59
+ /**
60
+ * Sorts the challenge phases in order of their supposed execution
61
+ *
62
+ * @param {Array } phases challenge phases that are to be sorte3d
63
+ */
64
+ export const sortChallengePhases = ( phases ) => {
65
+ return _ . sortBy ( phases , phase => phase . actualStartDate || phase . scheduledStartDate )
66
+ }
67
+
59
68
/**
60
69
* Convert challenge phase from hours to second and remove unnessesary field
61
70
* @param {Object } challengeDetail challenge detail
You can’t perform that action at this time.
0 commit comments