diff --git a/client/MenuItems/menuItemsForm.js b/client/MenuItems/menuItemsForm.js index d5c102c..4aeb09b 100644 --- a/client/MenuItems/menuItemsForm.js +++ b/client/MenuItems/menuItemsForm.js @@ -102,7 +102,7 @@ Template.menuItemsForm.events({ } else { // now add this item to the menu const addToMenu = async() => { - let result2 = await Meteor.callAsync('addto.Menu', menuId, menuItem, result, dateSrv); + let result2 = await Meteor.callAsync('addto.Menu', menuId, menuItem, addedItem, dateSrv); if (!result2) { console.log(" ERROR adding menuitem to menu: " + error); } else { @@ -123,15 +123,17 @@ Template.menuItemsForm.events({ if (menuItem == null || menuItem == "") { Session.set("menuItemErr", true); } else { - Meteor.call('addto.Menu', menuId, menuItem, menuItemId, dateSrv, isLinked, function(error, nresult) { - if (error) { + const addToMenu = async() => { + let result = await Meteor.callAsync('addto.Menu', menuId, menuItem, menuItemId, dateSrv, isLinked); + if (!result) { console.log(" ERROR adding menuitem to menu: " + error); } else { // console.log("Added item to menu - no problem."); $("#menuItemInp").val(""); $("#dateServed").val(""); } - }); + } + addToMenu(); } } }, diff --git a/imports/api/menu.js b/imports/api/menu.js index 8221a0f..7ea3be2 100644 --- a/imports/api/menu.js +++ b/imports/api/menu.js @@ -128,7 +128,7 @@ Meteor.methods({ throw new Meteor.Error('You are not allowed to add items to menus. Make sure you are logged in with valid user credentials.'); } - serveDateActual = new Date(dateSrv); + let serveDateActual = new Date(dateSrv); return Menus.updateAsync({ _id: menuId }, { $addToSet: {