import {
  type PaginatedResponse,
  type PaginationParams,
} from 'src/utils/pagination';

import { type LearningDuration } from '../common/types';
import { type CourseListItem } from '../courses/types';

export enum PathStatus {
  ALL = 'ALL',
  PENDING = 'PENDING',
  FINISHED = 'FINISHED',
  IN_PROGRESS = 'IN_PROGRESS',
}

export enum PathOrderBy {
  TITLE = 'TITLE',
  DUE_DATE = 'DUE_DATE',
  CREATED_AT = 'CREATED_AT',
  PROGRESS = 'PROGRESS',
  FINISHED_AT = 'FINISHED_AT',
  DEFAULT = 'DEFAULT_ORDER',
}

export enum PathCourseStatus {
  FINISHED = 'FINISHED',
  IN_PROGRESS = 'IN_PROGRESS',
  PENDING = 'PENDING',
  BLOCKED = 'BLOCKED',
}

export enum StartPathEventReason {
  NEW = 'new',
  RESUMED = 'resumed',
}

export type PathListItem = {
  id: number;
  title: string;
  dueDate?: string;
  isObligatory: boolean;
  pictureUrl?: string;
  progress: number;
  coursesAmount: number;
  status: PathStatus;
};

export type PathCourseListItem = Pick<
  CourseListItem,
  | 'id'
  | 'status'
  | 'progress'
  | 'title'
  | 'pictureUrl'
  | 'durationTime'
  | 'category'
> & {
  tag: string;
  createdAt: string;
  updatedAt: string;
  finishedAt: string;
};

export type Path = PathListItem & {
  userId: number;
  description: string;
  duration: number;
  durationTime: LearningDuration;
  issueCertificate: boolean;
  isSequential: boolean;
  createdAt: string;
  finishedAt: string;
  courses: PathCourseListItem[];
  certUrl?: string;
};

export type GetPathsParams = PaginationParams & {
  status: PathStatus;
};

export type GetPathsResponse = {
  learningPaths: PaginatedResponse<PathListItem>;
};
