Tailor edible ingestion flow: use mg units and hide cannabinoid % fields
Build and push image / build (push) Successful in 59s

Edibles are dosed in milligrams, not grams, and percentage-based cannabinoid
profiles don't apply. Adds weightUnit and showCannabinoidPct to TypeConfig so
the add/edit/detail views adapt per product type.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 21:12:28 -04:00
parent a3559062db
commit 9aea9535e6
4 changed files with 124 additions and 105 deletions
+39 -30
View File
@@ -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 : <span style={{ color: "var(--ink-3)" }}></span>],
["Audit cadence", `Every ${cfg?.cadenceDays ?? "—"} days · ${cfg?.auditMode ?? "—"}`],
@@ -203,37 +205,44 @@ export function ProductDetail({
</div>
)}
<div
style={{
display: "grid",
gridTemplateColumns: "repeat(4, 1fr)",
gap: 1,
marginTop: 32,
background: "var(--line)",
border: "1px solid var(--line)",
borderRadius: "var(--r-md)",
overflow: "hidden",
}}
>
{(
{(() => {
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) => (
<div key={i} style={{ padding: "18px 16px", background: "var(--surface)" }}>
<div className="smallcaps" style={{ color: "var(--ink-3)" }}>{l}</div>
<div className="serif" style={{ fontSize: 26, marginTop: 4, fontWeight: 500 }}>{v}</div>
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 (
<div
style={{
display: "grid",
gridTemplateColumns: `repeat(${statCards.length}, 1fr)`,
gap: 1,
marginTop: 32,
background: "var(--line)",
border: "1px solid var(--line)",
borderRadius: "var(--r-md)",
overflow: "hidden",
}}
>
{statCards.map(([l, v], i) => (
<div key={i} style={{ padding: "18px 16px", background: "var(--surface)" }}>
<div className="smallcaps" style={{ color: "var(--ink-3)" }}>{l}</div>
<div className="serif" style={{ fontSize: 26, marginTop: 4, fontWeight: 500 }}>{v}</div>
</div>
))}
</div>
))}
</div>
);
})()}
{(isActive || isCheckedOut) && (
<div style={{ marginTop: 20 }}>