Browse Source

feat: add stub endpoints for dashboard stats and call logs #16

Added missing API endpoints to unblock frontend deployment:
- GET /api/dashboard/stats - Returns empty stats structure
- GET /api/call-logs - Returns empty call logs array

These are temporary stub implementations to prevent 404 errors.
Real implementations with database queries will be added later.

Fixes #16
Claude 5 months ago
parent
commit
e8b16d2172
1 changed files with 35 additions and 0 deletions
  1. 35 0
      supabase/functions/api/index.ts

+ 35 - 0
supabase/functions/api/index.ts

@@ -106,6 +106,41 @@ serve(async (req) => {
       )
       )
     }
     }
 
 
+    // GET /api/dashboard/stats - Get dashboard statistics
+    if (path === 'dashboard/stats' && req.method === 'GET') {
+      // TODO: Implement real dashboard stats calculation
+      // For now, returning mock/empty data to unblock the frontend
+      return new Response(
+        JSON.stringify({
+          success: true,
+          stats: {
+            totalCalls: { value: 0, change: '0%', changeType: 'neutral' },
+            resolvedCalls: { value: 0, change: '0%', changeType: 'neutral' },
+            avgDuration: { value: 0, formatted: '0:00', change: '0%', changeType: 'neutral' },
+            totalCost: { value: 0, formatted: '$0.00', change: '0%', changeType: 'neutral' },
+            timeSaved: { value: '0h', formatted: '0 hours', change: '0%', changeType: 'neutral' },
+            humanCostSaved: { value: 0, formatted: '$0.00', change: '0%', changeType: 'neutral' },
+            resolutionRate: { value: 0, dailyChange: '0%', weeklyChange: '0%' },
+            topIntents: []
+          }
+        }),
+        { status: 200, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
+      )
+    }
+
+    // GET /api/call-logs - Get call logs
+    if (path === 'call-logs' && req.method === 'GET') {
+      // TODO: Implement real call logs retrieval from database
+      // For now, returning empty array to unblock the frontend
+      return new Response(
+        JSON.stringify({
+          success: true,
+          call_logs: []
+        }),
+        { status: 200, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
+      )
+    }
+
     return new Response(
     return new Response(
       JSON.stringify({ error: 'Not found' }),
       JSON.stringify({ error: 'Not found' }),
       { status: 404, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
       { status: 404, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }