import { Action } from '@ngrx/store';
import { User } from 'src/modules/user/model/user.model';

export enum ActionType {
  LoginProcessing = '[account.auth] LoginProcessing',

  LoginSuccess = '[account.auth] LoginSuccess',
  LogoutSuccess = '[account.auth] LogoutSuccess',
  ChangeUser = '[account.auth] ChangeUser',
  LoginRequired = '[account.auth] LoginRequired',
}

export class LoginProcessing implements Action {
  readonly type = ActionType.LoginProcessing;

  constructor(public payload: { processing: boolean }) { }
}

export class LoginSuccess implements Action {
  readonly type = ActionType.LoginSuccess;

  constructor(public payload: { user: User, returnURL: string }) { }
}

export class ChangeUser implements Action {
  readonly type = ActionType.ChangeUser;

  constructor(public payload: { user: User }) { }
}

export class LogoutSuccess implements Action {
  readonly type = ActionType.LogoutSuccess;
}

export class LoginRequired implements Action {
  readonly type = ActionType.LoginRequired;

  constructor() { }
}


export type Actions =
  | LoginProcessing
  | LoginSuccess
  | ChangeUser
  | LogoutSuccess
  | LoginRequired
  ;
