plane/apps/app/helpers/state.helper.ts
Aaryan Khandelwal 8e3541b947
fix: mutation of states (#256)
* feat: label grouping, fix: new states response

* fix: mutation of states
2023-02-08 23:58:17 +05:30

19 lines
616 B
TypeScript

// types
import { IState, StateResponse } from "types";
export const orderStateGroups = (unorderedStateGroups: StateResponse) =>
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();
};