UNPKG

@rsc-labs/medusa-store-analytics

Version:
29 lines (28 loc) 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RefundsNumber = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); /* * Copyright 2024 RSC-Labs, https://rsoftcon.com/ * * MIT License * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const ui_1 = require("@medusajs/ui"); const material_1 = require("@mui/material"); const percentage_comparison_1 = require("../../common/percentage-comparison"); const icon_comparison_1 = require("../../common/icon-comparison"); const helpers_1 = require("../../utils/helpers"); const RefundsNumber = ({ refundsResponse, compareEnabled }) => { const overallCurrentSum = parseInt(refundsResponse.analytics.current); const overallPreviousSum = refundsResponse.analytics.previous !== undefined ? parseInt(refundsResponse.analytics.previous) : undefined; return ((0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, alignItems: 'center', spacing: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsxs)(ui_1.Heading, { level: "h1", children: [(0, helpers_1.amountToDisplay)(overallCurrentSum, refundsResponse.analytics.currencyDecimalDigits), " ", refundsResponse.analytics.currencyCode.toUpperCase()] }) }), compareEnabled && refundsResponse.analytics.dateRangeFromCompareTo && (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, alignItems: 'center', children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(icon_comparison_1.IconComparison, { current: overallCurrentSum, previous: overallPreviousSum ? overallPreviousSum : undefined, switchArrow: true }) }), overallPreviousSum !== undefined && (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(percentage_comparison_1.PercentageComparison, { current: (0, helpers_1.amountToDisplay)(overallCurrentSum, refundsResponse.analytics.currencyDecimalDigits), label: refundsResponse.analytics.currencyCode.toUpperCase(), previous: (0, helpers_1.amountToDisplay)(overallPreviousSum, refundsResponse.analytics.currencyDecimalDigits) }) })] }) })] })); }; exports.RefundsNumber = RefundsNumber;