UNPKG

@rsc-labs/medusa-store-analytics

Version:
31 lines (30 loc) 3.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PopularityTable = 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 icon_comparison_1 = require("./icon-comparison"); const ValueColumn = ({ current, previous, enableComparing }) => { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, alignItems: 'center', children: [enableComparing ? (0, jsx_runtime_1.jsx)(ui_1.Tooltip, { content: `Previously: ${previous}`, children: (0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(ui_1.Text, { style: { textDecorationStyle: 'dotted', textDecorationLine: 'underline', textUnderlineOffset: '3px' }, children: current !== undefined ? `${current}` : `N/A` }) }) }) : (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(ui_1.Text, { children: current }) }), enableComparing && (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(material_1.Grid, { container: true, alignItems: 'center', children: parseInt(current) != parseInt(previous) && (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(icon_comparison_1.IconComparison, { current: parseInt(current), previous: previous ? parseInt(previous) : undefined }) }) }) })] })); }; const PopularityTable = ({ valueColumnName, tableRows, enableComparing }) => { return ((0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 12, children: (0, jsx_runtime_1.jsx)(material_1.Divider, {}) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 12, children: (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, justifyContent: 'space-between', children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(ui_1.Heading, { level: "h3", children: "Name" }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(ui_1.Heading, { level: "h3", children: valueColumnName }) })] }) }), tableRows.length > 0 ? tableRows.map(tableRow => ((0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 12, children: (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, justifyContent: 'space-between', children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(ui_1.Text, { children: tableRow.name }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(ValueColumn, { current: tableRow.current, previous: tableRow.previous, enableComparing: enableComparing }) })] }) }, tableRow.name))) : (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 12, children: (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, justifyContent: 'space-between', children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(ui_1.Text, { children: "None" }) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, children: (0, jsx_runtime_1.jsx)(ui_1.Text, { children: "None" }) })] }) })] })); }; exports.PopularityTable = PopularityTable;