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

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

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

export enum ActionType {
  ResetPassword = '[member.resetPassword] ResetPassword',
  ResetPasswordSuccess = '[member.resetPassword] ResetPasswordSuccess',
  ResetPasswordFailure = '[member.resetPassword] ResetPasswordFailure',
}

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

  constructor(public payload: string ) {}
}

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

  constructor(public payload: Member) {}
}

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

  constructor(public payload: RESTClientError) {}
}

export type Actions =
  | ResetPassword
  | ResetPasswordSuccess
  | ResetPasswordFailure
  | ModifyPassword
  | ModifyPasswordSuccess
  | ModifyPasswordFailure
;


export enum ActionType {
  ModifyPassword = '[member.modifyPassword] ModifyPassword',
  ModifyPasswordSuccess = '[member.modifyPassword] ModifyPasswordSuccess',
  ModifyPasswordFailure = '[member.modifyPassword] ModifyPasswordFailure',
}

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

  constructor(public payload: { token: string, pw: string, confirmPw: string } ) {}
}

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

  constructor(public payload: Member) {}
}

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

  constructor(public payload: RESTClientError) {}
}
