fix: query orders using admin client in admin routes to bypass RLS and show all orders to admin
All checks were successful
Staging Build / build (push) Successful in 3m24s
All checks were successful
Staging Build / build (push) Successful in 3m24s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { createClient } from '@/lib/supabase/server'
|
||||
import { createAdminClient } from '@/lib/supabase/admin'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { Package, ShoppingCart, Users, TrendingUp } from 'lucide-react'
|
||||
import { AdminRecentOrders } from '@/components/admin/recent-orders'
|
||||
@@ -6,14 +7,15 @@ import { AdminRecentOrders } from '@/components/admin/recent-orders'
|
||||
// ─── KPI-Daten aus DB ────────────────────────────────────────────────────────
|
||||
async function getKpis() {
|
||||
const supabase = await createClient()
|
||||
const adminDb = createAdminClient()
|
||||
|
||||
const [
|
||||
{ data: orders },
|
||||
{ count: userCount },
|
||||
{ count: productCount },
|
||||
] = await Promise.all([
|
||||
supabase.from('orders').select('total_price, status'),
|
||||
supabase.from('profiles').select('*', { count: 'exact', head: true }),
|
||||
adminDb.from('orders').select('total_price, status'),
|
||||
adminDb.from('profiles').select('*', { count: 'exact', head: true }),
|
||||
supabase.from('products').select('*', { count: 'exact', head: true }),
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user