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

import { RPCClientError } from '@loafer/ng-rpc/protocol';
import { MetaSensorItemKey } from 'packages/meta/sensor-item-key/model/MetaSensorItemKey';
import { MetaSensorDisplayItem } from 'packages/meta/sensor-display-item/model/MetaSensorDisplayItem';


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

;
