Skip to content

done#504

Open
Vladokvl wants to merge 2 commits intomate-academy:masterfrom
Vladokvl:master
Open

done#504
Vladokvl wants to merge 2 commits intomate-academy:masterfrom
Vladokvl:master

Conversation

@Vladokvl
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Category model in the src/models directory and integrate it.
  • API: Implement the backend CRUD endpoints for categories in src/createServer.js.
  • UI: Add a new section to page.html with 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/createServer.js Outdated
const path = require('path');
const { Op } = require('sequelize');
const {
models: { User, Expense },
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Category model should be imported here to be used for the new CRUD endpoints.

Comment thread src/createServer.js
// your code goes here
const app = express();
const usersRouter = express.Router();
const expensesRouter = express.Router();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A new router for managing categories should be defined here, similar to usersRouter and expensesRouter.

Comment thread src/createServer.js
await expense.destroy();

res.status(204).send();
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/createServer.js
});

app.use('/users', usersRouter);
app.use('/expenses', expensesRouter);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After creating and implementing the categoriesRouter, you'll need to register it with the application here, for example: app.use('/categories', categoriesRouter);.

Comment thread src/index.js

const { createServer } = require('./createServer');
const { sequelize } = require('./db');
require('./models/models');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread page.html
Comment on lines +139 to +219
<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>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/models/models.js
@@ -3,6 +3,9 @@
const { User } = require('./User.model');
const { Expense } = require('./Expense.model');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Category model needs to be imported here. You should first create a Category.model.js file and then require it in this file.

Copy link
Copy Markdown

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants