1 import { Control, useWatch } from "react-hook-form"
2 import { Text } from "@medusajs/ui"
3 import { CurrencyInfo } from "../../../lib/data/currencies"
4 import { getLocaleAmount } from "../../../lib/money-amount-helpers"
5
6 interface AmountDisplayProps {
7 index: number
8 control: Control<any>
9 currency: CurrencyInfo
10 }
11
12 export const AmountDisplay = ({
13 index,
14 control,
15 currency,
16 }: AmountDisplayProps) => {
17 const amount = useWatch({
18 control,
19 name: `prices.${index}.amount`,
20 })
21
22 return (
23 <Text size="small" weight="plus">
24 {amount ? getLocaleAmount(Number(amount), currency.code) : "—"}
25 </Text>
26 )
27 }