diff --git a/.changeset/shaggy-tigers-warn.md b/.changeset/shaggy-tigers-warn.md new file mode 100644 index 0000000000..6836f47f67 --- /dev/null +++ b/.changeset/shaggy-tigers-warn.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +fix(dashboard): budget labels and remove promo code diff --git a/packages/admin/dashboard/src/i18n/translations/$schema.json b/packages/admin/dashboard/src/i18n/translations/$schema.json index f514bfa30d..726e246988 100644 --- a/packages/admin/dashboard/src/i18n/translations/$schema.json +++ b/packages/admin/dashboard/src/i18n/translations/$schema.json @@ -8345,6 +8345,19 @@ "budget": { "type": "object", "properties": { + "attribute": { + "type": "object", + "properties": { + "customer_id": { + "type": "string" + }, + "customer_email": { + "type": "string" + } + }, + "required": ["customer_id", "customer_email"], + "additionalProperties": false + }, "create": { "type": "object", "properties": { @@ -8384,6 +8397,12 @@ }, "totalUsedByAttribute": { "type": "string" + }, + "totalUsedByAttributeCustomerId": { + "type": "string" + }, + "totalUsedByAttributeEmail": { + "type": "string" } }, "required": [ @@ -8393,7 +8412,9 @@ "used", "budgetAttribute", "budgetAttributeTooltip", - "totalUsedByAttribute" + "totalUsedByAttribute", + "totalUsedByAttributeCustomerId", + "totalUsedByAttributeEmail" ], "additionalProperties": false }, @@ -8432,11 +8453,22 @@ "title": { "type": "string" }, + "titleCustomerId": { + "type": "string" + }, + "titleEmail": { + "type": "string" + }, "description": { "type": "string" } }, - "required": ["title", "description"], + "required": [ + "title", + "titleCustomerId", + "titleEmail", + "description" + ], "additionalProperties": false } }, @@ -8454,7 +8486,14 @@ "additionalProperties": false } }, - "required": ["create", "details", "fields", "type", "edit"], + "required": [ + "attribute", + "create", + "details", + "fields", + "type", + "edit" + ], "additionalProperties": false }, "promotions": { diff --git a/packages/admin/dashboard/src/i18n/translations/en.json b/packages/admin/dashboard/src/i18n/translations/en.json index a37b5d4ced..6eef3ee66c 100644 --- a/packages/admin/dashboard/src/i18n/translations/en.json +++ b/packages/admin/dashboard/src/i18n/translations/en.json @@ -2240,6 +2240,10 @@ } }, "budget": { + "attribute": { + "customer_id": "customer", + "customer_email": "email" + }, "create": { "hint": "Create a budget for the campaign.", "header": "Campaign Budget" @@ -2251,8 +2255,10 @@ "limit": "Limit", "used": "Used", "budgetAttribute": "Limit usage per", - "budgetAttributeTooltip": "Define how many times the promotion can be used by a specific customer or email.", - "totalUsedByAttribute": "Budget limit per: {{attribute}}" + "budgetAttributeTooltip": "Define how many times the promotion can be used by each customer or email.", + "totalUsedByAttribute": "Budget limit per: {{attribute}}", + "totalUsedByAttributeCustomerId": "Budget limit per customer", + "totalUsedByAttributeEmail": "Budget limit per email" }, "type": { "spend": { @@ -2265,6 +2271,8 @@ }, "useByAttribute": { "title": "Usage by attribute (customer id, email, etc.)", + "titleCustomerId": "Usage per customer", + "titleEmail": "Usage per email", "description": "Set a limit on how many times the promotion can be used by a specific attribute value." } }, diff --git a/packages/admin/dashboard/src/routes/campaigns/campaign-detail/components/campaign-budget/campaign-budget.tsx b/packages/admin/dashboard/src/routes/campaigns/campaign-detail/components/campaign-budget/campaign-budget.tsx index 60671b93f7..39d763ac60 100644 --- a/packages/admin/dashboard/src/routes/campaigns/campaign-detail/components/campaign-budget/campaign-budget.tsx +++ b/packages/admin/dashboard/src/routes/campaigns/campaign-detail/components/campaign-budget/campaign-budget.tsx @@ -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 (
@@ -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()}
diff --git a/packages/admin/dashboard/src/routes/campaigns/common/components/create-campaign-form-fields/create-campaign-form-fields.tsx b/packages/admin/dashboard/src/routes/campaigns/common/components/create-campaign-form-fields/create-campaign-form-fields.tsx index 5de9c8ec4f..73b17892a8 100644 --- a/packages/admin/dashboard/src/routes/campaigns/common/components/create-campaign-form-fields/create-campaign-form-fields.tsx +++ b/packages/admin/dashboard/src/routes/campaigns/common/components/create-campaign-form-fields/create-campaign-form-fields.tsx @@ -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", + // }, ]} > diff --git a/packages/admin/dashboard/src/routes/promotions/promotion-add-campaign/components/add-campaign-promotion-form/campaign-details.tsx b/packages/admin/dashboard/src/routes/promotions/promotion-add-campaign/components/add-campaign-promotion-form/campaign-details.tsx index 8a21b390f9..958eb203d7 100644 --- a/packages/admin/dashboard/src/routes/promotions/promotion-add-campaign/components/add-campaign-promotion-form/campaign-details.tsx +++ b/packages/admin/dashboard/src/routes/promotions/promotion-add-campaign/components/add-campaign-promotion-form/campaign-details.tsx @@ -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) => {
- {t( - `campaigns.budget.type.${translationKeyMap[campaign.budget?.type]}.title`, - { - defaultValue: "-", - } - )} + {t(getTranslationKey(campaign.budget), { + defaultValue: "-", + })}