import { type Pagination } from 'src/utils/tableUtils';

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

export const coursesKeys = {
  all: () => ['courses'],
  list: {
    all: () => [...coursesKeys.all(), 'list'],
    paginated: (pagination: CoursesListParams) => [
      ...coursesKeys.list.all(),
      pagination,
    ],
  },
  metrics: () => [...coursesKeys.all(), 'metrics'],
  categories: {
    all: () => [...coursesKeys.all(), 'categories'],
    list: () => [...coursesKeys.categories.all(), 'categories'],
    paginatedList: (params: Pagination) => [
      ...coursesKeys.categories.all(),
      'paginated-categories',
      JSON.stringify(params),
    ],
  },
  courseOnPath: (id: number) => [...coursesKeys.all(), 'courseOnPath', id],
  detail: {
    all: () => [...coursesKeys.all(), 'detail'],
    course: (id: number | string) => [...coursesKeys.detail.all(), Number(id)],
    audience: (id: number | string) => [
      ...coursesKeys.detail.course(id),
      'audience',
    ],
    reports: {
      all: (id: number | string) => [
        ...coursesKeys.detail.course(id),
        'reports',
      ],
      colabs: {
        all: (id: number | string) => [
          ...coursesKeys.detail.reports.all(id),
          'colabs',
        ],
        list: (id: number | string, pagination: Pagination) => [
          ...coursesKeys.detail.reports.colabs.all(id),
          'list',
          pagination,
        ],
        metrics: (id: number | string) => [
          ...coursesKeys.detail.reports.colabs.all(id),
          'metrics',
        ],
      },
      surveys: {
        all: (id: number | string) => [
          ...coursesKeys.detail.reports.all(id),
          'surveys',
        ],
        list: (id: number | string, pagination: Pagination) => [
          ...coursesKeys.detail.reports.surveys.all(id),
          'list',
          pagination,
        ],
        metrics: (id: number | string) => [
          ...coursesKeys.detail.reports.surveys.all(id),
          'metrics',
        ],
      },
      evaluations: {
        all: (id: number | string) => [
          ...coursesKeys.detail.reports.all(id),
          'evaluations',
        ],
        list: (id: number | string, pagination: Pagination) => [
          ...coursesKeys.detail.reports.evaluations.all(id),
          'list',
          pagination,
        ],
      },
    },
  },
};
