|
1
|
import { CurrencyDollar } from "@medusajs/icons" |
|
2
|
import { AdminCampaign } from "@medusajs/types" |
|
3
|
import { Container, Heading, Text } from "@medusajs/ui" |
|
4
|
import { Trans, useTranslation } from "react-i18next" |
|
5
|
|
|
6
|
type CampaignSpendProps = { |
|
7
|
campaign: AdminCampaign |
|
8
|
} |
|
9
|
|
|
10
|
export const CampaignSpend = ({ campaign }: CampaignSpendProps) => { |
|
11
|
const { t } = useTranslation() |
|
12
|
|
|
13
|
return ( |
|
14
|
<Container className="flex flex-col gap-y-4 px-6 py-4"> |
|
15
|
<div className="mb-2 grid grid-cols-[28px_1fr] items-center gap-x-3"> |
|
16
|
<div className="bg-ui-bg-base shadow-borders-base flex size-7 items-center justify-center rounded-md"> |
|
17
|
<div className="bg-ui-bg-component flex size-6 items-center justify-center rounded-[4px]"> |
|
18
|
<CurrencyDollar className="text-ui-fg-subtle" /> |
|
19
|
</div> |
|
20
|
</div> |
|
21
|
|
|
22
|
<Heading level="h2"> |
|
23
|
{campaign.budget?.type === "use_by_attribute" |
|
24
|
? t("campaigns.fields.totalUsedByAttribute") |
|
25
|
: campaign.budget?.type === "spend" |
|
26
|
? t("campaigns.fields.total_spend") |
|
27
|
: t("campaigns.fields.total_used")} |
|
28
|
</Heading> |
|
29
|
</div> |
|
30
|
|
|
31
|
<div> |
|
32
|
<Text |
|
33
|
className="text-ui-fg-subtle border-ui-border-strong border-l-4 pl-3" |
|
34
|
size="small" |
|
35
|
leading="compact" |
|
36
|
> |
|
37
|
<Trans |
|
38
|
i18nKey="campaigns.totalSpend" |
|
39
|
values={{ |
|
40
|
amount: campaign?.budget?.used || 0, |
|
41
|
currency: |
|
42
|
campaign?.budget?.type === "spend" |
|
43
|
? campaign?.budget?.currency_code |
|
44
|
: "", |
|
45
|
}} |
|
46
|
components={[ |
|
47
|
<span |
|
48
|
key="amount" |
|
49
|
className="text-ui-fg-base txt-compact-medium-plus text-lg" |
|
50
|
/>, |
|
51
|
<span |
|
52
|
key="currency" |
|
53
|
className="text-ui-fg-base txt-compact-medium-plus text-lg" |
|
54
|
/>, |
|
55
|
]} |
|
56
|
/> |
|
57
|
</Text> |
|
58
|
</div> |
|
59
|
</Container> |
|
60
|
) |
|
61
|
} |