diff --git a/src/app/notes/page.tsx b/src/app/notes/page.tsx index 0f2bbaf..f654347 100644 --- a/src/app/notes/page.tsx +++ b/src/app/notes/page.tsx @@ -1,3 +1,4 @@ +import Note from "@/components/Note"; import prisma from "@/lib/db/prisma"; import { auth } from "@clerk/nextjs"; import { Metadata } from "next"; @@ -13,5 +14,16 @@ export default async function NotesPage() { const allNotes = await prisma.note.findMany({ where: { userId } }); - return
{JSON.stringify(allNotes)}
; + return ( +
+ {allNotes.map((note) => ( + + ))} + {allNotes.length === 0 && ( +
+ {"You don't have any notes yet. Why don't you create one?"} +
+ )} +
+ ); } diff --git a/src/components/Note.tsx b/src/components/Note.tsx new file mode 100644 index 0000000..40b03ca --- /dev/null +++ b/src/components/Note.tsx @@ -0,0 +1,35 @@ +import { Note as NoteModel } from "@prisma/client"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "./ui/card"; + +interface NoteProps { + note: NoteModel; +} + +export default function Note({ note }: NoteProps) { + const wasUpdated = note.updatedAt > note.createdAt; + + const createdUpdatedAtTimestamp = ( + wasUpdated ? note.updatedAt : note.createdAt + ).toDateString(); + + return ( + + + {note.title} + + {createdUpdatedAtTimestamp} + {wasUpdated && " (updated)"} + + + +

{note.content}

+
+
+ ); +}