mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
20 lines
757 B
TypeScript
20 lines
757 B
TypeScript
// types
|
|
import { IState, IStateResponse } from "@plane/types";
|
|
import { STATE_GROUPS } from "@/constants/state";
|
|
|
|
export const orderStateGroups = (unorderedStateGroups: IStateResponse | undefined): IStateResponse | undefined => {
|
|
if (!unorderedStateGroups) return undefined;
|
|
return Object.assign({ backlog: [], unstarted: [], started: [], completed: [], cancelled: [] }, unorderedStateGroups);
|
|
};
|
|
|
|
export const sortStates = (states: IState[]) => {
|
|
if (!states || states.length === 0) return;
|
|
|
|
return states.sort((stateA, stateB) => {
|
|
if (stateA.group === stateB.group) {
|
|
return stateA.sequence - stateB.sequence;
|
|
}
|
|
return Object.keys(STATE_GROUPS).indexOf(stateA.group) - Object.keys(STATE_GROUPS).indexOf(stateB.group);
|
|
});
|
|
};
|