UNPKG

infinity-forge

Version:
72 lines 6.04 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Pix = Pix; var jsx_runtime_1 = require("react/jsx-runtime"); var timer_1 = require("./timer/index.js"); var pix_sucess_1 = require("./pix-sucess/index.js"); var ui_1 = require("../../../ui/index.js"); var S = __importStar(require("./styles.js")); function Pix(_a) { var error = _a.error, pixValor = _a.pixValor, pixImage = _a.pixImage, pixURL = _a.pixURL, isSucess = _a.isSucess, isPaid = _a.isPaid, fastCheckout = _a.fastCheckout, expirationTime = _a.expirationTime; var createToast = (0, ui_1.useToast)().createToast; function toMoney(money, noIcon, options) { return Number(money) .toLocaleString((options === null || options === void 0 ? void 0 : options.local) || 'pt-BR', { minimumFractionDigits: 2, style: 'currency', currency: (options === null || options === void 0 ? void 0 : options.currency) || 'BRL', }) .replaceAll(noIcon ? (options === null || options === void 0 ? void 0 : options.icon) || 'R$' : '', ''); } return ((0, jsx_runtime_1.jsxs)(S.Pix, { className: 'pix', children: [!isSucess && !(error === null || error === void 0 ? void 0 : error.isError) && ((0, jsx_runtime_1.jsx)("h2", { className: 'titulo-2-bold', style: { color: isSucess ? 'green' : '#000' }, children: isSucess ? 'Pagamento confirmado.' : 'Aguardando seu pagamento' })), !isSucess ? ((0, jsx_runtime_1.jsxs)("div", { className: 'container-pix', children: [(error === null || error === void 0 ? void 0 : error.isError) ? ((0, jsx_runtime_1.jsx)("h2", { className: 'paragraph-1-bold escaneie', children: "O pix expirou..." })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: 'preco-pix', children: ["Valor a pagar: ", (0, jsx_runtime_1.jsx)("span", { className: ' paragraph-1-bold', children: toMoney(Number(pixValor)) || 0 })] }), (0, jsx_runtime_1.jsx)(timer_1.Timer, { expirationTime: expirationTime })] })), (0, jsx_runtime_1.jsx)("img", { src: pixImage, alt: 'QR Code pix', style: { filter: (error === null || error === void 0 ? void 0 : error.isError) ? 'blur(5px)' : '' } }), !(error === null || error === void 0 ? void 0 : error.isError) ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: 'copy', children: [(0, jsx_runtime_1.jsx)("p", { children: "Se preferir, voce pode pagar copiando e colando o seguinte c\u00F3digo" }), (0, jsx_runtime_1.jsxs)("div", { className: 'container-input', onClick: function () { var isCopied = (0, ui_1.copyToClipboard)(pixURL, { message: 'Copiado com sucesso!', format: 'text', }); if (isCopied) { createToast({ message: 'Copiado com sucesso!', status: 'success', }); return; } createToast({ message: 'Erro ao copiar', status: 'error', }); }, children: [(0, jsx_runtime_1.jsx)("input", { type: 'text', value: pixURL, readOnly: true }), (0, jsx_runtime_1.jsx)("button", { type: 'button', children: (0, jsx_runtime_1.jsxs)("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', fill: 'none', children: [(0, jsx_runtime_1.jsx)("path", { d: 'M6 11C6 8.17157 6 6.75736 6.87868 5.87868C7.75736 5 9.17157 5 12 5H15C17.8284 5 19.2426 5 20.1213 5.87868C21 6.75736 21 8.17157 21 11V16C21 18.8284 21 20.2426 20.1213 21.1213C19.2426 22 17.8284 22 15 22H12C9.17157 22 7.75736 22 6.87868 21.1213C6 20.2426 6 18.8284 6 16V11Z', "stroke-width": '1.5' }), (0, jsx_runtime_1.jsx)("path", { d: 'M6 19C4.34315 19 3 17.6569 3 16V10C3 6.22876 3 4.34315 4.17157 3.17157C5.34315 2 7.22876 2 11 2H15C16.6569 2 18 3.34315 18 5', "stroke-width": '1.5' })] }) })] })] }) })) : ((0, jsx_runtime_1.jsx)("button", { type: 'button', onClick: error === null || error === void 0 ? void 0 : error.onClickBack, children: "Voltar" }))] })) : ((0, jsx_runtime_1.jsx)(pix_sucess_1.PixSucess, { isSucess: isSucess, isPaid: isPaid, fastCheckout: fastCheckout }))] })); } //# sourceMappingURL=index.js.map