mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
feat(warehouseTransfer): handle error.
This commit is contained in:
@@ -25,6 +25,7 @@ import { compose, orderingLinesIndexes, transactionNumber } from 'utils';
|
|||||||
import {
|
import {
|
||||||
defaultWarehouseTransfer,
|
defaultWarehouseTransfer,
|
||||||
transformValueToRequest,
|
transformValueToRequest,
|
||||||
|
transformErrors,
|
||||||
transformToEditForm,
|
transformToEditForm,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
@@ -97,6 +98,9 @@ function WarehouseTransferForm({
|
|||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
|
if (errors) {
|
||||||
|
transformErrors(errors, { setErrors });
|
||||||
|
}
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
|
||||||
import clsx from 'classnames';
|
|
||||||
import { useFormikContext } from 'formik';
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
|
import { AppToaster } from 'components';
|
||||||
import { omit } from 'lodash';
|
import { omit } from 'lodash';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -105,3 +106,19 @@ export function transformValueToRequest(values) {
|
|||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transformes the response errors types.
|
||||||
|
*/
|
||||||
|
export const transformErrors = (errors, { setErrors }) => {
|
||||||
|
if (
|
||||||
|
errors.some(({ type }) => type === 'WAREHOUSES_TRANSFER_SHOULD_NOT_BE_SAME')
|
||||||
|
) {
|
||||||
|
AppToaster.show({
|
||||||
|
message: intl.get(
|
||||||
|
'warehouse_transfer.error.could_not_transfer_item_from_source_to_destination',
|
||||||
|
),
|
||||||
|
intent: Intent.DANGER,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user