UNPKG

@open-tender/ui

Version:

A component library for use with the Open Tender web app

20 lines (19 loc) 1.58 kB
import { formatQuantity } from '@open-tender/utils'; import React from 'react'; import { makeProps } from '../utils'; import Text from './Text'; import View from './View'; const PointsRewards = ({ config, items, points, pointsApplied, pointsRemaining, renderPointReward }) => { const pts = formatQuantity(points.toString()); const subtitle = `You have ${pts} points that can be redeemed for free items.`; const applied = formatQuantity(pointsApplied.toString()); const remaining = formatQuantity(pointsRemaining.toString()); const msg = `${applied} points applied and ${remaining} points remaining.`; return (React.createElement(View, Object.assign({}, makeProps(config, 'pointsRewards')), React.createElement(View, Object.assign({}, makeProps(config, 'pointsRewards__header')), React.createElement(Text, Object.assign({}, makeProps(config, 'pointsRewards__title'))), pointsApplied ? (React.createElement(Text, Object.assign({}, makeProps(config, 'pointsRewards__subtitle'), { text: msg }))) : (React.createElement(Text, Object.assign({}, makeProps(config, 'pointsRewards__subtitle'), { text: subtitle })))), React.createElement(View, Object.assign({}, makeProps(config, 'pointsRewards__items')), React.createElement(View, Object.assign({}, makeProps(config, 'pointsRewards__itemsContainer')), items.map((item, index) => (React.createElement(View, Object.assign({ key: `${item.id}-${index}` }, makeProps(config, 'pointsRewards__item')), renderPointReward(item)))))))); }; export default PointsRewards;