import { type CourseList } from './types';

export const coursesKeys = {
  all: () => ['courses'],
  allList: () => [...coursesKeys.all(), 'list'],
  list: (pagination: CourseList) => [...coursesKeys.allList(), pagination],
  categories: () => [...coursesKeys.all(), 'categories'],
  detail: {
    all: () => [...coursesKeys.all(), 'detail'],
    course: (id: number | string) => [...coursesKeys.detail.all(), Number(id)],
    init: (id: number | string) => [...coursesKeys.detail.course(id), 'init'],
    survey: (id: number | string) => [
      ...coursesKeys.detail.course(id),
      'survey',
    ],
    sign: (id: number | string) => [coursesKeys.detail.course(id), 'sign'],
  },
  lessons: {
    all: () => [...coursesKeys.all(), 'lessons'],
    lesson: (lessonId: number | string, tag: string) => [
      ...coursesKeys.lessons.all(),
      Number(lessonId),
      tag,
    ],
    init: (lessonId: number | string, tag: string) => [
      coursesKeys.lessons.lesson(lessonId, tag),
      'init',
    ],
    finish: (lessonId: number | string, tag: string) => [
      coursesKeys.lessons.lesson(lessonId, tag),
      'finish',
    ],
    questions: (lessonId: number | string, tag: string) => [
      coursesKeys.lessons.lesson(lessonId, tag),
      'questions',
    ],
  },
};
