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,
|
||||
slug: p.slug,
|
||||
description: p.description,
|
||||
basePrice: String(p.basePrice),
|
||||
basePrice: (p.basePrice / 100).toFixed(2),
|
||||
currency: p.currency,
|
||||
status: p.status,
|
||||
attributes: JSON.stringify(p.attributes, null, 2),
|
||||
@@ -171,7 +171,7 @@ export default function AdminProductEditPage() {
|
||||
title: form.title,
|
||||
slug: form.slug,
|
||||
description: form.description,
|
||||
basePrice: parseInt(form.basePrice),
|
||||
basePrice: Math.round(parseFloat(form.basePrice) * 100),
|
||||
currency: form.currency,
|
||||
status: form.status,
|
||||
attributes,
|
||||
@@ -262,11 +262,12 @@ export default function AdminProductEditPage() {
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Input
|
||||
label="Base Price (cents)"
|
||||
label={`Base Price (${form.currency})`}
|
||||
type="number"
|
||||
value={form.basePrice}
|
||||
onChange={(e) => setForm((f) => ({ ...f, basePrice: e.target.value }))}
|
||||
min="0"
|
||||
step="0.01"
|
||||
required
|
||||
/>
|
||||
<Select
|
||||
|
||||
Reference in New Issue
Block a user