Bouquet builder: mylars from Build category, latex from full catalog

Previously both mylar and latex items had to be in the Build category.
Now: mylar options = Build category items without showColors; latex
options = all showColors items in the catalog, no extra tagging needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
chris 2026-06-18 12:37:23 -04:00
parent 7b7c3efb65
commit 52a9828b96

View File

@ -65,14 +65,19 @@ export default function BouquetPicker({ product, onClose }: Props) {
fetch(BASE + '/api/catalog').then((r) => r.ok ? r.json() : { items: [] }), fetch(BASE + '/api/catalog').then((r) => r.ok ? r.json() : { items: [] }),
fetch(BASE + '/colors.json').then((r) => r.ok ? r.json() : []), fetch(BASE + '/colors.json').then((r) => r.ok ? r.json() : []),
]).then(([{ items }, families]: [{ items: CatalogItem[] }, ColorFamily[]]) => { ]).then(([{ items }, families]: [{ items: CatalogItem[] }, ColorFamily[]]) => {
const filtered = items.filter((item) => const inBuild = (item: CatalogItem) =>
(item.categories ?? []).includes('build') || item.category === 'build' (item.categories ?? []).includes('build') || item.category === 'build'
)
setBuildItems(filtered) // Mylars: anything in the "Build" category that isn't a latex item
const mylars = items.filter((i) => inBuild(i) && !i.showColors)
// Latex: all latex items in the catalog (showColors drives the color picker)
const latex = items.filter((i) => i.showColors)
setBuildItems([...mylars, ...latex])
setColorFamilies(families) setColorFamilies(families)
const initMylar: Record<string, { variationId: string; quantity: number }> = {} const initMylar: Record<string, { variationId: string; quantity: number }> = {}
filtered.filter((i) => !i.showColors).forEach((item) => { mylars.forEach((item) => {
const defaultVar = const defaultVar =
item.variations.find((v) => v.inventory === null || v.inventory > 0) ?? item.variations.find((v) => v.inventory === null || v.inventory > 0) ??
item.variations[0] item.variations[0]
@ -186,10 +191,10 @@ export default function BouquetPicker({ product, onClose }: Props) {
{loading ? ( {loading ? (
<p className="has-text-grey has-text-centered" style={{ padding: '2rem' }}>Loading</p> <p className="has-text-grey has-text-centered" style={{ padding: '2rem' }}>Loading</p>
) : buildItems.length === 0 ? ( ) : mylarItems.length === 0 && latexItems.length === 0 ? (
<p className="has-text-grey has-text-centered" style={{ padding: '2rem' }}> <p className="has-text-grey has-text-centered" style={{ padding: '2rem' }}>
No items are set up for the bouquet builder yet.<br /> No items are set up for the bouquet builder yet.<br />
Add a &ldquo;Build&rdquo; category to items in Square to make them available here. Add a &ldquo;Build&rdquo; category to mylar items in Square to make them available here.
</p> </p>
) : ( ) : (
<> <>