import { notFound } from "next/navigation";
import { getCurrentSession } from "@/lib/session";
import { NoteEditor } from "@/modules/notes/components/note-editor";
import { getNote } from "@/modules/notes/server/queries";

export default async function NotePage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const [{ user }, note] = await Promise.all([getCurrentSession(), getNote(id).catch(() => null)]);
  if (!note) notFound();

  return <NoteEditor note={note} currentUserId={user.id} />;
}
