@open-tender/ui
Version:
A component library for use with the Open Tender web app
22 lines (21 loc) • 1.28 kB
JavaScript
import { formatQuantity } from '@open-tender/utils';
import React from 'react';
import { makeProps } from '../utils';
import Button from './Button';
import Text from './Text';
import View from './View';
const AccountLoyalty = ({ config, handlers, account, loyaltyProgram }) => {
const { first_name } = account;
const greeting = `Welcome back, ${first_name}`;
const { credit: points } = loyaltyProgram.perk || {};
const pointsMsg = points
? `You've got ${formatQuantity(points.toString())} points!`
: null;
return (React.createElement(View, Object.assign({}, makeProps(config, 'accountLoyalty')),
React.createElement(View, Object.assign({}, makeProps(config, 'accountLoyalty__header')),
React.createElement(Text, Object.assign({}, makeProps(config, 'accountLoyalty__title'), { text: greeting })),
pointsMsg && (React.createElement(Text, Object.assign({}, makeProps(config, 'accountLoyalty__subtitle'), { text: pointsMsg }))),
React.createElement(View, Object.assign({}, makeProps(config, 'accountLoyalty__buttons')),
React.createElement(Button, Object.assign({}, makeProps(config, 'accountLoyalty__orderNow'), { onClick: handlers.startOrder }))))));
};
export default AccountLoyalty;