UNPKG

@rsc-labs/medusa-store-analytics-v2

Version:
38 lines (37 loc) 1.54 kB
import { jsxs, Fragment, jsx } from "react/jsx-runtime"; import { Heading } from "@medusajs/ui"; import { ChartCurrentPrevious } from "../common/chart-components.js"; import { amountToDisplay } from "../utils/helpers.js"; const SalesByNewChart = ({ dateRangeFrom, dateRangeTo, salesHistoryResponse, compareEnabled }) => { const rawChartData = { current: salesHistoryResponse.analytics.current.map((currentData) => { return { date: new Date(currentData.date), value: amountToDisplay(parseInt(currentData.total), salesHistoryResponse.analytics.currencyDecimalDigits) }; }), previous: salesHistoryResponse.analytics.previous.map((previousData) => { return { date: new Date(previousData.date), value: amountToDisplay(parseInt(previousData.total), salesHistoryResponse.analytics.currencyDecimalDigits) }; }) }; return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(Heading, { level: "h3", children: "Sales by time" }), /* @__PURE__ */ jsx( ChartCurrentPrevious, { rawChartData, fromDate: dateRangeFrom, toDate: dateRangeTo, fromCompareDate: salesHistoryResponse.analytics.dateRangeFromCompareTo ? new Date(salesHistoryResponse.analytics.dateRangeFromCompareTo) : void 0, toCompareDate: salesHistoryResponse.analytics.dateRangeToCompareTo ? new Date(salesHistoryResponse.analytics.dateRangeToCompareTo) : void 0, compareEnabled } ) ] }); }; export { SalesByNewChart };