Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated at #24

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
36 changes: 18 additions & 18 deletions backend/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
];

Expand Down
4 changes: 2 additions & 2 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/service/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
});

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function App() {
{connectionIssue && (
<h3 className="connection-warning">Warning: API Connection Issue</h3>
)}
<div className="app-content">
<NoteForm
onCancel={handleCancel}
selectedNote={selectedNote}
Expand All @@ -97,6 +98,7 @@ function App() {
handleEdit={handleEdit}
/>
)}
</div>
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Note: React.FC<NoteProps> = ({ note, handleEdit, deleteNote }) => {
<div data-testid="note" className="note-item" onClick={handleEdit}>
<h3 data-testid="note-title">{note.title}</h3>
<p className="note-content" data-testid="note-content">{note.content}</p>
<p className="note-updated" data-testid="note-updated">Updated {new Date(note.updatedAt ?? "").toLocaleDateString()}</p>
<div className="notes-header">
<button data-testid='note-delete-button' onClick={handleDeleteMouseDown}>X</button>
</div>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/types/note.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ type Note = {
id?: number;
title: string;
content: string;
createdAt?: string;
updatedAt?: string;
};

export default Note;
Loading