UNPKG

@oxyhq/services

Version:

OxyHQ Expo/React Native SDK — UI components, screens, and native features

176 lines (175 loc) 8.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNative = require("react-native"); var _vectorIcons = require("@expo/vector-icons"); var _index = require("../index.js"); var _GroupedPillButtons = _interopRequireDefault(require("../internal/GroupedPillButtons.js")); var _paymentStyles = require("./paymentStyles.js"); var _constants = require("./constants.js"); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } const getItemTypeIcon = type => { switch (type) { case 'product': return 'cart-outline'; case 'subscription': return 'repeat-outline'; case 'service': return 'construct-outline'; case 'fee': return 'cash-outline'; default: return 'pricetag-outline'; } }; const PaymentSummaryStep = ({ paymentItems, amount, currency, description, colors, animations, onClose, onNext }) => { const styles = (0, _react.useMemo)(() => (0, _paymentStyles.createPaymentStyles)(colors), [colors]); const currencySymbol = (0, _constants.getCurrencySymbol)(currency); const { fadeAnim, slideAnim, scaleAnim } = animations; return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, { style: [styles.stepContainer, { opacity: fadeAnim, transform: [{ translateY: slideAnim }, { scale: scaleAnim }] }], accessibilityRole: "none", accessibilityLabel: "Payment summary step", children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.section, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.sectionTitle, children: "Payment Summary" }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: styles.summaryCard, children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.summaryCardContent, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.Ionicons, { name: "receipt-outline", size: 64, color: colors.primary, style: styles.summaryCardIcon }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.summaryCardMainTitle, children: paymentItems.length > 0 ? 'Order Summary' : 'Payment' }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.summaryCardSubtitle, children: paymentItems.length > 0 ? 'Review your payment details' : 'Complete your payment' }), paymentItems.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: styles.summaryCardItems, children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.GroupedSection, { items: paymentItems.map((item, idx) => ({ id: `item-${idx}`, icon: getItemTypeIcon(item.type), iconColor: colors.primary, title: `${item.type === 'product' && item.quantity ? `${item.quantity} × ` : ''}${item.name}${item.type === 'subscription' && item.period ? ` (${item.period})` : ''}`, subtitle: item.description || `${item.currency ? _constants.CURRENCY_SYMBOLS[item.currency.toUpperCase()] || item.currency : currencySymbol} ${item.price * (item.quantity ?? 1)}`, customContent: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, { style: styles.summaryItemPrice, children: [item.currency ? _constants.CURRENCY_SYMBOLS[item.currency.toUpperCase()] || item.currency : currencySymbol, " ", item.price * (item.quantity ?? 1)] }) })) }) }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: styles.summaryCardDivider }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.summaryCardTotalSection, children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.summaryCardTotalRow, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.summaryCardTotalLabel, children: "Subtotal" }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, { style: styles.summaryCardTotalValue, children: [currencySymbol, " ", amount] })] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.summaryCardTotalRow, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.summaryCardTotalLabel, children: "Tax" }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, { style: styles.summaryCardTotalValue, children: [currencySymbol, " 0.00"] })] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.summaryCardTotalRow, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.summaryCardTotalLabel, children: "Total" }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, { style: styles.summaryCardTotalValue, children: [currencySymbol, " ", amount] })] })] })] }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, { children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.summaryCardAmount, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.summaryCardAmountLabel, children: "Amount to Pay" }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, { style: styles.summaryCardAmountValue, children: [currencySymbol, " ", amount] }), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.summaryCardAmountDescription, children: description })] }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: styles.summaryCardDivider }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: styles.summaryCardTotalSection, children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: styles.summaryCardTotalRow, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: styles.summaryCardTotalLabel, children: "Total" }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, { style: styles.summaryCardTotalValue, children: [currencySymbol, " ", amount] })] }) })] })] }) })] }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GroupedPillButtons.default, { buttons: [{ text: 'Close', onPress: onClose, icon: 'close', variant: 'transparent' }, { text: 'Continue', onPress: onNext, icon: 'arrow-forward', variant: 'primary' }], colors: colors })] }); }; var _default = exports.default = PaymentSummaryStep; //# sourceMappingURL=PaymentSummaryStep.js.map