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

import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { MetaSensorItemKey } from '@overflow/commons-typescript/model/meta';
import { MetaSensorDisplayItem } from '@overflow/commons-typescript/model/meta';


export enum ActionType {
  ReadAllByDisplayItem = '[meta.sensor-display-key-list] ReadAllByDisplayItem',
  ReadAllByDisplayItemSuccess = '[meta.sensor-display-key-list] ReadAllByDisplayItemSuccess',
  ReadAllByDisplayItemFailure = '[meta.sensor-display-key-list] ReadAllByDisplayItemFailure',
}

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

  constructor(public payload: MetaSensorDisplayItem) {}
}

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

  constructor(public payload: MetaSensorItemKey[]) {}
}

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

  constructor(public payload: RPCClientError) {}
}

export type Actions =
  | ReadAllByDisplayItem
  | ReadAllByDisplayItemSuccess
  | ReadAllByDisplayItemFailure

;
