fix(dashboard): campaign budget labels improvements (#13740)
* fix(dashboard): budget labels and remove promo code * fix: sidebar label * fix: update translation
This commit is contained in:
+17
-5
@@ -11,6 +11,22 @@ type CampaignBudgetProps = {
|
||||
export const CampaignBudget = ({ campaign }: CampaignBudgetProps) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
const getTranslation = () => {
|
||||
const budget = campaign.budget
|
||||
|
||||
if (budget?.type === "use_by_attribute") {
|
||||
if (budget?.attribute === "customer_id") {
|
||||
return t(`campaigns.budget.fields.totalUsedByAttributeCustomerId`)
|
||||
} else if (budget?.attribute === "customer_email") {
|
||||
return t(`campaigns.budget.fields.totalUsedByAttributeEmail`)
|
||||
}
|
||||
return t(`campaigns.budget.fields.totalUsedByAttribute`, {
|
||||
attribute: budget?.attribute,
|
||||
})
|
||||
}
|
||||
return t(`campaigns.fields.budget_limit`)
|
||||
}
|
||||
|
||||
return (
|
||||
<Container className="flex flex-col gap-y-4 px-6 py-4">
|
||||
<div className="flex justify-between">
|
||||
@@ -25,11 +41,7 @@ export const CampaignBudget = ({ campaign }: CampaignBudgetProps) => {
|
||||
className="text-ui-fg-subtle ms-10 mt-[1.5px] font-normal"
|
||||
level="h3"
|
||||
>
|
||||
{campaign.budget?.type === "use_by_attribute"
|
||||
? t("campaigns.budget.fields.totalUsedByAttribute", {
|
||||
attribute: campaign.budget?.attribute,
|
||||
})
|
||||
: t("campaigns.fields.budget_limit")}
|
||||
{getTranslation()}
|
||||
</Heading>
|
||||
</div>
|
||||
|
||||
|
||||
+5
-4
@@ -382,10 +382,11 @@ export const CreateCampaignFormFields = ({ form, fieldScope = "" }) => {
|
||||
label: t("fields.email"),
|
||||
value: "customer_email",
|
||||
},
|
||||
{
|
||||
label: t("fields.promotionCode"),
|
||||
value: "promotion_code",
|
||||
},
|
||||
// TEMP disable promotion code for now
|
||||
// {
|
||||
// label: t("fields.promotionCode"),
|
||||
// value: "promotion_code",
|
||||
// },
|
||||
]}
|
||||
></Combobox>
|
||||
</Form.Control>
|
||||
|
||||
+18
-6
@@ -9,6 +9,21 @@ const translationKeyMap = {
|
||||
use_by_attribute: "useByAttribute",
|
||||
}
|
||||
|
||||
const getTranslationKey = (budget: AdminCampaign["budget"]) => {
|
||||
const translationKey = translationKeyMap[budget?.type] || "-"
|
||||
|
||||
if (budget?.type === "use_by_attribute") {
|
||||
if (budget?.attribute === "customer_id") {
|
||||
return `campaigns.budget.type.useByAttribute.titleCustomerId`
|
||||
} else if (budget?.attribute === "customer_email") {
|
||||
return `campaigns.budget.type.useByAttribute.titleEmail`
|
||||
}
|
||||
return `campaigns.budget.type.useByAttribute.title`
|
||||
}
|
||||
|
||||
return `campaigns.budget.type.${translationKey}.title`
|
||||
}
|
||||
|
||||
type CampaignDetailsProps = {
|
||||
campaign?: AdminCampaign
|
||||
}
|
||||
@@ -84,12 +99,9 @@ export const CampaignDetails = ({ campaign }: CampaignDetailsProps) => {
|
||||
|
||||
<div className="flex items-center gap-1">
|
||||
<Text className="txt-small truncate">
|
||||
{t(
|
||||
`campaigns.budget.type.${translationKeyMap[campaign.budget?.type]}.title`,
|
||||
{
|
||||
defaultValue: "-",
|
||||
}
|
||||
)}
|
||||
{t(getTranslationKey(campaign.budget), {
|
||||
defaultValue: "-",
|
||||
})}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user