import { UserBody } from '../models';

enum ActionKey {
  EMPLOYER_DETAILS_REQUEST = 'EMPLOYER/EMPLOYER_DETAILS_REQUEST',
  EMPLOYER_DETAILS_SUCCESS = 'EMPLOYER/EMPLOYER_DETAILS_SUCCESS',
  EMPLOYER_DETAILS_FAIL = 'EMPLOYER/EMPLOYER_DETAILS_FAIL',
}

export type EmployerDetailsRequest = {
  type: ActionKey.EMPLOYER_DETAILS_REQUEST;
  employerId: string,
};
export function employerDetailsRequest(employerId: string): EmployerDetailsRequest {
  return {
    type: ActionKey.EMPLOYER_DETAILS_REQUEST,
    employerId,
  };
}

export type EmployerDetailsSuccess = {
  type: ActionKey.EMPLOYER_DETAILS_SUCCESS;
  user: UserBody,
};
export function employerDetailsSuccess(user: UserBody): EmployerDetailsSuccess {
  return {
    type: ActionKey.EMPLOYER_DETAILS_SUCCESS,
    user,
  };
}

export type EmployerDetailsFailed = {
  type: ActionKey.EMPLOYER_DETAILS_FAIL;
  error: string,
};
export function employerDetailsFail(error: string): EmployerDetailsFailed {
  return {
    type: ActionKey.EMPLOYER_DETAILS_FAIL,
    error,
  };
}

type ActionType = EmployerDetailsSuccess | EmployerDetailsSuccess | EmployerDetailsFailed;

export { ActionKey, ActionType };
