Browse Source

fix(mcp-shoprenter): handle status object in order formatting

ShopRenter API returns status as an object with name property, not a string.
Now extracts status.name for display.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fszontagh 4 months ago
parent
commit
fc9b6fac5a
1 changed files with 13 additions and 1 deletions
  1. 13 1
      supabase/functions/mcp-shoprenter/index.ts

+ 13 - 1
supabase/functions/mcp-shoprenter/index.ts

@@ -360,7 +360,19 @@ function formatOrderAsPlainText(o: any): string {
 
 
   let text = `Id: #${orderNum}`;
   let text = `Id: #${orderNum}`;
   text += `\nCustomer: ${customerName}${phone ? ' ' + phone : ''}${email ? ' ' + email : ''}`;
   text += `\nCustomer: ${customerName}${phone ? ' ' + phone : ''}${email ? ' ' + email : ''}`;
-  text += `\nStatus: ${o.status || 'unknown'}`;
+
+  // Handle status - ShopRenter returns status as an object with name property
+  let statusText = 'unknown';
+  if (o.status) {
+    if (typeof o.status === 'string') {
+      statusText = o.status;
+    } else if (o.status.name) {
+      statusText = o.status.name;
+    } else if (o.status.id) {
+      statusText = o.status.id.toString();
+    }
+  }
+  text += `\nStatus: ${statusText}`;
 
 
   const currency = o.currency?.code || o.currency || '';
   const currency = o.currency?.code || o.currency || '';
   text += `\nTotal: ${o.total || '0'}${currency ? ' ' + currency : ''}`;
   text += `\nTotal: ${o.total || '0'}${currency ? ' ' + currency : ''}`;