interface TokenData {
  exp: number;
  iat: number;
  auth_time: number;
  jti: string;
  iss: string;
  aud: string[];
  sub: string;
  typ: string;
  azp: string;
  nonce: string;
  session_state: string;
  acr: string;
  "allowed-origins": string[];
  realm_access: Realmaccess;
  resource_access: Resourceaccess;
  scope: string;
  sid: string;
  email_verified: boolean;
  name: string;
  preferred_username: string;
  given_name: string;
  family_name: string;
  email: string;
}

interface Resourceaccess {
  journal: Realmaccess;
}

interface Realmaccess {
  roles: (string | "teacher")[];
}

export interface UserData extends TokenData {
  sub: string;
  gravatar: string;
  email_verified: boolean;
  attributes: Record<string, string[]>;
  name: string;
  preferred_username: string;
  given_name: string;
  family_name: string;
  email: string;
}

export type BaseResponse<Data> = {
  success: boolean;
  body: Data;
};

export interface Lesson {
  id: string;
  _id: string;
  name: string;
  students: User[];
  teachers: Teacher[];
  date: string;
  created: string;
}

interface Teacher {
  sub: string;
  email_verified: boolean;
  preferred_username: string;
}

export interface AccessCode {
  expires: string;
  lesson: Lesson;
  _id: string;
  created: string;
}

export interface User {
  sub: string;
  email_verified: boolean;
  gravatar: string;
  name: string;
  groups: string[];
  preferred_username: string;
  given_name: string;
  family_name: string;
  email: string;
  picture?: string;
}

export interface Course {
  _id: string;
  id: string;
  name: string;
  teachers: User[];
  lessons: string[];
  creator: User;
  startDt: string;
  examWithJury?: string;
  created: string;
}

export interface PopulatedCourse extends Omit<Course, 'examWithJury' | 'lessons'> {
  examWithJury: ExamWithJury;
  lessons: Lesson[];
}

interface ExamWithJury {
  name: string;
  description: string;
  jury: any[];
  date: string;
  created: string;
  criterias: Criteria[][];
  id: string;
}

interface Criteria {
  title: string;
  type?: string;
  min?: number;
  max?: number;
  wight?: number;
  subcriterias?: Subcriteria[];
}

interface Subcriteria {
  title: string;
  type: string;
  wight: number;
  trueText?: string;
  falseText?: string;
  min?: number;
  max?: number;
}