import { createSelector } from '@ngrx/store';
import { selectShelfState } from '../shelf.selectors';
import { detailsStateEntityAdapter } from './details.state';
import { OrderItemListItemDTO } from '@swagger/oms';

export const selectDetailsState = createSelector(selectShelfState, (s) => s.details);

const { selectAll } = detailsStateEntityAdapter.getSelectors(selectDetailsState);

export const selectOrderItemsByOrderNumber = createSelector(selectAll, (entities: OrderItemListItemDTO[], orderNumber: string) =>
  entities.filter((item) => item.orderNumber === orderNumber)
);

export const selectOrderItemsByCompartmentCode = createSelector(selectAll, (entities: OrderItemListItemDTO[], compartmentCode: string) =>
  entities.filter((item) => item.compartmentCode === compartmentCode)
);
