Skip to content

Commit

Permalink
add sorting function based on flagging status
Browse files Browse the repository at this point in the history
  • Loading branch information
helihard committed Feb 3, 2025
1 parent 07891f5 commit 66c2715
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ import useToggleDebounce from 'utils/hooks/useToggleDebounce';

type OrganizerActionViewCell = null | ZetkinOrganizerAction[];

const sortByOa = (
v1: ZetkinOrganizerAction[],
v2: ZetkinOrganizerAction[]
): number => {
const hasActions = (v: ZetkinOrganizerAction[]): boolean => {
return v.length > 0;
};

const getSortValue = (v: ZetkinOrganizerAction[]): number => {
if (!hasActions(v)) {
return 2;
}
if (v.every((oan) => oan.organizer_action_taken)) {
return 1;
}
return 0;
};

return getSortValue(v1) - getSortValue(v2);
};

export default class OrganizerActionColumnType implements IColumnType {
cellToString(cell: OrganizerActionViewCell): string {
const requiresAction = cell?.length
Expand All @@ -53,6 +74,7 @@ export default class OrganizerActionColumnType implements IColumnType {
/>
);
},
sortComparator: (v1, v2) => sortByOa(v1, v2),
};
}

Expand Down

0 comments on commit 66c2715

Please sign in to comment.