import { createClient } from '@/lib/supabase/server' import { getProducts, getCategories } from '@/lib/actions/products' import { getEndCustomers } from '@/lib/actions/end-customers' import { OrderWizard } from '@/components/order-wizard' import { redirect } from 'next/navigation' import { Suspense } from 'react' export default async function OrderPage() { return (

Konfigurieren Sie Ihre Lösung

Wählen Sie das passende Paket und die benötigten Module für Ihr Business.

}>
) } async function OrderDataWrapper() { const supabase = await createClient() const { data: { user } } = await supabase.auth.getUser() if (!user) { redirect('/auth/login?next=/order') } // Check user role const { data: userData } = await supabase .from('users') .select('role') .eq('id', user.id) .single() if (userData?.role === 'admin') { redirect('/admin/einstellungen') } const products = await getProducts().catch(() => []) const categories = await getCategories().catch(() => []) const endCustomers = await getEndCustomers().catch(() => []) // Fetch profile safely using maybeSingle let profile = null try { const { data } = await supabase .from('profiles') .select('*') .eq('id', user.id) .maybeSingle() profile = data } catch (e) { console.error('Fehler beim Laden des Profils:', e) } return }