2023-02-08 13:21:03 +00:00
|
|
|
// types
|
2023-12-14 11:15:39 +00:00
|
|
|
import { STATE_GROUP_KEYS } from "constants/project";
|
|
|
|
import { IState, IStateResponse } from "types";
|
2023-02-08 13:21:03 +00:00
|
|
|
|
2023-11-08 15:01:46 +00:00
|
|
|
export const orderStateGroups = (unorderedStateGroups: IStateResponse | undefined): IStateResponse | undefined => {
|
2023-07-26 17:50:44 +00:00
|
|
|
if (!unorderedStateGroups) return undefined;
|
2023-11-08 15:01:46 +00:00
|
|
|
return Object.assign({ backlog: [], unstarted: [], started: [], completed: [], cancelled: [] }, unorderedStateGroups);
|
2023-02-08 13:21:03 +00:00
|
|
|
};
|
2023-12-14 11:15:39 +00:00
|
|
|
|
|
|
|
export const sortStates = (states: IState[]) => {
|
|
|
|
if (!states || states.length === 0) return null;
|
|
|
|
|
|
|
|
return states.sort((stateA, stateB) => {
|
|
|
|
if (stateA.group === stateB.group) {
|
|
|
|
return stateA.sequence - stateB.sequence;
|
|
|
|
}
|
|
|
|
return STATE_GROUP_KEYS.indexOf(stateA.group) - STATE_GROUP_KEYS.indexOf(stateB.group);
|
|
|
|
});
|
|
|
|
};
|