Skip to content

Commit

Permalink
in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
HaAnh18 committed Jan 10, 2024
1 parent 4933d38 commit 4bb259d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
25 changes: 1 addition & 24 deletions controllers/categoryControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 35,7 @@ exports.createCategory = async(req, res, next) => {
exports.viewCategory = async(req, res, next) => {
try {
const categories = await (Category.find({user: req.userID}))
const a = await Promise.all(categories.map(async(category) => {
// console.log(category.name);
const transactions = await NormalTransaction.find({user: req.userID, category: category})
let amount = 0;
// console.log(transactions);
transactions.map((transaction) => {
// console.log(transaction);
const transactionAmount = transaction.currency === "VND" ? transaction.VND : transaction.USD;
amount = transactionAmount;
})

return {
id: category._id,
name: category.name,
type: category.type,
color: category.color,
icon: category.icon,
budget: category.budget,
amount: amount
}
}))


res.status(200).json(a);
res.status(200).json(categories);


} catch (err) {
Expand Down
1 change: 0 additions & 1 deletion controllers/transactionControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 80,6 @@ exports.createTransaction = async (req, res, next) => {
}
)
}


res.status(200).json({
message: "Transaction created successfully!",
Expand Down

0 comments on commit 4bb259d

Please sign in to comment.