import { parseAsString, parseAsStringEnum, parseAsArrayOf, useQueryStates } from "nuqs";

import { TaskStatus } from "../types";

export type GroupByOption = "none" | "assignee" | "status" | "priority" | "labels" | "project";
export type LabelsOperator = "AND" | "OR";

export const useTaskFilters = () => {
  return useQueryStates({
    projectId: parseAsString,
    status: parseAsStringEnum(Object.values(TaskStatus)),
    assigneeId: parseAsString,
    search: parseAsString,
    dueDate: parseAsString,
    labels: parseAsArrayOf(parseAsString),
    groupBy: parseAsString.withDefault("none"),
    labelsOperator: parseAsString.withDefault("OR"),
  });
};
