mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix: estimate entries & floatingAction.
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { If, Icon } from 'components';
|
import { If, Icon } from 'components';
|
||||||
import { useEstimateFormContext } from './EstimateFormProvider';
|
import { useEstimateFormContext } from './EstimateFormProvider';
|
||||||
@@ -20,6 +21,7 @@ import { useEstimateFormContext } from './EstimateFormProvider';
|
|||||||
* Estimate floating actions bar.
|
* Estimate floating actions bar.
|
||||||
*/
|
*/
|
||||||
export default function EstimateFloatingActions() {
|
export default function EstimateFloatingActions() {
|
||||||
|
const history = useHistory();
|
||||||
const { resetForm, submitForm, isSubmitting } = useFormikContext();
|
const { resetForm, submitForm, isSubmitting } = useFormikContext();
|
||||||
|
|
||||||
// Estimate form context.
|
// Estimate form context.
|
||||||
@@ -62,6 +64,7 @@ export default function EstimateFloatingActions() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleCancelBtnClick = (event) => {
|
const handleCancelBtnClick = (event) => {
|
||||||
|
history.goBack();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ import withSettings from 'containers/Settings/withSettings';
|
|||||||
|
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
import { ERROR } from 'common/errors';
|
import { ERROR } from 'common/errors';
|
||||||
import {
|
import { compose, orderingLinesIndexes } from 'utils';
|
||||||
compose,
|
|
||||||
orderingLinesIndexes,
|
|
||||||
} from 'utils';
|
|
||||||
import { useEstimateFormContext } from './EstimateFormProvider';
|
import { useEstimateFormContext } from './EstimateFormProvider';
|
||||||
import { transformToEditForm, defaultEstimate } from './utils';
|
import { transformToEditForm, defaultEstimate } from './utils';
|
||||||
|
|
||||||
@@ -55,7 +52,7 @@ function EstimateForm({
|
|||||||
() => ({
|
() => ({
|
||||||
...(!isEmpty(estimate)
|
...(!isEmpty(estimate)
|
||||||
? {
|
? {
|
||||||
...transformToEditForm(estimate)
|
...transformToEditForm(estimate),
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
...defaultEstimate,
|
...defaultEstimate,
|
||||||
@@ -126,7 +123,11 @@ function EstimateForm({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onError = (errors) => {
|
const onError = ({
|
||||||
|
response: {
|
||||||
|
data: { errors },
|
||||||
|
},
|
||||||
|
}) => {
|
||||||
if (errors) {
|
if (errors) {
|
||||||
handleErrors(errors, { setErrors });
|
handleErrors(errors, { setErrors });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export const transformToEditForm = (estimate) => ({
|
|||||||
...transformToForm(estimate, defaultEstimateEntry),
|
...transformToForm(estimate, defaultEstimateEntry),
|
||||||
})),
|
})),
|
||||||
...repeatValue(
|
...repeatValue(
|
||||||
defaultEstimate,
|
defaultEstimateEntry,
|
||||||
Math.max(MIN_LINES_NUMBER - estimate.entries.length, 0),
|
Math.max(MIN_LINES_NUMBER - estimate.entries.length, 0),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -136,8 +136,10 @@ function ReceiptForm({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle the request error.
|
// Handle the request error.
|
||||||
const onError = (errors) => {
|
const onError = ({response:{data:{errors}}}) => {
|
||||||
handleErrors(errors, { setErrors });
|
if(errors){
|
||||||
|
handleErrors(errors, { setErrors });
|
||||||
|
}
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user