mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
22 lines
700 B
TypeScript
22 lines
700 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 = Object.assign(
|
||
|
{ backlog: [], unstarted: [], started: [], completed: [], cancelled: [] },
|
||
|
stateGroups
|
||
|
);
|
||
|
|
||
|
// extract states from the groups and return them
|
||
|
return Object.keys(orderedStateGroups)
|
||
|
.map((group) => [...orderedStateGroups[group].map((state: IState) => state)])
|
||
|
.flat();
|
||
|
};
|