import { KeyValueOfStringAndString } from '@isa/common/data-access';
import { DBHOrderItemListItem } from '../schemas';

export const getMainActions = (
  items: DBHOrderItemListItem[],
  isPartial?: boolean,
): KeyValueOfStringAndString[] => {
  const firstItem = items?.find((_) => true);
  return (
    firstItem?.actions
      ?.filter((action) => action?.enabled === true)
      ?.filter((action) =>
        isPartial ? !action?.command?.includes('FETCHED_PARTIAL') : true,
      ) ?? []
  );
};
