Let resolver process a subset; skip untouched rows

Previously submitting created a £0 product for every unmatched row the
user didn't touch, silently hiding it from the unmatched list. Now rows
with no chosen product and no printing cost are skipped and stay
unmatched, so items can be resolved a few at a time across syncs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
dlawler489 2026-06-13 12:24:38 +10:00
parent 9219f01ae5
commit 3c3adcdea9

View file

@ -86,10 +86,19 @@ export const MissingProductsModal: React.FC<MissingProductsModalProps> = ({
try {
const newProducts: any[] = [];
const existingMatches: any[] = [];
let skipped = 0;
for (const product of missingProducts) {
const data = productData[product.title] || {};
// Skip rows the user didn't act on (no existing product chosen and no
// printing cost entered) so they can resolve a few now and the rest
// later — untouched items stay unmatched instead of becoming £0 products
if (!data.useExisting && data.printingCost === undefined) {
skipped++;
continue;
}
// If user selected to use an existing product, save the packing-slip
// title as an alias on it so this and all future imports match it
// deterministically
@ -166,6 +175,9 @@ export const MissingProductsModal: React.FC<MissingProductsModalProps> = ({
if (existingMatches.length > 0) {
toast.success(`Matched ${existingMatches.length} items to existing products`);
}
if (skipped > 0) {
toast(`${skipped} item(s) left for later — they'll still show as unmatched`);
}
console.log('Products processed successfully, calling onComplete...');
@ -199,10 +211,12 @@ export const MissingProductsModal: React.FC<MissingProductsModalProps> = ({
<div className="p-6">
<div className="mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg">
<p className="text-blue-900 text-sm">
<strong>Found unmatched product:</strong> "{missingProducts[0]?.title}"
<strong>{missingProducts.length} unmatched item{missingProducts.length === 1 ? '' : 's'}</strong>
</p>
<p className="text-blue-700 text-xs mt-1">
This product isn't in your database yet. Add printing costs to complete the import.
Match each to an existing product or enter a printing cost to create it.
You don't have to do them all now rows you leave blank stay unmatched
and you can resolve them next time.
</p>
</div>