-
-export const deleteCollectionTag = (key: string) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const item = getState().collectionPanel.item;
- const uuid = item ? item.uuid : '';
- try {
- if (item) {
- const data: Partial<CollectionResource> = {
- properties: JSON.parse(JSON.stringify(item.properties))
- };
- delete data.properties[key];
- const updatedCollection = await services.collectionService.update(uuid, data);
- delete item.properties[key];
- dispatch(resourcesActions.SET_RESOURCES([updatedCollection]));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Tag has been successfully deleted.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
- return updatedCollection;
- }
- return;
- } catch (e) {
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.errors[0], hideDuration: 2000, kind: SnackbarKind.ERROR }));
- return;
- }
- };