mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
BIG-354: warehouse transfer validate.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Formik, Form } from 'formik';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { isEmpty, sumBy } from 'lodash';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { CLASSES } from 'common/classes';
|
||||
@@ -20,7 +20,7 @@ import WarehouseTransferFormDialog from './WarehouseTransferFormDialog';
|
||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||
import withSettings from 'containers/Settings/withSettings';
|
||||
|
||||
import { AppToaster, } from 'components';
|
||||
import { AppToaster } from 'components';
|
||||
import { useWarehouseTransferFormContext } from './WarehouseTransferFormProvider';
|
||||
import { compose, orderingLinesIndexes, transactionNumber } from 'utils';
|
||||
import { WarehouseTransferObserveItemsCost } from './components';
|
||||
@@ -72,6 +72,18 @@ function WarehouseTransferForm({
|
||||
// Handles form submit.
|
||||
const handleSubmit = (values, { setSubmitting, setErrors, resetForm }) => {
|
||||
setSubmitting(true);
|
||||
const totalQuantity = sumBy(values.entries, 'quantity');
|
||||
|
||||
if (totalQuantity <= 0) {
|
||||
AppToaster.show({
|
||||
message: intl.get(
|
||||
'warehouse_transfer.quantity_cannot_be_zero_or_empty',
|
||||
),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Transformes the values of the form to request.
|
||||
const form = {
|
||||
...transformValueToRequest(values),
|
||||
@@ -119,7 +131,7 @@ function WarehouseTransferForm({
|
||||
.catch(onError);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
@@ -141,7 +153,7 @@ function WarehouseTransferForm({
|
||||
<WarehouseTransferFormFooter />
|
||||
<WarehouseTransferFormDialog />
|
||||
<WarehouseTransferFloatingActions />
|
||||
<WarehouseTransferObserveItemsCost />
|
||||
<WarehouseTransferObserveItemsCost />
|
||||
</Form>
|
||||
</Formik>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user