"use server"; import { getAdminUser } from "@/lib/admin-permissions"; import { getActiveBrandId } from "@/lib/brand-scope"; import { supabase } from "@/lib/supabase"; import AdminAccessDenied from "@/components/admin/AdminAccessDenied"; import TaxDashboard from "@/components/admin/TaxDashboard"; import { PageHeader } from "@/components/admin/design-system"; type Props = { params: Promise<{ brandId?: string }>; }; export default async function TaxesPage({ params }: Props) { const { brandId: brandIdParam } = await params; const adminUser = await getAdminUser(); if (!adminUser) return ; const activeBrandId = await getActiveBrandId(adminUser, brandIdParam); if (!activeBrandId && adminUser.role !== "platform_admin") { return ; } const effectiveBrandId = activeBrandId ?? ""; const isPlatformAdmin = adminUser.role === "platform_admin"; let resolvedBrandId = effectiveBrandId; if (isPlatformAdmin && !resolvedBrandId) { const { data: firstBrand } = await supabase .from("brands") .select("id") .limit(1) .single() as unknown as { data: { id: string } | null }; if (firstBrand?.id) { resolvedBrandId = String(firstBrand.id); } else { return (

No Brands Found

Create a brand in the database first.

Back to Admin
); } } if (!resolvedBrandId) return ; const { data: brands } = await supabase .from("brands") .select("id, name") .order("name"); const allBrands = (brands ?? []) as Array<{ id: string; name: string }>; return (
); }