import React from 'react';
/* eslint-disable */
export const getErrorMessage = (attributes) => {
  switch (attributes.errors.type) {
    case 'SHORT_PRODUCT_EXPIRED_MESSAGE':
      if (!attributes.is_trunkshow) {
        return attributes.errors.message;
      }
      break;
    case 'SHORT_QUANTITY_EXCEEDED_MESSAGE':
      return 'Not enough units: Please select a smaller quantity';
      break;
    case 'SHORT_SIZE_SOLD_OUT_MESSAGE':
      return 'Size sold out: Please select a different size';
      break;
    default:
      return attributes.errors.message;
    }
  };

  export const renderExcessShipping = (attributes) => {
    if (attributes.excess_shipping){
      return (
        <div className='mojo-tagline-4' data-automation='shipping'>
          This item will require additional shipping fees
        </div>
      );      
    }
  };

  export const renderGiftPackagingMessage = (attributes) => {
    if (attributes.gift_packaging_message && attributes.is_gift_order) {
      return (
        <div
          className="mojo-tagline-4"
          data-automation="gift-packaging-message"
        >
          {attributes.is_gift_item
            ? 'Item can be gift wrapped'
            : 'Item cannot be gift wrapped'}
        </div>
      );
    }
  };

  export const showMultipleSameItemPrice = (quantity, price) => {
    const totalPrice = parseInt(quantity) * parseInt(price.price);
    const formattedPrice = totalPrice
      .toFixed(2)
      .replace(/\d(?=(\d{3})+\.)/g, '$&,');
    return `${price.currency_html_code}${formattedPrice}`;
  };