|
|
@@ -394,8 +394,8 @@ export const appRouter = router({
|
|
|
|
|
|
// 5. Stock / inventory
|
|
|
if (!erpContext && /\b(in stock|available|inventory|stock|availability)\b/.test(msgLower)) {
|
|
|
- // Try to extract a model number: capital letters + digits, e.g. "B1234-1"
|
|
|
- const modelMatch = msg.match(/\b([A-Z]{1,4}[-\s]?\d{3,}[-\w]*)\b/);
|
|
|
+ // Match model numbers: letter-first (B1234-1) or digit-first (2259W-5, 1436W-6)
|
|
|
+ const modelMatch = msg.match(/\b([A-Z]{1,4}\d{2,}[-\w]*|\d{2,}[A-Z]\d*[-\w]*)\b/i);
|
|
|
if (modelMatch) {
|
|
|
erpContext = await lookupStock({ model: modelMatch[1] }, userCtx);
|
|
|
}
|
|
|
@@ -418,7 +418,7 @@ export const appRouter = router({
|
|
|
|
|
|
// 7. Product images — "show image/photo/picture of [model]" or "image for 1436W-6"
|
|
|
if (!erpContext && /\b(image|images|photo|photos|picture|pictures|what does .* look like|show me)\b/.test(msgLower)) {
|
|
|
- const modelMatch = msg.match(/\b([A-Z]{1,5}[-]?\d{3,}[-\w]*)\b/);
|
|
|
+ const modelMatch = msg.match(/\b([A-Z]{1,4}\d{2,}[-\w]*|\d{2,}[A-Z]\d*[-\w]*)\b/i);
|
|
|
if (modelMatch) {
|
|
|
erpContext = await lookupProductImages(modelMatch[1], userCtx);
|
|
|
}
|