From d06729d0d14d7f657a2cdeb958dd7ac6d3c6f199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Fri, 2 Jan 2026 11:46:50 +0100 Subject: [PATCH] fix(dashboard): form reset for across allocation (#14369) **What** - fix an issue where switching between `across` promotion types in the create form wouldn't set `max_quantity` to null which would cause the create request to fail --- CLOSES https://github.com/medusajs/medusa/issues/14365 --- > [!NOTE] > Prevents invalid `max_quantity` when switching templates to an *across* allocation in the promotion creation flow. > > - In `create-promotion-form.tsx`, after applying template defaults, explicitly sets `application_method.max_quantity` to `null` if `application_method.allocation` is `"across"` to avoid resetting it to `1` > - Adds a changeset entry for `@medusajs/dashboard` patch release > > Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5b08c77fee741ec5de399b4f1f9e245ba69b5bee. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot). Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com> --- .changeset/eight-baths-win.md | 5 +++++ .../create-promotion-form/create-promotion-form.tsx | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 .changeset/eight-baths-win.md diff --git a/.changeset/eight-baths-win.md b/.changeset/eight-baths-win.md new file mode 100644 index 0000000000..9fe3d44628 --- /dev/null +++ b/.changeset/eight-baths-win.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +fix(dashboard): form reset for across allocation diff --git a/packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/create-promotion-form.tsx b/packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/create-promotion-form.tsx index d823263943..eebf5f33bf 100644 --- a/packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/create-promotion-form.tsx +++ b/packages/admin/dashboard/src/routes/promotions/promotion-create/components/create-promotion-form/create-promotion-form.tsx @@ -275,6 +275,12 @@ export const CreatePromotionForm = () => { } } + // if switching to `across` allocation, reset call above will set the max quantity to 1 which is forbidden for this allocation type + // but since there wasn't change in the `application_method.allocation` field, useEffect below responsible for resetting will not be triggered + if (currentTemplate.defaults?.application_method?.allocation === "across") { + setValue("application_method.max_quantity", null) + } + return currentTemplate }, [watchTemplateId, setValue, reset])