import { queryOptions } from '@tanstack/react-query';
import { getCourseById, getCourses } from './service';
import type { Course, CourseFilters } from './types';

export type { Course };

export const courseKeys = {
  all: ['courses'] as const,
  list: (filters: CourseFilters) => [...courseKeys.all, 'list', filters] as const,
  detail: (id: number) => [...courseKeys.all, 'detail', id] as const
};

export const coursesQueryOptions = (filters: CourseFilters) =>
  queryOptions({
    queryKey: courseKeys.list(filters),
    queryFn: () => getCourses(filters)
  });

export const courseByIdOptions = (id: number) =>
  queryOptions({
    queryKey: courseKeys.detail(id),
    queryFn: () => getCourseById(id)
  });
