@rsc-labs/medusa-store-analytics
Version:
Get analytics data about your store
23 lines (22 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PercentageComparison = 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 helpers_1 = require("../utils/helpers");
const PercentageComparison = ({ current, label, previous, headingLevel = "h2" }) => {
const percentage = (0, helpers_1.calculatePercentage)(parseInt(current), parseInt(previous));
return ((0, jsx_runtime_1.jsx)(ui_1.Tooltip, { content: `Previously: ${previous} ${label}`, children: (0, jsx_runtime_1.jsx)("span", { children: (0, jsx_runtime_1.jsx)(ui_1.Heading, { level: headingLevel, style: { textDecorationStyle: 'dotted', textDecorationLine: 'underline', textUnderlineOffset: '3px' }, children: percentage !== undefined ? `${percentage}%` : `N/A` }) }) }));
};
exports.PercentageComparison = PercentageComparison;