Skip to content

Commit

Permalink
only show pending
Browse files Browse the repository at this point in the history
  • Loading branch information
yamiltauil committed Jan 3, 2025
1 parent 72bad48 commit 1bf9e5f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/application/orders/orderControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ class OrderController {
const page: number | undefined = parseInt(req.query.page as string) || 1;
try {
const { data, totalItems, totalPages } = await orderService.findAll(page);
res.status(200).json({ data, totalItems, totalPages });
// exclude from data all orders that contain Delivered status
const filteredData = data.filter((order) => order.status !== 'Delivered');
const moreFiltedData = filteredData.filter((order) => order.status !== 'Cancelled');
const ultraFilteredData = moreFiltedData.filter((order) => order.status !== 'Shipped');
res.status(200).json({ data: ultraFilteredData, totalItems, totalPages });
} catch (error) {
console.log(error);
next(error);
Expand Down

0 comments on commit 1bf9e5f

Please sign in to comment.