1 import { clx } from "@medusajs/ui"
2 import { getStylizedAmount } from "../../../../../lib/money-amount-helpers"
3 import { PlaceholderCell } from "../placeholder-cell"
4
5 type MoneyAmountCellProps = {
6 currencyCode: string
7 amount?: number | null
8 align?: "left" | "right"
9 className?: string
10 }
11
12 export const MoneyAmountCell = ({
13 currencyCode,
14 amount,
15 align = "left",
16 className,
17 }: MoneyAmountCellProps) => {
18 if (typeof amount === "undefined" || amount === null) {
19 return <PlaceholderCell />
20 }
21
22 const formatted = getStylizedAmount(amount, currencyCode)
23
24 return (
25 <div
26 className={clx(
27 "flex h-full w-full items-center overflow-hidden",
28 {
29 "justify-start text-left": align === "left",
30 "justify-end text-right": align === "right",
31 },
32 className
33 )}
34 >
35 <span className="truncate">{formatted}</span>
36 </div>
37 )
38 }