import {
  TASK_LIST_SORTABLE_ATTRIBUTES,
  SORT_DIRECTIONS,
} from '../../../constants';

export type TaskListSortableAttribute =
  (typeof TASK_LIST_SORTABLE_ATTRIBUTES)[number];

export type SortDirection = (typeof SORT_DIRECTIONS)[number];

export const isTaskListSortableAttribute = (
  arg: string,
): arg is TaskListSortableAttribute => {
  const param = arg as TaskListSortableAttribute;
  if (TASK_LIST_SORTABLE_ATTRIBUTES.includes(param)) {
    return true;
  }
  return false;
};

export const isSortDirection = (arg: string): arg is SortDirection => {
  const param = arg as SortDirection;
  if (SORT_DIRECTIONS.includes(param)) {
    return true;
  }
  return false;
};
