Skip to content

Commit

Permalink
fix: minot
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharbansal22 committed Apr 9, 2024
1 parent 4715264 commit 53785ff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion controllers/vendorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ const createDiscount = asyncHandler(async (req, res) => {
offer_price
} = req.body

console.log(item_id)

const {vendor_id} = req;

const item = await MenuItem.findOne({ item_id: item_id });
Expand All @@ -303,6 +305,11 @@ const createDiscount = asyncHandler(async (req, res) => {
}

const menuIndex = menu.items.findIndex(item => item.item_id === item_id);

if(menuIndex == -1){
res.status(404).send("Item not found in the menu");
}

menu.items[menuIndex].on_offer = true;
menu.items[menuIndex].offer_price = offer_price;
await menu.save();
Expand All @@ -315,7 +322,9 @@ const createDiscount = asyncHandler(async (req, res) => {
})

const deleteDiscount = asyncHandler(async (req, res) => {
const item_id = req.body
const { item_id } = req.body

const {vendor_id} = req

const item = await MenuItem.findOne({ item_id: item_id });
if(!item){
Expand Down

0 comments on commit 53785ff

Please sign in to comment.