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

View File

@@ -6,13 +6,13 @@ import { Form } from "../../common/form"
interface HeadlessControllerProps<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
> extends Omit<ControllerProps<TFieldValues, TName>, "render"> {}
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> extends Omit<ControllerProps<TFieldValues, TName>, "render"> {}
interface SwitchBoxProps<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
> extends HeadlessControllerProps<TFieldValues, TName>{
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> extends HeadlessControllerProps<TFieldValues, TName> {
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<TFieldValues> = FieldPath<TFieldValues>
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
>({
label,
description,
@@ -49,10 +49,14 @@ export const SwitchBox = <
<Form.Item>
<div className="bg-ui-bg-component shadow-elevation-card-rest flex items-start gap-x-3 rounded-lg p-3">
<Form.Control>
<Switch {...field} checked={value} onCheckedChange={(e) => {
onCheckedChange?.(e)
onChange(e)
}} />
<Switch
{...field}
checked={value}
onCheckedChange={(e) => {
onCheckedChange?.(e)
onChange(e)
}}
/>
</Form.Control>
<div>
<Form.Label optional={optional} tooltip={tooltip}>
@@ -67,4 +71,4 @@ export const SwitchBox = <
}}
/>
)
}
}

View File

@@ -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,