2023-02-08 13:21:03 +00:00
|
|
|
// types
|
2023-04-22 12:49:35 +00:00
|
|
|
import { IState, IStateResponse } from "types";
|
2023-02-08 13:21:03 +00:00
|
|
|
|
2023-04-22 12:49:35 +00:00
|
|
|
export const orderStateGroups = (unorderedStateGroups: IStateResponse) =>
|
2023-02-08 13:21:03 +00:00
|
|
|
Object.assign(
|
|
|
|
{ backlog: [], unstarted: [], started: [], completed: [], cancelled: [] },
|
|
|
|
unorderedStateGroups
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getStatesList = (stateGroups: any): IState[] => {
|
|
|
|
// order the unordered state groups first
|
2023-02-08 18:28:17 +00:00
|
|
|
const orderedStateGroups = orderStateGroups(stateGroups);
|
2023-02-08 13:21:03 +00:00
|
|
|
|
|
|
|
// extract states from the groups and return them
|
|
|
|
return Object.keys(orderedStateGroups)
|
|
|
|
.map((group) => [...orderedStateGroups[group].map((state: IState) => state)])
|
|
|
|
.flat();
|
|
|
|
};
|