Skip to content

Commit

Permalink
[finishes #187584937] buyer track order status
Browse files Browse the repository at this point in the history
  • Loading branch information
solangeihirwe03 committed Jul 9, 2024
1 parent 30b1dfd commit e2f91cf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/modules/cart/controller/cartControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,35 @@ const buyerCreateUpdateCart = async (req: ExtendRequest, res: Response) => {
});
}
};
const buyerGetOrderStatus = async(req:ExtendRequest, res:Response)=>{
try{
const status= await cartRepositories.getOrderStatus(req.params.id)
return res.status(200).json({
message: "Order Status found successfully",
data: status
})

}catch(error){
return res.status(httpStatus.INTERNAL_SERVER_ERROR).json({
status: httpStatus.INTERNAL_SERVER_ERROR,
error: error.message
})
}
}


const adminUpdateOrderStatus = async(req:ExtendRequest, res:Response)=>{
const orderId = req.params.id;
const updatedStatus: any = {
status:req.body.status
};

const updateStatus = await cartRepositories.updateOrderStatus(orderId, updatedStatus);
return res.status(httpStatus.OK).json({
status: "Status updated successfully!",
data:updateStatus
})
}

const buyerClearCartProduct = async (req: ExtendRequest, res: Response) => {
try {
Expand Down Expand Up @@ -362,4 +391,6 @@ export {
getProductDetails,
paymentSuccess,
paymentCanceled,
buyerGetOrderStatus,
adminUpdateOrderStatus
};
2 changes: 2 additions & 0 deletions src/routes/cartRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ router.get(
isCartIdExist,
cartControllers.buyerGetCart
);
router.get("/user-get-order-status/:id",userAuthorization(["buyer"]), cartControllers.buyerGetOrderStatus )
router.put("/admin-update-order-status/:id", userAuthorization(["admin"]), cartControllers.adminUpdateOrderStatus)

router.delete(
"/buyer-clear-cart-product/:cartId/:productId",
Expand Down

0 comments on commit e2f91cf

Please sign in to comment.