import { Application, ApplicationData } from './application';
import { Location } from './location';

export type UserBody = {
  id: string;
  name: string;
  email: string;
  avatar: string;
  description: string;
  location: Location;
  birthYear?: number;
  phoneNumber?: string;
};

export type EmployerBody = UserBody & {
  website?: string;
  googleID?: string;
  businessLocation?: Location;
};

export type BaseUser = {
  body: UserBody;
  firstLogin?: boolean;
  unsupportedVersion?: boolean;
};

export type FirebaseUser = {
  displayName: string | null
  email: string | null
  emailVerified: boolean
  isAnonymous: boolean
  photoURL: string | null
  providerData: any | null
  providerId: string | null
  uid: string,
};

export type EmployeeData = {
  applications: Array<Application>,
  employers: MapOfEmployers,
};

export type MapOfEmployees = { [employeeId: string]: UserBody };
export type MapOfEmployers = { [employerId: string]: EmployerBody };

export type EmployerData = {
  applications: Array<ApplicationData>,
  employees: MapOfEmployees,
};

export type Employer = BaseUser & {
  role: UserRole.EMPLOYER;
  body: EmployerBody;
};

export type Employee = BaseUser & {
  role: UserRole.EMPLOYEE;
};

export type User = Employee | Employer;

export enum UserRole {
  EMPLOYER = 'employers',
  EMPLOYEE = 'employees',
}
