UNPKG

website-session-kit

Version:

A modular and extensible session management toolkit for modern websites.

18 lines (17 loc) 1.23 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; const PriceShow = ({ price, salesPrice, installments, className = "", }) => { const formatCurrency = (value) => value.toLocaleString("pt-BR", { style: "currency", currency: "BRL", minimumFractionDigits: 2, }); const parsedPrice = Number(price); const parsedSalesPrice = Number(salesPrice); const hasDiscount = !isNaN(parsedSalesPrice) && parsedSalesPrice < parsedPrice; const displayPrice = hasDiscount ? parsedSalesPrice : parsedPrice; const installmentValue = installments ? displayPrice / installments : null; return (_jsxs("div", { className: `custom-color-light-blue ${className}`, children: [_jsx("p", { className: "text-xl fs-5", children: hasDiscount ? (_jsxs(_Fragment, { children: ["De ", _jsx("s", { children: formatCurrency(parsedPrice) }), " por apenas", _jsx("br", {})] })) : (_jsxs(_Fragment, { children: ["Por apenas", _jsx("br", {})] })) }), _jsx("p", { className: "fs-6", children: installments ? `${installments}x de ${formatCurrency(installmentValue)}` : `${formatCurrency(displayPrice)}` })] })); }; export default PriceShow;