Skip to content

Commit

Permalink
LPS-121645 Add catch in deleteMenuItem request
Browse files Browse the repository at this point in the history
  • Loading branch information
veroglez authored and brianchandotcom committed Oct 5, 2020
1 parent d015afe commit 63a87d8
Showing 1 changed file with 14 additions and 5 deletions.
Expand Up @@ -18,7 +18,7 @@ import {ClayCheckbox} from '@clayui/form';
import ClayIcon from '@clayui/icon';
import ClayLayout from '@clayui/layout';
import classNames from 'classnames';
import {fetch, objectToFormData} from 'frontend-js-web';
import {fetch, objectToFormData, openToast} from 'frontend-js-web';
import PropTypes from 'prop-types';
import React from 'react';
import {useDrag} from 'react-dnd';
Expand Down Expand Up @@ -49,11 +49,20 @@ export const MenuItem = ({item}) => {
[`${portletNamespace}siteNavigationMenuItemId`]: siteNavigationMenuItemId,
}),
method: 'POST',
}).then(() => {
const newItems = deleteItem(items, siteNavigationMenuItemId);
})
.then(() => {
const newItems = deleteItem(items, siteNavigationMenuItemId);

setItems(newItems);
});
setItems(newItems);
})
.catch(() => {
openToast({
message: Liferay.Language.get(
'an-unexpected-error-occurred'
),
type: 'danger',
});
});
};

const [, handlerRef] = useDrag({
Expand Down

0 comments on commit 63a87d8

Please sign in to comment.