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

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

import { Probe } from '@overflow/commons-typescript/model/probe';


export enum ActionType {
  Modify = '[probe.modify] Modify',
  ModifyDisplayName = '[probe.modify] ModifyDisplayName',
  ModifySuccess = '[probe.modify] ModifySuccess',
  ModifyFailure = '[probe.modify] ModifyFailure',
}

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

  constructor(public payload: Probe) {}
}

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

  constructor(public payload: Probe) {}
}

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

  constructor(public payload: RPCClientError) {}
}

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

  constructor(public payload: {id: string, displayName: string}) {}
}


export type Actions =
  | Modify
  | ModifySuccess
  | ModifyFailure
  | ModifyDisplayName
;
