import { ProfilePageQuery } from '@/lib/page-queries/ProfilePageQuery';
import { notFound } from 'next/navigation';
import { ProfilePageClient } from './ProfilePageClient';

export default async function ProfilePage() {
  const query = new ProfilePageQuery();
  const result = await query.execute();

  if (result.isErr()) {
    notFound();
  }

  const viewData = result.unwrap();
  const mode = viewData.driver.id ? 'profile-exists' : 'needs-profile';

  return (
    <ProfilePageClient
      viewData={viewData}
      mode={mode}
    />
  );
}
