@open-tender/ui
Version:
A component library for use with the Open Tender web app
22 lines (21 loc) • 1.41 kB
JavaScript
import { makeDiscountEnhanced } from '@open-tender/utils';
import React from 'react';
import { makeImageProps, makeProps } from '../utils';
import Card from './Card';
import Text from './Text';
import View from './View';
const Discount = ({ config, discount, cardConfig, apiUrl }) => {
const { title, description } = discount;
const { todayOnly, imageUrl } = makeDiscountEnhanced(discount);
const imageProps = makeImageProps(config, 'discount__image', imageUrl, apiUrl);
return (React.createElement(View, Object.assign({}, makeProps(config, 'discount')),
React.createElement(Card, { config: cardConfig },
React.createElement(View, Object.assign({}, makeProps(config, 'discount__container')),
React.createElement(View, Object.assign({}, makeProps(config, 'discount__header')),
React.createElement(View, Object.assign({}, imageProps)),
todayOnly && React.createElement(Text, Object.assign({}, makeProps(config, 'discount__today')))),
React.createElement(View, Object.assign({}, makeProps(config, 'discount__content')),
React.createElement(Text, Object.assign({}, makeProps(config, 'discount__title'), { text: title })),
React.createElement(Text, Object.assign({}, makeProps(config, 'discount__subtitle'), { text: description })))))));
};
export default Discount;