import { getPercentageDiff } from "@lib/util/get-precentage-diff" import { convertToLocale } from "@lib/util/money" import { HttpTypes } from "@medusajs/types" import { clx } from "@medusajs/ui" type LineItemPriceProps = { item: HttpTypes.StoreCartLineItem | HttpTypes.StoreOrderLineItem style?: "default" | "tight" currencyCode: string } const LineItemPrice = ({ item, style = "default", currencyCode, }: LineItemPriceProps) => { const { total, original_total } = item const originalPrice = original_total const currentPrice = total const hasReducedPrice = currentPrice < originalPrice return (
{hasReducedPrice && ( <>

{style === "default" && ( Original: )} {convertToLocale({ amount: originalPrice, currency_code: currencyCode, })}

{style === "default" && ( -{getPercentageDiff(originalPrice, currentPrice || 0)}% )} )} {convertToLocale({ amount: currentPrice, currency_code: currencyCode, })}
) } export default LineItemPrice