import { Action } from '@ngrx/store';

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

import { DomainMember } from '@overflow/commons-typescript/model/domain';
import { Member } from '@overflow/commons-typescript/model/member';

export enum ActionType {
  SigninSuccess = '[auth.auth] SigninSuccess',

  SigninCookieSuccess = '[auth.auth] SigninCookieSuccess',

  SignoutSuccess = '[auth.auth] SignoutSuccess',

  ModifySuccess = '[auth.auth] ModifySuccess',
}

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

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

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

  constructor(public payload: {domainMember: DomainMember, returnURL: string}) {}
}

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

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

  constructor(public payload: Member) {}
}


export type Actions =
  | SigninSuccess
  | SigninCookieSuccess
  | SignoutSuccess
  | ModifySuccess
;
