Files
recall/src/app/edit/[id]/page.tsx
T
2026-03-22 13:01:46 -03:00

31 lines
864 B
TypeScript

import { prisma } from '@/lib/prisma'
import { notFound } from 'next/navigation'
import { NoteForm } from '@/components/note-form'
import { NoteType } from '@/types/note'
export default async function EditNotePage({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params
const note = await prisma.note.findUnique({
where: { id },
include: { tags: { include: { tag: true } } },
})
if (!note) {
notFound()
}
const noteWithTags = {
...note,
createdAt: note.createdAt.toISOString(),
updatedAt: note.updatedAt.toISOString(),
type: note.type as NoteType,
tags: note.tags.map(nt => ({ tag: nt.tag })),
}
return (
<main className="container mx-auto py-8 px-4">
<h1 className="text-2xl font-bold mb-6">Editar nota</h1>
<NoteForm initialData={noteWithTags} isEdit />
</main>
)
}