From f01e0868bd669b0203bd0f3db3bb908062b1f2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Sun, 6 Apr 2025 17:32:27 +0200 Subject: [PATCH] fix(dashboard): product create discountable flag (#12073) * fix(dashboard): product create discountable flag * chore: changeset --- .changeset/afraid-socks-refuse.md | 5 ++++ .../common/switch-box/switch-box.tsx | 26 +++++++++++-------- .../routes/products/product-create/utils.ts | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 .changeset/afraid-socks-refuse.md diff --git a/.changeset/afraid-socks-refuse.md b/.changeset/afraid-socks-refuse.md new file mode 100644 index 0000000000..b0ef08dedb --- /dev/null +++ b/.changeset/afraid-socks-refuse.md @@ -0,0 +1,5 @@ +--- +"@medusajs/dashboard": patch +--- + +fix(dashboard): product create discountable flag diff --git a/packages/admin/dashboard/src/components/common/switch-box/switch-box.tsx b/packages/admin/dashboard/src/components/common/switch-box/switch-box.tsx index 856753c599..913b8c16d2 100644 --- a/packages/admin/dashboard/src/components/common/switch-box/switch-box.tsx +++ b/packages/admin/dashboard/src/components/common/switch-box/switch-box.tsx @@ -6,13 +6,13 @@ import { Form } from "../../common/form" interface HeadlessControllerProps< TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath -> extends Omit, "render"> {} + TName extends FieldPath = FieldPath, +> extends Omit, "render"> {} interface SwitchBoxProps< TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath -> extends HeadlessControllerProps{ + TName extends FieldPath = FieldPath, +> extends HeadlessControllerProps { label: string description: string optional?: boolean @@ -26,13 +26,13 @@ interface SwitchBoxProps< /** * Wrapper for the Switch component to be used with `react-hook-form`. - * + * * Use this component whenever a design calls for wrapping the Switch component * in a container with a label and description. */ export const SwitchBox = < TFieldValues extends FieldValues = FieldValues, - TName extends FieldPath = FieldPath + TName extends FieldPath = FieldPath, >({ label, description, @@ -49,10 +49,14 @@ export const SwitchBox = <
- { - onCheckedChange?.(e) - onChange(e) - }} /> + { + onCheckedChange?.(e) + onChange(e) + }} + />
@@ -67,4 +71,4 @@ export const SwitchBox = < }} /> ) -} \ No newline at end of file +} diff --git a/packages/admin/dashboard/src/routes/products/product-create/utils.ts b/packages/admin/dashboard/src/routes/products/product-create/utils.ts index 848e7c67b3..31c74fd954 100644 --- a/packages/admin/dashboard/src/routes/products/product-create/utils.ts +++ b/packages/admin/dashboard/src/routes/products/product-create/utils.ts @@ -36,7 +36,7 @@ export const normalizeProductFormValues = ( title: values.title.trim(), subtitle: values.subtitle?.trim(), description: values.description?.trim(), - discountable: values.discountable || undefined, + discountable: values.discountable, width: values.width ? parseFloat(values.width) : undefined, length: values.length ? parseFloat(values.length) : undefined, height: values.height ? parseFloat(values.height) : undefined,