import { CollectingShelfOrder } from '../../models/collecting-shelf-order.model';
import { OrderDTO } from '@swagger/oms';

export const SET_SHELF_ORDERS = '[COLLECTING-SHELF] Set orders';
export const RELOAD_COLECTING_SHELF_DATA = '[COLLECTING-SHELF] Reload Collecting Shelf data';
export const CLEAR_SHELF_ORDERS_FOR_PROCESS = '[COLLECTING-SHELF] Clear shelf orders for process';
export const SET_EDIT_ORDER = '[COLLECTING-SHELF] Set order that has to be edited';
export const SET_CACHED_RESULTS = '[COLLECTING-SHELF] Set cached results';
export const CLEAR_CACHED_RESULTS = '[COLLECTING-SHELF] Clear cached results';
export const DELETE_COLLECTING_SHELF_FOR_PROCESS = '[COLLECTING-SHELF] Delete collecting shelf for process';
export const SET_COLLECTING_SHELF_CACHE_STATE = '[COLLECTING-SHELF] Set use cache true/false';

export class SetShelfOrders {
  static readonly type = SET_SHELF_ORDERS;

  constructor(public orders: CollectingShelfOrder[]) {}
}

export class ReloadCollectingShelfData {
  static readonly type = RELOAD_COLECTING_SHELF_DATA;

  constructor(
    public orders: { [key: number]: { [key: number]: CollectingShelfOrder } },
    public editOrder: { [id: number]: OrderDTO },
    public cachedSearchResults: { [id: number]: { result: CollectingShelfOrder[]; hits: number } },
    public useCache: { [id: number]: boolean }
  ) {}
}

export class ClearShelfOrdersForProcess {
  static readonly type = CLEAR_SHELF_ORDERS_FOR_PROCESS;
}

export class ClearCachedResults {
  static readonly type = CLEAR_CACHED_RESULTS;
}

export class SetEditOrder {
  static readonly type = SET_EDIT_ORDER;

  constructor(public order: OrderDTO) {}
}

export class SetCachedResults {
  static readonly type = SET_CACHED_RESULTS;

  constructor(public processCachedSearchResults: { result: CollectingShelfOrder[]; hits: number }) {}
}

export class DeleteCollectingShelfForProcess {
  static readonly type = DELETE_COLLECTING_SHELF_FOR_PROCESS;

  constructor(public processId: number) {}
}

export class SetCollectingShelfCacheState {
  static readonly type = SET_COLLECTING_SHELF_CACHE_STATE;

  constructor(public useCache: boolean) {}
}
