From fdecfe6cc14780caecaa664279a65894b536abe8 Mon Sep 17 00:00:00 2001 From: abhishek Date: Mon, 7 Sep 2026 18:05:54 +0530 Subject: [PATCH] console --- src/features/catalogue/CatalogueBrowser.tsx | 31 ++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/features/catalogue/CatalogueBrowser.tsx b/src/features/catalogue/CatalogueBrowser.tsx index b4e7f88..d7569e2 100644 --- a/src/features/catalogue/CatalogueBrowser.tsx +++ b/src/features/catalogue/CatalogueBrowser.tsx @@ -256,17 +256,34 @@ export function CatalogueBrowser({ }); /** - * The category an import would actually be written under. + * The LAST-RESORT category: the tenant's first real one. * - * Falls back to the tenant's first real category rather than to nothing. - * `categoryOptions` arrives asynchronously, so this is derived at render - * instead of pushed into state by an effect — state seeded from an empty - * list would keep the old default after the categories loaded, and the - * picker would then show one thing while the request sent another. + * Only reached when a product carries no catalogue category of its own and + * nothing has been picked. `categoryOptions` arrives asynchronously, so this + * is derived at render rather than pushed into state by an effect — state + * seeded from an empty list would keep the old default after the categories + * loaded, and the picker would then show one thing while the request sent + * another. */ const defaultCategory = categoryOptions.find((option) => option.value !== '')?.value ?? ''; const chosenCategory = importInto ?? defaultCategory; + /** + * What the picker DISPLAYS, which is not the same as the fallback above. + * + * Empty until the operator picks, so the control shows its placeholder — and + * the placeholder names the catalogue's own category, which is what an + * untouched import actually uses. + * + * Showing `chosenCategory` here was a straight contradiction on screen: the + * description read "filed under Food - Mixes" while the select beside it + * showed "Category 2" as the chosen value, because the fallback had been + * pressed into service as a display value. The two are different questions — + * "what will happen" and "what have you chosen" — and only the second belongs + * in the control. + */ + const pickerValue = importInto ?? ''; + /** * True when an import would produce a product the customer app cannot show. * @@ -631,7 +648,7 @@ export function CatalogueBrowser({ isBusy={busy === catalogueKey(open)} actionLabel={actionLabel} {...(showCategoryPicker - ? { categoryOptions, categoryid: chosenCategory, onCategoryChange: setImportInto } + ? { categoryOptions, categoryid: pickerValue, onCategoryChange: setImportInto } : {})} {...(canImport && !isReadOnly && !hasNoCategory ? {