import { getServerLocale } from "@/lib/i18n/server";
import { Header } from "@/components/layout/Header";
import Footer from "@/components/layout/Footer";
import UserProfileShell from "@/features/user/components/UserProfileShell";

interface UserPageProps {
  params: Promise<{ userId: string }>;
}

export default async function UserPage({ params }: UserPageProps) {
  const { userId } = await params;
  const locale = await getServerLocale();
  const targetUserId = parseInt(userId, 10);

  if (isNaN(targetUserId)) {
    return (
      <div className="dt-fade-in">
        <Header locale={locale} />
        <main style={{ minHeight: "60vh", display: "flex", alignItems: "center", justifyContent: "center" }}>
          <p style={{ color: "#6b7280" }}>User not found.</p>
        </main>
        <Footer locale={locale} />
      </div>
    );
  }

  return (
    <div className="dt-fade-in">
      <Header locale={locale} />
      <UserProfileShell targetUserId={targetUserId} />
      <Footer locale={locale} />
    </div>
  );
}
