import { queryOptions } from '@tanstack/react-query';
import { getEmployeeDirectory, getEmployeeDirectoryTarget } from './service';
import type { EmployeeDirectoryFilters } from './types';

export const employeeDirectoryKeys = {
  all: ['employee-directory'] as const,
  list: (filters: EmployeeDirectoryFilters) =>
    [...employeeDirectoryKeys.all, 'list', filters] as const,
  target: (id: number, year?: number) =>
    [...employeeDirectoryKeys.all, 'target', id, year ?? 'current'] as const
};

export const employeeDirectoryQueryOptions = (filters: EmployeeDirectoryFilters) =>
  queryOptions({
    queryKey: employeeDirectoryKeys.list(filters),
    queryFn: () => getEmployeeDirectory(filters)
  });

export const employeeDirectoryTargetQueryOptions = (id: number, year?: number) =>
  queryOptions({
    queryKey: employeeDirectoryKeys.target(id, year),
    queryFn: () => getEmployeeDirectoryTarget(id, year)
  });
