diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 04016705..497a9c2a 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -15,6 +15,6 @@ model Note { id Int @id @default(autoincrement()) title String content String - created_at DateTime @default(now()) - updated_at DateTime @default(now()) + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @default(now()) @map("updated_at") } \ No newline at end of file diff --git a/backend/prisma/seed.ts b/backend/prisma/seed.ts index 0f1b310b..4f9da588 100644 --- a/backend/prisma/seed.ts +++ b/backend/prisma/seed.ts @@ -6,56 +6,56 @@ export const seed = [ { "title": "Meeting Notes", "content": "Discussed project timelines and goals.", - "created_at": "2024-02-05T23:33:42.252Z", - "updated_at": "2024-02-05T23:33:42.252Z", + "createdAt": "2024-02-05T23:33:42.252Z", + "updatedAt": "2024-02-05T23:33:42.252Z", }, { "title": "Shopping List", "content": "Milk, eggs, bread, and fruits.", - "created_at": "2024-02-05T23:33:42.253Z", - "updated_at": "2024-02-05T23:33:42.253Z", + "createdAt": "2024-02-05T23:33:42.253Z", + "updatedAt": "2024-02-05T23:33:42.253Z", }, { "title": "Recipe", "content": "Ingredients: Chicken, tomatoes, onions, garlic.", - "created_at": "2024-02-05T23:33:42.254Z", - "updated_at": "2024-02-05T23:33:42.254Z", + "createdAt": "2024-02-05T23:33:42.254Z", + "updatedAt": "2024-02-05T23:33:42.254Z", }, { "title": "Ideas", "content": "Brainstorming ideas for the next feature release. 🚀", - "created_at": "2024-02-05T23:33:42.255Z", - "updated_at": "2024-02-05T23:33:42.255Z", + "createdAt": "2024-02-05T23:33:42.255Z", + "updatedAt": "2024-02-05T23:33:42.255Z", }, { "title": "Personal Goals", "content": "Exercise for 30 minutes daily. Read a book every week.", - "created_at": "2024-02-05T23:33:42.256Z", - "updated_at": "2024-02-05T23:33:42.256Z", + "createdAt": "2024-02-05T23:33:42.256Z", + "updatedAt": "2024-02-05T23:33:42.256Z", }, { "title": "Fête d'anniversaire", "content": "Préparer une surprise pour la fête d'anniversaire.", - "created_at": "2024-02-05T23:33:42.257Z", - "updated_at": "2024-02-05T23:33:42.257Z", + "createdAt": "2024-02-05T23:33:42.257Z", + "updatedAt": "2024-02-05T23:33:42.257Z", }, { "title": "日本旅行", "content": "計画: 東京、京都、大阪を訪れる。", - "created_at": "2024-02-05T23:33:42.258Z", - "updated_at": "2024-02-05T23:33:42.258Z", + "createdAt": "2024-02-05T23:33:42.258Z", + "updatedAt": "2024-02-05T23:33:42.258Z", }, { "title": "Семейный ужин", "content": "Приготовить вкусный ужин для всей семьи.", - "created_at": "2024-02-05T23:33:42.259Z", - "updated_at": "2024-02-05T23:33:42.259Z", + "createdAt": "2024-02-05T23:33:42.259Z", + "updatedAt": "2024-02-05T23:33:42.259Z", }, { "title": "Coding Project", "content": "Implement new features using React and Express.", - "created_at": "2024-02-05T23:33:42.260Z", - "updated_at": "2024-02-05T23:33:42.260Z", + "createdAt": "2024-02-05T23:33:42.260Z", + "updatedAt": "2024-02-05T23:33:42.260Z", } ]; diff --git a/backend/src/index.ts b/backend/src/index.ts index 976d475f..641489a5 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -10,7 +10,7 @@ app.use(cors()) app.get("/api/notes", async (req, res) => { try { - const notes = await prisma.note.findMany({ orderBy: { updated_at: "desc" }}); + const notes = await prisma.note.findMany({ orderBy: { updatedAt: "desc" }}); res.json(notes); } catch (error) { @@ -50,7 +50,7 @@ app.put("/api/notes/:id", async (req, res) => { try { const updatedNote = await prisma.note.update({ where: { id }, - data: { title, content, updated_at: new Date()}, + data: { title, content, updatedAt: new Date()}, }); res.json(updatedNote); } catch (error) { diff --git a/backend/tests/service/api.spec.ts b/backend/tests/service/api.spec.ts index 0d5fe499..754b11f5 100644 --- a/backend/tests/service/api.spec.ts +++ b/backend/tests/service/api.spec.ts @@ -16,10 +16,10 @@ test("Get the list of Notes", async () => { expect(getNoteResponse.body[getNoteResponse.body.length - 1]).toStrictEqual({ content: "Discussed project timelines and goals.", - created_at: "2024-02-05T23:33:42.252Z", + createdAt: "2024-02-05T23:33:42.252Z", id: 1, title: "Meeting Notes", - updated_at: "2024-02-05T23:33:42.252Z", + updatedAt: "2024-02-05T23:33:42.252Z", }); }); diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5d3ec1e9..2a0ade88 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -82,6 +82,7 @@ function App() { {connectionIssue && (

Warning: API Connection Issue

)} +
)} +
); } diff --git a/frontend/src/components/Note.tsx b/frontend/src/components/Note.tsx index 7ac2209b..49fb4abb 100644 --- a/frontend/src/components/Note.tsx +++ b/frontend/src/components/Note.tsx @@ -19,6 +19,7 @@ const Note: React.FC = ({ note, handleEdit, deleteNote }) => {

{note.title}

{note.content}

+

Updated {new Date(note.updatedAt ?? "").toLocaleDateString()}

diff --git a/frontend/src/types/note.tsx b/frontend/src/types/note.tsx index 640bce29..d22a5d7e 100644 --- a/frontend/src/types/note.tsx +++ b/frontend/src/types/note.tsx @@ -2,6 +2,8 @@ type Note = { id?: number; title: string; content: string; + createdAt?: string; + updatedAt?: string; }; export default Note; \ No newline at end of file