From b36f9995ab0594ae652a9f60cc3ae8cc07559a97 Mon Sep 17 00:00:00 2001 From: Joe Armani <93854858+JoeArmani@users.noreply.github.com> Date: Wed, 30 Aug 2023 12:52:05 -0400 Subject: [PATCH] add box error handling --- src/pages/shipping.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/shipping.js b/src/pages/shipping.js index 6ee67666..5426a134 100644 --- a/src/pages/shipping.js +++ b/src/pages/shipping.js @@ -332,7 +332,11 @@ export const addNewBox = async () => { if (largestBoxIndexAtLocation == -1 || shouldUpdateBoxModal) { const boxToAdd = await createNewBox(boxList, siteLocationConversion, siteCode, largestBoxId, shouldUpdateBoxModal); - if (!boxToAdd) return false; + if (!boxToAdd) { + showNotifications({ title: 'ERROR ADDING BOX - PLEASE REFRESH YOUR BROWSER', body: 'Error: This box already exists. A member of your team may have recently created this box. Please refresh your browser and try again.' }); + return false; + } + updateShippingStateCreateBox(boxToAdd); return true; } else { @@ -353,7 +357,10 @@ const createNewBox = async (boxList, pageLocationConversion, siteCode, largestBo }; try { - await addBox(boxToAdd); + const addBoxResponse = await addBox(boxToAdd); + if (addBoxResponse.message !== 'Success!') { + return null; + } } catch (e) { console.error('Error adding box', e); return null;