TypeScriptNext.js / ReactDifficulty 1/3
// app/perfil/page.tsx (Server Component)
import { db } from "@/lib/db";
import { getSession } from "@/lib/session";
import { ProfileCard } from "./profile-card";
export default async function Page() {
const session = await getSession();
if (!session) return null;
const user = await db.user.findUnique({ where: { id: session.userId } });
return <ProfileCard user={user} />;
}
// app/perfil/profile-card.tsx
"use client";
export function ProfileCard({ user }: { user: { name: string; avatarUrl: string | null } }) {
return (
<section>
<img src={user.avatarUrl ?? ""} alt="" />
<h2>{user.name}</h2>
</section>
);
}