import { createClient } from '@/lib/supabase/server' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Package, ShoppingCart, Users, TrendingUp } from 'lucide-react' import { AdminRecentOrders } from '@/components/admin/recent-orders' // ─── KPI-Daten aus DB ──────────────────────────────────────────────────────── async function getKpis() { const supabase = await createClient() 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 }), supabase.from('products').select('*', { count: 'exact', head: true }), ]) const totalRevenue = (orders ?? []).reduce((sum, o) => sum + Number(o.total_price), 0) const orderCount = (orders ?? []).length return { totalRevenue, orderCount, userCount: userCount ?? 0, productCount: productCount ?? 0 } } export default async function AdminDashboard() { const { totalRevenue, orderCount, userCount, productCount } = await getKpis() return (
Aus allen Bestellungen
Gesamt
Im Katalog
Registrierte User