@open-tender/ui
Version:
A component library for use with the Open Tender web app
25 lines (24 loc) • 2.05 kB
JavaScript
import { formatDollars, formatQuantity } from '@open-tender/utils';
import { Plus } from 'iconoir-react';
import React from 'react';
import { makeImageProps, makeProps } from '../utils';
import Button from './Button';
import Text from './Text';
import View from './View';
const CartUpsellItem = ({ config, handlers, item, isLast, apiUrl, displayCals = false }) => {
const { name, imageUrl, totalPrice, totalCals } = item;
const imageProps = makeImageProps(config, 'cartUpsellItem__image', imageUrl, apiUrl);
return (React.createElement(View, Object.assign({}, makeProps(config, isLast ? 'cartUpsellItem' : 'cartUpsellItem')),
React.createElement(Button, Object.assign({}, makeProps(config, 'cartUpsellItem__button'), { onClick: handlers.add }),
React.createElement(View, Object.assign({}, makeProps(config, 'cartUpsellItem__container')),
React.createElement(View, Object.assign({}, imageProps)),
React.createElement(View, Object.assign({}, makeProps(config, 'cartUpsellItem__info')),
React.createElement(View, Object.assign({}, makeProps(config, 'cartUpsellItem__header')),
React.createElement(Text, Object.assign({}, makeProps(config, 'cartUpsellItem__title'), { text: name })),
React.createElement(View, Object.assign({}, makeProps(config, 'cartUpsellItem__details')),
totalPrice !== null && (React.createElement(Text, Object.assign({}, makeProps(config, 'cartUpsellItem__price'), { text: formatDollars(totalPrice.toString()) }))),
displayCals && totalCals !== null && (React.createElement(Text, Object.assign({}, makeProps(config, 'cartUpsellItem__calories'), { text: `${formatQuantity(totalCals.toString())} Cal` }))))),
React.createElement(View, Object.assign({}, makeProps(config, 'cartUpsellItem__add')),
React.createElement(Plus, { width: 28, height: 28, strokeWidth: 2 })))))));
};
export default CartUpsellItem;