/* API Interfaces */

import { EmployeeCourseAssessmentResponse } from 'app/models/assessment/employee-assessment.model';

export interface PgCourseProvider {
  courseProviderId: number;
  courseProviderName: string;
  clientId: string;
  clientSecret: string;
}

export interface PgCourseDetails {
  courseDetailsId: number;
  pgCourseProvider: PgCourseProvider;
  courseName: string;
  courseDesc: string;
  duration: string;
  courseLink: string;
  skillTrackId?: any;
  image1: string;
  image2: string;
  image3: string;
  createdBy: string;
  updatedBy: string;
  createdDt: Date;
  assessment?: boolean;
  updatedDt: Date;
  status: string;
}

/* export interface Course {
  userCourseId: number;
  userInfoMstrId: number;
  pgCourseDetails: PgCourseDetails;
  status: string;
  rating?: number;
  recommended?: boolean;
  orgName?: any;
  startDate?: number;
  dueDate?: number;
  courseStatusCount?: any;
  averageRating?: number;
  usersSubscribedToCourse: number[];
  candidate?: any;
} */

export interface UserCourseMapping {
  Open?: Course[];
  Overdue?: Course[];
  'In Progress'?: Course[];
  Completed?: Course[];
  Assessment?: Course[];
}

export interface CapabilityTransformationCourseList {
  userCourseMapping: UserCourseMapping;
  error?: any;
}

/* updateUserCourses enpdoint payload */
export interface CourseUpdatePayload {
  userId: number;
  courseId: number;
  status: string;
}

/* Custom interfaces */
export enum CourseCardType {
  default = 'default',
  open = 'open',
  overdue = 'overdue',
  inprogress = 'inprogress',
  assessment = 'assessment',
  completed = 'completed'
}

export enum CourseStatus {
  Open = 'Open',
  Overdue = 'Overdue',
  InProgress = 'In Progress',
  Completed = 'Completed',
  Assessment = 'Assessment',
}

export interface ICourse extends PgCourseDetails {
  userCourseId: number;
  userInfoMstrId: number;  
  pgGroupCourseDetails?: any;
  rating?: any;
  recommended?: boolean;
  orgName?: any;
  startDate?: any;
  dueDate?: number;
  courseStatusCount?: any;
  averageRating?: any;
  usersSubscribedToCourse?: number[];
}

export interface CourseList {
  name: string;
  type: CourseCardType;
  courses: Course[];
}

export interface CourseListTabs {
  all: UserCourseMappingExtended;
  mandatory: UserCourseMappingExtended;
  personal: UserCourseMappingExtended;
}

export interface UserCourseMappingExtended {
  Open?: CourseList;
  Overdue?: CourseList;
  'In Progress'?: CourseList;
  Completed?: CourseList;
  Assessment?: CourseList;
}

export function createCourseListTabs() {
  return {
    all: {
      Open: { name: 'Open', type: CourseCardType.open, courses: [] },
      Overdue: { name: 'Overdue', type: CourseCardType.overdue, courses: [] },
      'In Progress': { name: 'In Progress', type: CourseCardType.inprogress, courses: [] },
      Assessment: { name: 'Assessment', type: CourseCardType.assessment, courses: [] },
      Completed: { name: 'Completed', type: CourseCardType.completed, courses: [] }
    },
    mandatory: {
      Open: { name: 'Recommended', type: CourseCardType.open, courses: [] },
      Overdue: { name: 'Overdue', type: CourseCardType.overdue, courses: [] },
      'In Progress': { name: 'In Progress', type: CourseCardType.inprogress, courses: [] },
      Assessment: { name: 'Assessment', type: CourseCardType.assessment, courses: [] },
      Completed: { name: 'Completed', type: CourseCardType.completed, courses: [] }
    },
    personal: {
      Open: { name: 'Wishlist', type: CourseCardType.open, courses: [] },
      Overdue: { name: 'Overdue', type: CourseCardType.overdue, courses: [] },
      'In Progress': { name: 'In Progress', type: CourseCardType.inprogress, courses: [] },
      Assessment: { name: 'Assessment', type: CourseCardType.assessment, courses: [] },
      Completed: { name: 'Completed', type: CourseCardType.completed, courses: [] }
    }
  };
}

export class Course implements ICourse {
  public courseDetailsId = 0;
  public pgCourseProvider: PgCourseProvider;
  public courseName: string;
  public courseDesc: string;
  public duration: string;
  public courseLink: string;
  public skillTrackId?: any;
  public image1: string;
  public image2: string;
  public image3: string;
  public createdBy: string;
  public updatedBy: string;
  public createdDt: Date;
  public assessment?: boolean;
  public updatedDt: Date;
  public status: string;
  public userCourseId: number;
  public userInfoMstrId: number;
  public pgGroupCourseDetails?: any;
  public rating?: any;
  public recommended?: boolean;
  public orgName?: any;
  public startDate?: any;
  public dueDate?: number;
  public courseStatusCount?: any;
  public averageRating?: any;
  public usersSubscribedToCourse?: number[];
  public pgCourseDetails: PgCourseDetails;
  /* Candidate response field */
  public candidate?: any;
  /* Custom fields */
  public assessmentDetails: EmployeeCourseAssessmentResponse;
  public assessmentDtls: any;
  public assessmentEvent: any;
  public isType: any;
}

interface allCourses {
  courseDetailsId: number;
  pgCourseProvider: any;
  courseName: string;
  courseDesc: string;
  duration: string;
  courseLink: string;
  skillTrackId: number;
  image1: string;
  image2: string;
  image3: string;
  createdBy: string;
  updatedBy: string;
  createdDt: string;
  updatedDt: string;
  assessment: boolean;
  status: string;
  averageRating: any;
  usersSubscribedToCourse: any;
}
export interface selectedCourse {
  createdBy:string
  createdDt:number
  description:string
  isSelected:boolean
  skillCategoryId:number
  skillCategoryName:string
  status:string
  updatedBy:string
  updatedDt:number
}

export interface CourseDetails {
  allCourses: allCourses;

}