import { RewardSelectionItem } from '@isa/checkout/data-access';

export const calculatePriceValue = (
  rewardSelectionItem: RewardSelectionItem,
): number => {
  console.log(rewardSelectionItem);
  const itemUnitPrice = rewardSelectionItem.item?.unitPrice?.value?.value;
  const availabilityPrice =
    rewardSelectionItem.item?.availability?.price?.value?.value;
  const catalogPrice = rewardSelectionItem.catalogPrice?.value?.value;

  if (itemUnitPrice != null && itemUnitPrice !== 0) {
    return itemUnitPrice;
  }

  if (availabilityPrice != null && availabilityPrice !== 0) {
    return availabilityPrice;
  }

  if (catalogPrice != null && catalogPrice !== 0) {
    return catalogPrice;
  }

  return 0;
};
