From 1438b394aea8b570fa6703543faaea506ef816b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Tue, 8 Jul 2025 16:01:03 +0200 Subject: [PATCH] fix(dashboard): show TIP flag only for fixed promotions (#12897) * fix(dashboard): show TIP flag only for fixed promotions * fix: refactor changes --- .changeset/empty-apricots-confess.md | 5 +++ .../create-promotion-form/templates.ts | 32 +++++++++++++------ .../promotion-general-section.tsx | 22 +++++++------ 3 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 .changeset/empty-apricots-confess.md diff --git a/.changeset/empty-apricots-confess.md b/.changeset/empty-apricots-confess.md new file mode 100644 index 0000000000..bcf03b00b7 --- /dev/null +++ b/.changeset/empty-apricots-confess.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +fix(dashboard): show TIP flag only for fixed promotions diff --git a/packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/templates.ts b/packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/templates.ts index b07754a7da..51aea08682 100644 --- a/packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/templates.ts +++ b/packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/templates.ts @@ -4,13 +4,31 @@ const commonHiddenFields = [ "application_method.allocation", ] +const amountOfOrderHiddenFields = [...commonHiddenFields] +const amountOfProductHiddenFields = [...commonHiddenFields] + +const percentageOfOrderHiddenFields = [ + ...commonHiddenFields, + "is_tax_inclusive", +] +const percentageOfProductHiddenFields = [ + ...commonHiddenFields, + "is_tax_inclusive", +] + +const buyGetHiddenFields = [ + ...commonHiddenFields, + "application_method.value", + "is_tax_inclusive", +] + export const templates = [ { id: "amount_off_products", type: "standard", title: "Amount off products", description: "Discount specific products or collection of products", - hiddenFields: [...commonHiddenFields], + hiddenFields: amountOfProductHiddenFields, defaults: { is_automatic: "false", type: "standard", @@ -26,7 +44,7 @@ export const templates = [ type: "standard", title: "Amount off order", description: "Discounts the total order amount", - hiddenFields: [...commonHiddenFields], + hiddenFields: amountOfOrderHiddenFields, defaults: { is_automatic: "false", type: "standard", @@ -42,7 +60,7 @@ export const templates = [ type: "standard", title: "Percentage off product", description: "Discounts a percentage off selected products", - hiddenFields: [...commonHiddenFields], + hiddenFields: percentageOfProductHiddenFields, defaults: { is_automatic: "false", type: "standard", @@ -58,7 +76,7 @@ export const templates = [ type: "standard", title: "Percentage off order", description: "Discounts a percentage of the total order amount", - hiddenFields: [...commonHiddenFields], + hiddenFields: percentageOfOrderHiddenFields, defaults: { is_automatic: "false", type: "standard", @@ -74,11 +92,7 @@ export const templates = [ type: "buy_get", title: "Buy X Get Y", description: "Buy X product(s), get Y product(s)", - hiddenFields: [ - ...commonHiddenFields, - "application_method.value", - "is_tax_inclusive", - ], + hiddenFields: buyGetHiddenFields, defaults: { is_automatic: "false", type: "buyget", diff --git a/packages/admin/dashboard/src/routes/promotions/promotion-detail/components/promotion-general-section/promotion-general-section.tsx b/packages/admin/dashboard/src/routes/promotions/promotion-detail/components/promotion-general-section/promotion-general-section.tsx index 16bfc053e2..9415698c06 100644 --- a/packages/admin/dashboard/src/routes/promotions/promotion-detail/components/promotion-general-section/promotion-general-section.tsx +++ b/packages/admin/dashboard/src/routes/promotions/promotion-detail/components/promotion-general-section/promotion-general-section.tsx @@ -181,17 +181,21 @@ export const PromotionGeneralSection = ({ -