diff --git a/web/src/components/ProductDetail.tsx b/web/src/components/ProductDetail.tsx index 8a09670..f83cbaa 100644 --- a/web/src/components/ProductDetail.tsx +++ b/web/src/components/ProductDetail.tsx @@ -61,7 +61,9 @@ export function ProductDetail({ ["Strain", item.name], ["Brand", helpers.brandName(data, item.brandId)], ["Shop", helpers.shopName(data, item.shopId)], - ["Total cannabinoids", `${item.totalCannabinoids.toFixed(1)}%`], + ...(cfg?.showCannabinoidPct !== false + ? [["Total cannabinoids", `${item.totalCannabinoids.toFixed(1)}%`] as [string, React.ReactNode]] + : []), ["Purchase date", fmt.date(item.purchaseDate)], ["Bin", isCheckedOut ? "In your custody" : bin ? bin.name : ], ["Audit cadence", `Every ${cfg?.cadenceDays ?? "—"} days · ${cfg?.auditMode ?? "—"}`], @@ -203,37 +205,44 @@ export function ProductDetail({ )} -
- {( + {(() => { + const statCards: [string, React.ReactNode][] = [ + ["Price", fmt.money(item.price)], [ - ["Price", fmt.money(item.price)], - [ - item.kind === "discrete" ? "Unit weight" : "Size", - item.kind === "discrete" - ? `${item.unitWeight} g` - : `${item.weight} ${cfg?.unit ?? "g"}`, - ], - ["THC", `${item.thc.toFixed(1)}%`], - ["CBD", `${item.cbd.toFixed(1)}%`], - ] as [string, React.ReactNode][] - ).map(([l, v], i) => ( -
-
{l}
-
{v}
+ item.kind === "discrete" ? "Unit weight" : "Size", + item.kind === "discrete" + ? `${item.unitWeight} ${cfg?.weightUnit ?? "g"}` + : `${item.weight} ${cfg?.unit ?? "g"}`, + ], + ...(cfg?.showCannabinoidPct !== false + ? [ + ["THC", `${item.thc.toFixed(1)}%`] as [string, React.ReactNode], + ["CBD", `${item.cbd.toFixed(1)}%`] as [string, React.ReactNode], + ] + : []), + ]; + return ( +
+ {statCards.map(([l, v], i) => ( +
+
{l}
+
{v}
+
+ ))}
- ))} -
+ ); + })()} {(isActive || isCheckedOut) && (
diff --git a/web/src/components/modals/AddInventoryFlow.tsx b/web/src/components/modals/AddInventoryFlow.tsx index c1c617c..017859d 100644 --- a/web/src/components/modals/AddInventoryFlow.tsx +++ b/web/src/components/modals/AddInventoryFlow.tsx @@ -365,9 +365,9 @@ function InstanceDetailsStep({ weight: last?.weight ?? (isDiscrete ? 0 : 3.5), unitWeight: last?.unitWeight ?? (isDiscrete ? 0.7 : 0), price: initialPrice, - thc: last?.thc ?? 22, - cbd: last?.cbd ?? 0.4, - totalCannabinoids: last?.totalCannabinoids ?? 26, + thc: last?.thc ?? (cfg?.showCannabinoidPct !== false ? 22 : 0), + cbd: last?.cbd ?? (cfg?.showCannabinoidPct !== false ? 0.4 : 0), + totalCannabinoids: last?.totalCannabinoids ?? (cfg?.showCannabinoidPct !== false ? 26 : 0), purchaseDate: TODAY_STR, }); const [newShopName, setNewShopName] = useState(""); @@ -572,7 +572,7 @@ function InstanceDetailsStep({ }} > {isDiscrete ? ( - + )} -
- Cannabinoid profile -
-
- - update("thc", +e.target.value)} - /> - - - update("cbd", +e.target.value)} - /> - - - update("totalCannabinoids", +e.target.value)} - /> - -
+ {cfg?.showCannabinoidPct !== false && ( + <> +
+ Cannabinoid profile +
+
+ + update("thc", +e.target.value)} + /> + + + update("cbd", +e.target.value)} + /> + + + update("totalCannabinoids", +e.target.value)} + /> + +
+ + )} {error && (
{error}
diff --git a/web/src/components/modals/EditInventoryFlow.tsx b/web/src/components/modals/EditInventoryFlow.tsx index 83bcdde..0f92490 100644 --- a/web/src/components/modals/EditInventoryFlow.tsx +++ b/web/src/components/modals/EditInventoryFlow.tsx @@ -191,7 +191,7 @@ export function EditInventoryFlow({ }} > {isDiscrete ? ( - + )} -
- Cannabinoid profile -
-
- - update("thc", +e.target.value)} - /> - - - update("cbd", +e.target.value)} - /> - - - update("totalCannabinoids", +e.target.value)} - /> - -
+ {cfg?.showCannabinoidPct !== false && ( + <> +
+ Cannabinoid profile +
+
+ + update("thc", +e.target.value)} + /> + + + update("cbd", +e.target.value)} + /> + + + update("totalCannabinoids", +e.target.value)} + /> + +
+ + )} {item.audits.length > 0 && (