import { Action } from '@ngrx/store';
import { RESTClientError } from '@loafer/ng-rest';

export enum ActionType {
  SigninRedirect = '[app.signin] SigninRedirect',
  SigninCookie = '[app.signin] SigninCookie',
  SigninCookieFailure = '[app.signin] SigninCookieFailure',
}

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

  constructor(public payload: {returnURL: string}) {}
}

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

  constructor(public payload: { authToken: string, returnURL: string }) { }
}

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

  constructor(public payload: RESTClientError) {}
}


export type Actions =
  | SigninRedirect
  | SigninCookie
  | SigninCookieFailure
;
