import * as React from 'react';
import { Utils } from '@assets/js-shop/cart/Utils';
import { ICartItem } from '@assets/js-shop/GraphQLInterfaces';
import { translate as _t } from '@assets/js-shop/ShopUtils';

export function CartInfoTemplate(me: any, items: ICartItem[]) {
   return (
      <a aria-controls="cartbox-focus" href={me.context.cart.url} onClick={e => me.handleCartInfoClick(e)} className={items.length <= 0 ? 'e-cart-info empty' : 'e-cart-info'} title={_t('prejitDoKosiku')}>
         <span className="icon">
            <i className="c-icon" dangerouslySetInnerHTML={{ __html: require('@assets/icons/cart.svg?raw') }}/>
            <span>
               {Utils.countProducts(items)}
            </span>
         </span>
         <span className="text">
            {items.length ? Utils.printPrice(me.context.cart.totalPrice, me.context) : 'Prázdný'}
         </span>
      </a>
   );
}
