import { AdminDashboardPageQuery } from '@/lib/page-queries/AdminDashboardPageQuery';
import { AdminDashboardTemplate } from '@/templates/AdminDashboardTemplate';
import { ErrorBanner } from '@/components/ui/ErrorBanner';

export default async function AdminPage() {
  const result = await AdminDashboardPageQuery.execute();
  
  if (result.isErr()) {
    const error = result.getError();
    if (error === 'notFound') {
      return (
        <ErrorBanner
          title="Access Denied"
          message="You must be logged in as an Owner or Admin"
          variant="error"
        />
      );
    }
    return (
      <ErrorBanner
        title="Load Failed"
        message={`Failed to load dashboard: ${error}`}
        variant="error"
      />
    );
  }
  
  const output = result.unwrap();
  
  // For now, use empty callbacks. In a real app, these would be Server Actions
  // that trigger revalidation or navigation
  return <AdminDashboardTemplate adminDashboardViewData={output} onRefresh={() => {}} isLoading={false} />;
}