forked from github/plane
19 lines
618 B
TypeScript
19 lines
618 B
TypeScript
// types
|
|
import { IState, IStateResponse } from "types";
|
|
|
|
export const orderStateGroups = (unorderedStateGroups: IStateResponse) =>
|
|
Object.assign(
|
|
{ backlog: [], unstarted: [], started: [], completed: [], cancelled: [] },
|
|
unorderedStateGroups
|
|
);
|
|
|
|
export const getStatesList = (stateGroups: any): IState[] => {
|
|
// order the unordered state groups first
|
|
const orderedStateGroups = orderStateGroups(stateGroups);
|
|
|
|
// extract states from the groups and return them
|
|
return Object.keys(orderedStateGroups)
|
|
.map((group) => [...orderedStateGroups[group].map((state: IState) => state)])
|
|
.flat();
|
|
};
|