)}
- {isDiscrete && form.price > 0 && form.countOriginal > 0 && (
-
- Total:{" "}
-
- {fmt.money(totalPrice)}
-
-
- ({form.countOriginal} × {fmt.money(form.price)})
-
-
- )}
0
- ? item.price / item.countOriginal
- : item.price;
const [form, setForm] = useState({
shopId: item.shopId ?? NEW_SHOP,
binId: item.binId ?? NEW_BIN,
weight: item.weight,
- countOriginal: item.countOriginal,
unitWeight: item.unitWeight,
- price: initialPrice,
+ price: item.price,
thc: item.thc,
cbd: item.cbd,
totalCannabinoids: item.totalCannabinoids,
@@ -50,7 +44,6 @@ export function EditInventoryFlow({
setForm((f) => ({ ...f, [k]: v }));
const cfg = TYPES.find((t) => t.id === item.type);
- const totalPrice = isDiscrete ? form.price * form.countOriginal : form.price;
const cpg = !isDiscrete && form.weight > 0 ? form.price / form.weight : 0;
const save = useMutation({
@@ -76,9 +69,8 @@ export function EditInventoryFlow({
shopId,
binId,
weight: isDiscrete ? undefined : form.weight,
- countOriginal: isDiscrete ? form.countOriginal : undefined,
unitWeight: isDiscrete ? form.unitWeight : undefined,
- price: totalPrice,
+ price: form.price,
thc: form.thc,
cbd: form.cbd,
totalCannabinoids: form.totalCannabinoids,
@@ -223,24 +215,14 @@ export function EditInventoryFlow({
}}
>
{isDiscrete ? (
- <>
-
- update("countOriginal", +e.target.value)}
- />
-
-
- update("unitWeight", +e.target.value)}
- />
-
- >
+
+ update("unitWeight", +e.target.value)}
+ />
+
) : (
)}
-
+
)}
- {isDiscrete && form.price > 0 && form.countOriginal > 0 && (
-
- Total:{" "}
-
- {fmt.money(totalPrice)}
-
-
- ({form.countOriginal} × {fmt.money(form.price)})
-
-
- )}