console
This commit is contained in:
@@ -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
|
||||
? {
|
||||
|
||||
Reference in New Issue
Block a user