feat: handle errors.

This commit is contained in:
elforjani13
2021-11-26 19:46:48 +02:00
parent 97c421e2f1
commit 64bf223458
2 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
import intl from 'react-intl-universal';
import { Intent } from '@blueprintjs/core';
import { AppToaster } from 'components';
// handle delete errors.
export const transformErrors = (errors) => {
if (
errors.find((error) => error.type === 'CANNOT_AUTHORIZED_USER_MUTATE_ROLE')
) {
AppToaster.show({
message: intl.get('roles.error.you_cannot_change_your_own_role'),
intent: Intent.DANGER,
});
}
};

View File

@@ -0,0 +1,13 @@
import intl from 'react-intl-universal';
import { Intent } from '@blueprintjs/core';
import { AppToaster } from 'components';
// handle delete errors.
export const handleDeleteErrors = (errors) => {
if (errors.find((error) => error.type === 'ROLE_PREFINED')) {
AppToaster.show({
message: intl.get('roles.error.role_is_predefined'),
intent: Intent.DANGER,
});
}
};