Skip to content

Commit

Permalink
Merge pull request #576 from episphere/add-box-error-handling
Browse files Browse the repository at this point in the history
Add box error handling
  • Loading branch information
JoeArmani authored Aug 30, 2023
2 parents 3ac6949 + b36f999 commit 35e06bd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pages/shipping.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down

0 comments on commit 35e06bd

Please sign in to comment.