Skip to content

Commit 16fa1d1

Browse files
author
Vikas Agarwal
committed
fix: Github issue#666, Standard Design "Edit" Event Sequence Out of Order
1 parent d3da364 commit 16fa1d1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/services/challenges.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import _ from 'lodash'
22
import qs from 'qs'
33
import { axiosInstance } from './axiosWithAuth'
4-
import { updateChallengePhaseBeforeSendRequest, convertChallengePhaseFromSecondsToHours } from '../util/date'
4+
import { updateChallengePhaseBeforeSendRequest, convertChallengePhaseFromSecondsToHours, sortChallengePhases } from '../util/date'
55
import FormData from 'form-data'
66
const {
77
CHALLENGE_API_URL,
@@ -88,6 +88,7 @@ export async function fetchChallenge (challengeId) {
8888
}
8989
}
9090
convertChallengePhaseFromSecondsToHours(newResponse.phases)
91+
newResponse.phases = sortChallengePhases(newResponse.phases)
9192
return newResponse
9293
}
9394

src/util/date.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ export const convertChallengePhaseFromSecondsToHours = (phases) => {
5656
}
5757
}
5858

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+
5968
/**
6069
* Convert challenge phase from hours to second and remove unnessesary field
6170
* @param {Object} challengeDetail challenge detail

0 commit comments

Comments
 (0)