UNPKG

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

Version:
30 lines (29 loc) 2.81 kB
import { jsxs, jsx } from "react/jsx-runtime"; import { Heading, Text, Tooltip } from "@medusajs/ui"; import { Grid, Divider } from "@mui/material"; import { IconComparison } from "./icon-comparison.js"; const ValueColumn = ({ current, previous, enableComparing }) => { return /* @__PURE__ */ jsxs(Grid, { container: true, alignItems: "center", children: [ enableComparing ? /* @__PURE__ */ jsx(Tooltip, { content: `Previously: ${previous}`, children: /* @__PURE__ */ jsx("span", { children: /* @__PURE__ */ jsx(Text, { style: { textDecorationStyle: "dotted", textDecorationLine: "underline", textUnderlineOffset: "3px" }, children: current !== void 0 ? `${current}` : `N/A` }) }) }) : /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Text, { children: current }) }), enableComparing && /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Grid, { container: true, alignItems: "center", children: parseInt(current) != (previous ? parseInt(previous) : void 0) && /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(IconComparison, { current: parseInt(current), previous: previous ? parseInt(previous) : void 0 }) }) }) }) ] }); }; const PopularityTable = ({ valueColumnName, tableRows, enableComparing }) => { return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, children: [ /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsx(Divider, {}) }), /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(Grid, { container: true, justifyContent: "space-between", children: [ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Heading, { level: "h3", children: "Name" }) }), /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Heading, { level: "h3", children: valueColumnName }) }) ] }) }), tableRows.length > 0 ? tableRows.map((tableRow) => /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(Grid, { container: true, justifyContent: "space-between", children: [ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Text, { children: tableRow.name }) }), /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(ValueColumn, { current: tableRow.current, previous: tableRow.previous, enableComparing }) }) ] }) }, tableRow.name)) : /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(Grid, { container: true, justifyContent: "space-between", children: [ /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Text, { children: "None" }) }), /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(Text, { children: "None" }) }) ] }) }) ] }); }; export { PopularityTable };