done#504
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
This submission requires changes because the main feature of the task, a CRUD page for managing categories, has not been implemented. The existing application is a good starting point, but the new functionality is missing.
Here's what you need to add:
- Model: Create a new
Categorymodel in thesrc/modelsdirectory and integrate it. - API: Implement the backend CRUD endpoints for categories in
src/createServer.js. - UI: Add a new section to
page.htmlwith a form and table for managing categories, along with the necessary JavaScript logic.
Looking forward to seeing your updated solution!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| const path = require('path'); | ||
| const { Op } = require('sequelize'); | ||
| const { | ||
| models: { User, Expense }, |
There was a problem hiding this comment.
The Category model should be imported here to be used for the new CRUD endpoints.
| // your code goes here | ||
| const app = express(); | ||
| const usersRouter = express.Router(); | ||
| const expensesRouter = express.Router(); |
There was a problem hiding this comment.
A new router for managing categories should be defined here, similar to usersRouter and expensesRouter.
| await expense.destroy(); | ||
|
|
||
| res.status(204).send(); | ||
| }); |
There was a problem hiding this comment.
The implementation for the category CRUD endpoints is missing. You need to add a new section with routes for creating, reading, updating, and deleting categories, similar to how it's done for users and expenses.
| }); | ||
|
|
||
| app.use('/users', usersRouter); | ||
| app.use('/expenses', expensesRouter); |
There was a problem hiding this comment.
After creating and implementing the categoriesRouter, you'll need to register it with the application here, for example: app.use('/categories', categoriesRouter);.
|
|
||
| const { createServer } = require('./createServer'); | ||
| const { sequelize } = require('./db'); | ||
| require('./models/models'); |
There was a problem hiding this comment.
The Category model is a crucial part of this task, but it appears to be missing. To implement CRUD for categories, you should start by defining a new model for them and including it in your application setup.
| <div class="sections"> | ||
| <!-- USERS --> | ||
| <div class="card"> | ||
| <h2>Users</h2> | ||
| <div id="users-error" class="error" style="display: none"></div> | ||
| <form id="add-user-form"> | ||
| <input | ||
| id="user-name" | ||
| type="text" | ||
| placeholder="Name" | ||
| required | ||
| /> | ||
| <button type="submit" class="btn-primary">Add user</button> | ||
| </form> | ||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th>ID</th> | ||
| <th>Name</th> | ||
| <th>Actions</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody id="users-body"></tbody> | ||
| </table> | ||
| </div> | ||
|
|
||
| <!-- EXPENSES --> | ||
| <div class="card"> | ||
| <h2>Expenses</h2> | ||
| <div id="expenses-error" class="error" style="display: none"></div> | ||
| <form id="add-expense-form"> | ||
| <select id="expense-user" required> | ||
| <option value="">User…</option> | ||
| </select> | ||
| <input | ||
| id="expense-title" | ||
| type="text" | ||
| placeholder="Title" | ||
| required | ||
| /> | ||
| <input | ||
| id="expense-amount" | ||
| type="number" | ||
| placeholder="Amount" | ||
| step="0.01" | ||
| required | ||
| /> | ||
| <input | ||
| id="expense-category" | ||
| type="text" | ||
| placeholder="Category (optional)" | ||
| /> | ||
| <input | ||
| id="expense-note" | ||
| type="text" | ||
| placeholder="Note (optional)" | ||
| /> | ||
| <input | ||
| id="expense-date" | ||
| type="datetime-local" | ||
| required | ||
| /> | ||
| <button type="submit" class="btn-primary">Add expense</button> | ||
| </form> | ||
| <table> | ||
| <thead> | ||
| <tr> | ||
| <th>ID</th> | ||
| <th>User</th> | ||
| <th>Title</th> | ||
| <th>Amount</th> | ||
| <th>Category</th> | ||
| <th>Note</th> | ||
| <th>Date</th> | ||
| <th>Actions</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody id="expenses-body"></tbody> | ||
| </table> | ||
| </div> | ||
| </div> |
There was a problem hiding this comment.
The main requirement for this task is to implement a CRUD page for categories. This file is missing the HTML structure and the corresponding JavaScript logic to display, create, update, and delete categories. A new section for managing categories should be added here, similar to the existing 'Users' and 'Expenses' sections.
| @@ -3,6 +3,9 @@ | |||
| const { User } = require('./User.model'); | |||
| const { Expense } = require('./Expense.model'); | |||
There was a problem hiding this comment.
The Category model needs to be imported here. You should first create a Category.model.js file and then require it in this file.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this submission! I am approving your solution as you have successfully implemented the full CRUD functionality for managing categories. The new Category model, the backend API endpoints, and the frontend UI all work together seamlessly. Your code is clean, well-structured, and meets all the requirements for this task. Keep up the fantastic work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.