import { usersData } from "@/src/utils/dummy-data/profileData";
import UserProfilePage from "@/src/components/user/profilepage/profile";
import AuthGuard from "@/src/components/reusables/auth";

type Params = {
  id: string;
};

export default async function InterestedInMe({
  params,
}: {
  params: Promise<Params>;
}) {
  // Await the params Promise
  const resolvedParams = await params;
  const { id } = resolvedParams;

  console.log(
    "Available users:",
    usersData.map((user) => user.id)
  );
  console.log("Requested user ID:", id);
  console.log("Type of requested ID:", typeof id);

  // Try to find the user with the matching ID
  const userData = usersData.find((user) => {
    console.log(
      `Comparing user ID: ${user.id} (${typeof user.id}) with id: ${id} (${typeof id})`
    );
    return user.id === id;
  });

  if (!userData) {
    return (
      <AuthGuard>
        <div>
          <h1>User not found</h1>
          <p>Could not find user with ID: {id}</p>
          <p>
            Available user IDs: {usersData.map((user) => user.id).join(", ")}
          </p>
        </div>
      </AuthGuard>
    );
  }

  return (
    <AuthGuard>
      <UserProfilePage userData={userData} viewMode={true} />
    </AuthGuard>
  );
}
