UNPKG

@blocklet/payment-react

Version:

Reusable react components for payment kit v2

82 lines (81 loc) 2.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); module.exports = TrialInfo; var _jsxRuntime = require("react/jsx-runtime"); var _material = require("@mui/material"); var _context = require("@arcblock/ux/lib/Locale/context"); var _format = require("../../utils/format"); function TrialInfo({ trial, mode, items }) { const { t } = (0, _context.useLocaleContext)(); if (trial.active && trial.afterTrialPrice) { return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { borderTop: "1px solid", borderColor: "divider", pt: 1, mt: 1 }, children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, { sx: { color: "text.secondary", fontSize: 14 }, children: t("common.nextCharge") }), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, { sx: { fontSize: 16, color: "text.secondary" }, children: [trial.afterTrialPrice, trial.afterTrialInterval ? ` ${t(_format.INTERVAL_LOCALE_KEY[trial.afterTrialInterval] || "")}` : ""] })] }); } if (!trial.active && ["subscription", "setup"].includes(mode)) { const meteredItem = items.find(item => (item.upsell_price || item.price)?.recurring?.usage_type === "metered"); if (!meteredItem) return null; const meteredInterval = (meteredItem.upsell_price || meteredItem.price)?.recurring?.interval; if (!meteredInterval) return null; const recurringText = t("common.per", { interval: t(`common.${meteredInterval}`) }); return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { borderTop: "1px solid", borderColor: "divider", pt: 1, mt: 1 }, children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, { sx: { color: "text.secondary", fontSize: 14, fontWeight: 600 }, children: t("common.nextCharge") }), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, { sx: { fontSize: 16, color: "text.secondary" }, children: t("payment.checkout.metered", { recurring: recurringText }) })] }); } return null; }