fix(dashboard): product create discountable flag (#12073)

* fix(dashboard): product create discountable flag

* chore: changeset
This commit is contained in:
Frane Polić
2025-04-06 17:32:27 +02:00
committed by GitHub
parent 9bf1e52d25
commit f01e0868bd
3 changed files with 21 additions and 12 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---
fix(dashboard): product create discountable flag
@@ -6,13 +6,13 @@ import { Form } from "../../common/form"
interface HeadlessControllerProps< interface HeadlessControllerProps<
TFieldValues extends FieldValues = FieldValues, TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues> TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> extends Omit<ControllerProps<TFieldValues, TName>, "render"> {} > extends Omit<ControllerProps<TFieldValues, TName>, "render"> {}
interface SwitchBoxProps< interface SwitchBoxProps<
TFieldValues extends FieldValues = FieldValues, TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues> TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> extends HeadlessControllerProps<TFieldValues, TName>{ > extends HeadlessControllerProps<TFieldValues, TName> {
label: string label: string
description: string description: string
optional?: boolean optional?: boolean
@@ -26,13 +26,13 @@ interface SwitchBoxProps<
/** /**
* Wrapper for the Switch component to be used with `react-hook-form`. * Wrapper for the Switch component to be used with `react-hook-form`.
* *
* Use this component whenever a design calls for wrapping the Switch component * Use this component whenever a design calls for wrapping the Switch component
* in a container with a label and description. * in a container with a label and description.
*/ */
export const SwitchBox = < export const SwitchBox = <
TFieldValues extends FieldValues = FieldValues, TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues> TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
>({ >({
label, label,
description, description,
@@ -49,10 +49,14 @@ export const SwitchBox = <
<Form.Item> <Form.Item>
<div className="bg-ui-bg-component shadow-elevation-card-rest flex items-start gap-x-3 rounded-lg p-3"> <div className="bg-ui-bg-component shadow-elevation-card-rest flex items-start gap-x-3 rounded-lg p-3">
<Form.Control> <Form.Control>
<Switch {...field} checked={value} onCheckedChange={(e) => { <Switch
onCheckedChange?.(e) {...field}
onChange(e) checked={value}
}} /> onCheckedChange={(e) => {
onCheckedChange?.(e)
onChange(e)
}}
/>
</Form.Control> </Form.Control>
<div> <div>
<Form.Label optional={optional} tooltip={tooltip}> <Form.Label optional={optional} tooltip={tooltip}>
@@ -67,4 +71,4 @@ export const SwitchBox = <
}} }}
/> />
) )
} }
@@ -36,7 +36,7 @@ export const normalizeProductFormValues = (
title: values.title.trim(), title: values.title.trim(),
subtitle: values.subtitle?.trim(), subtitle: values.subtitle?.trim(),
description: values.description?.trim(), description: values.description?.trim(),
discountable: values.discountable || undefined, discountable: values.discountable,
width: values.width ? parseFloat(values.width) : undefined, width: values.width ? parseFloat(values.width) : undefined,
length: values.length ? parseFloat(values.length) : undefined, length: values.length ? parseFloat(values.length) : undefined,
height: values.height ? parseFloat(values.height) : undefined, height: values.height ? parseFloat(values.height) : undefined,