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

import { RPCClientError } from '@loafer/ng-rpc/protocol';

import { DiscoveryStartInfo } from '@overflow/commons-typescript/model/discovery';

export enum ActionType {
  Setting = '[discovery.setting] Setting',
  SettingSuccess = '[discovery.setting] SettingSuccess',
  SettingFailure = '[discovery.setting] SettingFailure',
  SettingRedirect = '[discovery.setting] SettingRedirect',
}

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

  constructor(public payload: DiscoveryStartInfo) {}
}

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

  constructor(public payload: DiscoveryStartInfo) {}
}

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

  constructor(public payload: RPCClientError) {}
}

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


export type Actions =
  | Setting
  | SettingSuccess
  | SettingFailure
  | SettingRedirect
;
