import { queryOptions } from '@tanstack/react-query';
import { getOnlineLessonById, getOnlineLessons } from './service';
import type { OnlineLesson, OnlineLessonFilters } from './types';

export type { OnlineLesson };

export const onlineLessonKeys = {
  all: ['online-lessons'] as const,
  list: (filters: OnlineLessonFilters) => [...onlineLessonKeys.all, 'list', filters] as const,
  detail: (id: number) => [...onlineLessonKeys.all, 'detail', id] as const
};

export const onlineLessonsQueryOptions = (filters: OnlineLessonFilters) =>
  queryOptions({
    queryKey: onlineLessonKeys.list(filters),
    queryFn: () => getOnlineLessons(filters)
  });

export const onlineLessonByIdOptions = (id: number) =>
  queryOptions({
    queryKey: onlineLessonKeys.detail(id),
    queryFn: () => getOnlineLessonById(id)
  });
