1 import { Container, Text } from "@medusajs/ui";
2 import { AdminGiftCard, ModuleStoreCreditAccount } from "../../../../../types";
3 import { formatAmount } from "../../../../utils/format-amount";
4
5 const GiftCardBalanceSection = ({
6 storeCreditAccount,
7 giftCard,
8 }: {
9 storeCreditAccount: ModuleStoreCreditAccount;
10 giftCard: AdminGiftCard;
11 }) => {
12 if (
13 !storeCreditAccount ||
14 typeof storeCreditAccount.balance === "undefined"
15 ) {
16 return;
17 }
18
19 return (
20 <Container className="grid grid-cols-2 gap-x-2 px-6 py-4">
21 <div className="text-ui-fg-subtle flex items-center gap-x-3">
22 <div className="bg-ui-tag-green-icon h-8 w-1 rounded-full" />
23
24 <div>
25 <Text weight="plus" size="small" className="text-ui-fg-subtle">
26 Current Balance
27 </Text>
28
29 <Text
30 weight="plus"
31 size="xlarge"
32 className="tabular-nums text-ui-fg-base"
33 >
34 {formatAmount(
35 storeCreditAccount.balance as number,
36 giftCard.currency_code
37 )}
38 </Text>
39 </div>
40 </div>
41
42 <div className="text-ui-fg-subtle flex items-center gap-x-3">
43 <div className="bg-ui-tag-neutral-icon h-8 w-1 rounded-full" />
44
45 <div>
46 <Text weight="plus" size="small" className="text-ui-fg-subtle">
47 Initial Balance
48 </Text>
49
50 <Text
51 weight="plus"
52 size="xlarge"
53 className="tabular-nums text-ui-fg-base"
54 >
55 {formatAmount(giftCard.value, giftCard.currency_code)}
56 </Text>
57 </div>
58 </div>
59 </Container>
60 );
61 };
62
63 export default GiftCardBalanceSection;