refactor: Inovices alerts.

This commit is contained in:
elforjani3
2021-01-27 14:54:08 +02:00
parent 0e95c5cce1
commit 963f68a640
5 changed files with 221 additions and 109 deletions

View File

@@ -2,6 +2,8 @@ import React from 'react';
import { Intent, Tag, ProgressBar } from '@blueprintjs/core';
import { Choose, If, Icon } from 'components';
import { FormattedMessage as T, useIntl } from 'react-intl';
import { AppToaster } from 'components';
import { formatMessage } from 'services/intl';
const calculateStatus = (paymentAmount, balanceAmount) =>
paymentAmount / balanceAmount;
@@ -60,3 +62,18 @@ export const statusAccessor = (row) => {
</div>
);
};
export const handleDeleteErrors = (errors) => {
if (
errors.find(
(error) => error.type === 'INVOICE_HAS_ASSOCIATED_PAYMENT_ENTRIES',
)
) {
AppToaster.show({
message: formatMessage({
id: 'the_invoice_cannot_be_deleted',
}),
intent: Intent.DANGER,
});
}
};