plane/apps/app/helpers/state.helper.ts

19 lines
618 B
TypeScript
Raw Permalink Normal View History

// types
2023-04-22 12:49:35 +00:00
import { IState, IStateResponse } from "types";
2023-04-22 12:49:35 +00:00
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();
};