import { BaseFields } from ".";

export interface User {
  id: string;
  created_at: string;
  email: string;
  external_id: string | null;
  first_name: string | null;
  gender: string | null;
  last_name: string | null;
  password?: string;
  language: string | null;
  phone_number: string | null;
  /**
   * @deprecated Use employee.profile_picture
   */
  profile_picture: string | null;
  state: State;
  timezone: string;
  updated_at: string;
  employee_activation?: string;
}

interface BaseRole {
  id: string;
  created_at: string;
  updated_at: string;
}

export interface ContactRole extends BaseRole {
  uuid: string | null;
  default_week_template: string | null;
  function: string | null;
  introduction: string | null;
  is_active: boolean;
  video_url?: string | null;
  timezone: null | string;
  default_week_template_id: string | null;
}

export interface AdminRole extends BaseRole {
  is_owner: boolean;
}

export interface CentralPlannerRole extends BaseRole {}
export interface OfficeManagerRole extends BaseRole {}

export enum State {
  PENDING = 0,
  SUSPENDED = 4,
  ACTIVE = 8,
}

export type RoleIdentifier = "central_planner" | "contact" | "admin" | "office_manager";

export interface ContactInfo extends BaseFields {
  email: string;
  phone_number: string | null;
  profile_picture: number | null;
  state: State;
  updated_at: string;
  user_id: string | null;
}

export interface WithEmployeeUser {
  user: User | null;
}

export interface WithEmployeeRoles {
  roles: {
    central_planner?: CentralPlannerRole;
    contact?: ContactRole;
    admin?: AdminRole;
    office_manager?: OfficeManagerRole;
  };
}

export interface Employee extends ContactInfo {}

export interface WithContactEmployee {
  roles: {
    contact: ContactRole;
  };
}

export interface WithOfficeManagerEmployee {
  roles: {
    office_manager: OfficeManagerRole;
  };
}

export interface FavoriteContact {
  contact_id: string;
  office_id: string;
}

export interface Admin extends ContactInfo {
  roles: {
    admin?: AdminRole;
  };
}

export interface CentralPlanner extends ContactInfo {
  roles: {
    admin?: CentralPlannerRole;
  };
}

export interface OfficeManager extends ContactInfo {
  roles: {
    office_manager?: OfficeManagerRole;
  };
}

export interface Contact extends ContactInfo {
  roles: {
    contact?: ContactRole;
  };
}
