TypeScriptNext.js / ReactDifficulty 2/3
// app/notas/[id]/page.tsx
import { db } from "@/lib/db";
import { getSession } from "@/lib/session";
export default async function NotePage({ params }: { params: Promise<{ id: string }> }) {
const session = await getSession();
const { id } = await params;
const note = await db.note.findFirst({
where: {
id,
OR: [{ ownerId: session.userId }, { sharedWith: { some: { userId: session.userId } } }],
},
});
if (!note) return <p>Note not found</p>;
return (
<article>
<h1>{note.title}</h1>
<div dangerouslySetInnerHTML={{ __html: note.body }} />
</article>
);
}