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