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

import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { Target } from '@overflow/commons-typescript/model/target';

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

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

  constructor(public payload: Target) {}
}

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

  constructor(public payload: Target) {}
}

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

  constructor(public payload: RPCClientError) {}
}

export type Actions =
  | Modify
  | ModifySuccess
  | ModifyFailure
;
