fix: accept price in currency units instead of cents in product form
Il campo prezzo del form admin ora accetta valori in unità (es. 19.99) invece di centesimi (1999). La conversione *100 avviene al submit, il DB e Stripe continuano a ricevere centesimi.
This commit is contained in:
@@ -82,7 +82,7 @@ export default function AdminProductEditPage() {
|
|||||||
title: p.title,
|
title: p.title,
|
||||||
slug: p.slug,
|
slug: p.slug,
|
||||||
description: p.description,
|
description: p.description,
|
||||||
basePrice: String(p.basePrice),
|
basePrice: (p.basePrice / 100).toFixed(2),
|
||||||
currency: p.currency,
|
currency: p.currency,
|
||||||
status: p.status,
|
status: p.status,
|
||||||
attributes: JSON.stringify(p.attributes, null, 2),
|
attributes: JSON.stringify(p.attributes, null, 2),
|
||||||
@@ -171,7 +171,7 @@ export default function AdminProductEditPage() {
|
|||||||
title: form.title,
|
title: form.title,
|
||||||
slug: form.slug,
|
slug: form.slug,
|
||||||
description: form.description,
|
description: form.description,
|
||||||
basePrice: parseInt(form.basePrice),
|
basePrice: Math.round(parseFloat(form.basePrice) * 100),
|
||||||
currency: form.currency,
|
currency: form.currency,
|
||||||
status: form.status,
|
status: form.status,
|
||||||
attributes,
|
attributes,
|
||||||
@@ -262,11 +262,12 @@ export default function AdminProductEditPage() {
|
|||||||
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<Input
|
<Input
|
||||||
label="Base Price (cents)"
|
label={`Base Price (${form.currency})`}
|
||||||
type="number"
|
type="number"
|
||||||
value={form.basePrice}
|
value={form.basePrice}
|
||||||
onChange={(e) => setForm((f) => ({ ...f, basePrice: e.target.value }))}
|
onChange={(e) => setForm((f) => ({ ...f, basePrice: e.target.value }))}
|
||||||
min="0"
|
min="0"
|
||||||
|
step="0.01"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
Reference in New Issue
Block a user