Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

660 B
Raw Blame
type LabelSource = {
  id: string;
  name: string;
  color: string;
  taskId: string | null;
};

export type CalendarLabelOption = {
  value: string;
  label: string;
  color: string;
};

export function getCalendarLabelOptions(
  labels: LabelSource[],
): CalendarLabelOption[] {
  const byName = new Map<string, LabelSource>();
  for (const label of labels) {
    if (!byName.has(label.name) || label.taskId === null) {
      byName.set(label.name, label);
    }
  }

  return [...byName.values()]
    .map((label) => ({
      value: label.id,
      label: label.name,
      color: label.color,
    }))
    .sort((a, b) => a.label.localeCompare(b.label));
}