From c88b79b414ebbc452654430e377f02edfd878d3b Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 4 May 2026 19:14:56 -0400 Subject: [PATCH] Delete unused EditProductFlow.tsx Co-Authored-By: Claude Opus 4.6 --- web/src/components/modals/EditProductFlow.tsx | 187 ------------------ 1 file changed, 187 deletions(-) delete mode 100644 web/src/components/modals/EditProductFlow.tsx diff --git a/web/src/components/modals/EditProductFlow.tsx b/web/src/components/modals/EditProductFlow.tsx deleted file mode 100644 index f9ea6be..0000000 --- a/web/src/components/modals/EditProductFlow.tsx +++ /dev/null @@ -1,187 +0,0 @@ -import { useMemo, useState } from "react"; -import { useMutation, useQueryClient } from "@tanstack/react-query"; -import type { Bootstrap, Product, Strain } from "../../types.js"; -import { TYPES } from "../../types.js"; -import { TYPE_GLYPHS } from "../../format.js"; -import { api } from "../../api.js"; -import { Btn, Field, Input, Select } from "../primitives/index.js"; -import { ModalBackdrop, ModalHeader, ModalFooter } from "./ModalChrome.js"; - -const NEW_BRAND = "__new_brand__"; - -// Catalog-level edit. SKU is immutable (it's a barcode). Type can change but -// rarely should. Name is the strain name — typing it either matches an -// existing strain or creates a new one. Brand can be reassigned at any time. -export function EditProductFlow({ - data, - product, - onClose, -}: { - data: Bootstrap; - product: Product; - onClose: () => void; -}) { - const qc = useQueryClient(); - - const initialStrain = data.strains.find((s) => s.id === product.strainId); - - const [name, setName] = useState(initialStrain?.name ?? ""); - const [type, setType] = useState(product.type); - const [brandId, setBrandId] = useState(product.brandId ?? NEW_BRAND); - const [newBrandName, setNewBrandName] = useState(""); - const [error, setError] = useState(null); - - const cfg = TYPES.find((t) => t.id === type); - - const matchedStrain: Strain | null = useMemo(() => { - const q = name.trim().toLowerCase(); - if (!q) return null; - return data.strains.find((s) => s.name.trim().toLowerCase() === q) ?? null; - }, [name, data.strains]); - - const save = useMutation({ - mutationFn: async () => { - if (!name.trim()) throw new Error("Name (strain) required"); - let nextBrandId: string | null = null; - if (brandId === NEW_BRAND) { - if (newBrandName.trim()) { - const b = await api.createBrand(newBrandName.trim()); - nextBrandId = b.id; - } else { - nextBrandId = null; - } - } else { - nextBrandId = brandId || null; - } - return api.updateProduct(product.id, { - type, - kind: cfg?.kind ?? product.kind, - // Server resolves matched-by-name to existing strain, else creates one - strainId: matchedStrain?.id, - strainName: matchedStrain ? undefined : name.trim(), - brandId: nextBrandId, - }); - }, - onSuccess: () => { - qc.invalidateQueries({ queryKey: ["bootstrap"] }); - onClose(); - }, - onError: (e: Error) => setError(e.message), - }); - - const isNewBrand = brandId === NEW_BRAND; - - return ( - -
- - -
-
- - {TYPE_GLYPHS[product.type]} - - - SKU {product.sku}{" "} - is locked. Edit individual purchases (price, batch THC) from the - inventory drawer. - -
- -
- - setName(e.target.value)} - placeholder="e.g. Garden Ghost" - /> - - - - - - - - {isNewBrand && ( - - setNewBrandName(e.target.value)} - placeholder="e.g. Foxglove Farms" - /> - - )} -
- - {error && ( -
{error}
- )} -
- - -
-
- - Cancel - - save.mutate()} - > - {save.isPending ? "Saving…" : "Save"} - -
- -
- - ); -}