UNPKG

@open-tender/ui

Version:

A component library for use with the Open Tender web app

21 lines (20 loc) 1.4 kB
import React from 'react'; import { makeProps } from '../utils'; import CheckTotalsLine from './CheckTotalsLine'; import CheckTotalsSubline from './CheckTotalsSubline'; import CheckTotalsTotal from './CheckTotalsTotal'; import View from './View'; const CheckTotals = ({ config, check }) => { const { discounts, totals } = check; const { subtotal, discount, surcharge, tax, tip, total } = totals; return (React.createElement(View, Object.assign({}, makeProps(config, 'checkTotals')), React.createElement(CheckTotalsLine, { config: config, label: "Subtotal", amount: subtotal }), surcharge !== '0.00' && (React.createElement(CheckTotalsLine, { config: config, label: "Surcharge", amount: surcharge })), discount !== '0.00' && (React.createElement(React.Fragment, null, discounts.map(({ id, name, title, amount }) => (React.createElement(CheckTotalsSubline, { key: id, config: config, label: title || name, amount: amount }))), React.createElement(CheckTotalsLine, { config: config, label: "Discount", amount: discount }))), React.createElement(CheckTotalsLine, { config: config, label: "Tax", amount: tax }), React.createElement(CheckTotalsLine, { config: config, label: "Tip", amount: tip }), React.createElement(CheckTotalsTotal, { config: config, label: "Total", amount: total }))); }; export default CheckTotals;