diff --git a/web/src/components/ProductDetail.tsx b/web/src/components/ProductDetail.tsx index 74738bb..74dcaf5 100644 --- a/web/src/components/ProductDetail.tsx +++ b/web/src/components/ProductDetail.tsx @@ -216,35 +216,11 @@ export function ProductDetail({ > {( [ + ["Price", fmt.money(item.price)], [ - "Price", - item.kind === "discrete" && item.countOriginal > 0 ? ( - <> - {fmt.money(item.price / item.countOriginal)} - - /unit - -
- {fmt.money(item.price)} total -
- - ) : ( - fmt.money(item.price) - ), - ], - [ - item.kind === "discrete" ? "Quantity" : "Size", + item.kind === "discrete" ? "Unit weight" : "Size", item.kind === "discrete" - ? `${item.countOriginal} ${cfg?.unit ?? "ct"}` + ? `${item.unitWeight} g` : `${item.weight} ${cfg?.unit ?? "g"}`, ], ["THC", `${item.thc.toFixed(1)}%`], diff --git a/web/src/components/modals/AddInventoryFlow.tsx b/web/src/components/modals/AddInventoryFlow.tsx index bce5d51..bb2f04a 100644 --- a/web/src/components/modals/AddInventoryFlow.tsx +++ b/web/src/components/modals/AddInventoryFlow.tsx @@ -397,7 +397,6 @@ function InstanceDetailsStep({ shopId: last?.shopId ?? data.shops[0]?.id ?? NEW_SHOP, binId: data.bins[0]?.id ?? NEW_BIN, weight: last?.weight ?? (isDiscrete ? 0 : 3.5), - countOriginal: last?.countOriginal ?? (isDiscrete ? 1 : 0), unitWeight: last?.unitWeight ?? (isDiscrete ? 0.7 : 0), price: initialPrice, thc: last?.thc ?? 22, @@ -414,7 +413,6 @@ function InstanceDetailsStep({ const update = (k: K, v: (typeof form)[K]) => setForm((f) => ({ ...f, [k]: v })); - const totalPrice = isDiscrete ? form.price * form.countOriginal : form.price; const cpg = !isDiscrete && form.weight > 0 ? form.price / form.weight : 0; const assetIdValid = ASSET_ID_RE.test(assetId); const assetIdConflict = @@ -447,9 +445,9 @@ function InstanceDetailsStep({ shopId, binId, weight: isDiscrete ? undefined : form.weight, - countOriginal: isDiscrete ? form.countOriginal : undefined, + countOriginal: isDiscrete ? 1 : undefined, unitWeight: isDiscrete ? form.unitWeight : undefined, - price: totalPrice, + price: form.price, thc: form.thc, cbd: form.cbd, totalCannabinoids: form.totalCannabinoids, @@ -608,24 +606,14 @@ function InstanceDetailsStep({ }} > {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)}) - -
- )}
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)}) - -
- )}