// /src/app/profile/[steamId]/layout.tsx
import type { ReactNode } from 'react'
import { notFound } from 'next/navigation'
import { prisma } from '@/app/lib/prisma'
import Card from '@/app/components/Card'
import UserHeader from '@/app/components/UserHeader'

export default async function ProfileLayout({
  children,
  params,
}: {
  children: ReactNode
  params: { steamId: string }
}) {
  const user = await prisma.user.findUnique({
    where: { steamId: params.steamId },
    select: {
      steamId: true,
      name: true,
      avatar: true,
      premierRank: true, 
    },
  })

  if (!user) return notFound()

  return (
    <Card maxWidth="auto">
      <div className="max-w-4xl mx-auto py-8 px-4 space-y-6">
        <UserHeader steamId={user.steamId} name={user.name ?? ''} avatar={user.avatar} premierRank={user.premierRank} />
        <div className="pt-6">{children}</div>
      </div>
    </Card>
  )
}
