@blocklet/payment-react
Version:
Reusable react components for payment kit v2
38 lines (37 loc) • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
module.exports = TxGas;
var _jsxRuntime = require("react/jsx-runtime");
var _context = require("@arcblock/ux/lib/Locale/context");
var _material = require("@mui/material");
var _util = require("@ocap/util");
var _payment = require("../../contexts/payment");
var _util2 = require("../../libs/util");
function TxGas(props) {
const {
t
} = (0, _context.useLocaleContext)();
const {
settings
} = (0, _payment.usePaymentContext)();
const {
gas
} = (0, _util2.getTxLink)(props.method, props.details);
const method = settings.paymentMethods.find(x => x.id === props.method.id);
if (gas && method) {
const currency = method.payment_currencies.find(x => x.id === method.default_currency_id);
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
component: "span",
children: [(0, _util.fromUnitToToken)(gas, currency.decimal), " ", currency.symbol, " (", method.name, ")"]
});
}
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
component: "small",
sx: {
color: "text.secondary"
},
children: t("common.none")
});
}