mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
fix: defaultEstimate
This commit is contained in:
@@ -43,8 +43,8 @@ const MIN_LINES_NUMBER = 4;
|
|||||||
const defaultEstimate = {
|
const defaultEstimate = {
|
||||||
index: 0,
|
index: 0,
|
||||||
item_id: '',
|
item_id: '',
|
||||||
rate: 0,
|
rate: '',
|
||||||
discount: '',
|
discount: 0,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
description: '',
|
description: '',
|
||||||
};
|
};
|
||||||
@@ -164,6 +164,8 @@ const EstimateForm = ({
|
|||||||
values,
|
values,
|
||||||
{ setSubmitting, setErrors, resetForm },
|
{ setSubmitting, setErrors, resetForm },
|
||||||
) => {
|
) => {
|
||||||
|
setSubmitting(true);
|
||||||
|
|
||||||
const entries = values.entries.filter(
|
const entries = values.entries.filter(
|
||||||
(item) => item.item_id && item.quantity,
|
(item) => item.item_id && item.quantity,
|
||||||
);
|
);
|
||||||
@@ -211,7 +213,9 @@ const EstimateForm = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onError = (errors) => {
|
const onError = (errors) => {
|
||||||
handleErrors(errors, { setErrors });
|
if (errors) {
|
||||||
|
handleErrors(errors, { setErrors });
|
||||||
|
}
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -246,11 +250,13 @@ const EstimateForm = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(
|
<div
|
||||||
CLASSES.PAGE_FORM,
|
className={classNames(
|
||||||
CLASSES.PAGE_FORM_STRIP_STYLE,
|
CLASSES.PAGE_FORM,
|
||||||
CLASSES.PAGE_FORM_ESTIMATE,
|
CLASSES.PAGE_FORM_STRIP_STYLE,
|
||||||
)}>
|
CLASSES.PAGE_FORM_ESTIMATE,
|
||||||
|
)}
|
||||||
|
>
|
||||||
<Formik
|
<Formik
|
||||||
validationSchema={
|
validationSchema={
|
||||||
isNewMode ? CreateEstimateFormSchema : EditEstimateFormSchema
|
isNewMode ? CreateEstimateFormSchema : EditEstimateFormSchema
|
||||||
@@ -258,13 +264,13 @@ const EstimateForm = ({
|
|||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
>
|
>
|
||||||
{({ isSubmitting ,values }) => (
|
{({ isSubmitting, values }) => (
|
||||||
<Form>
|
<Form>
|
||||||
<EstimateFormHeader
|
<EstimateFormHeader
|
||||||
onEstimateNumberChanged={handleEstimateNumberChange}
|
onEstimateNumberChanged={handleEstimateNumberChange}
|
||||||
/>
|
/>
|
||||||
<EstimateNumberWatcher estimateNumber={estimateNumber} />
|
<EstimateNumberWatcher estimateNumber={estimateNumber} />
|
||||||
<EstimateFormBody />
|
<EstimateFormBody defaultEstimate={defaultEstimate} />
|
||||||
<EstimateFormFooter />
|
<EstimateFormFooter />
|
||||||
<EstimateFloatingActions
|
<EstimateFloatingActions
|
||||||
isSubmitting={isSubmitting}
|
isSubmitting={isSubmitting}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const Schema = Yup.object().shape({
|
|||||||
.min(1)
|
.min(1)
|
||||||
.max(DATATYPES_LENGTH.TEXT)
|
.max(DATATYPES_LENGTH.TEXT)
|
||||||
.label(formatMessage({ id: 'note' })),
|
.label(formatMessage({ id: 'note' })),
|
||||||
delivered: Yup.boolean().required(),
|
delivered: Yup.boolean(),
|
||||||
entries: Yup.array().of(
|
entries: Yup.array().of(
|
||||||
Yup.object().shape({
|
Yup.object().shape({
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
@@ -44,7 +44,7 @@ const Schema = Yup.object().shape({
|
|||||||
is: (quantity, rate) => !isBlank(quantity) && !isBlank(rate),
|
is: (quantity, rate) => !isBlank(quantity) && !isBlank(rate),
|
||||||
then: Yup.number().required(),
|
then: Yup.number().required(),
|
||||||
}),
|
}),
|
||||||
discount: Yup.number().nullable().min(0).max(DATATYPES_LENGTH.INT_10),
|
discount: Yup.number().nullable().min(0).max(100),
|
||||||
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
description: Yup.string().nullable().max(DATATYPES_LENGTH.TEXT),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import classNames from 'classnames';
|
|||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import EditableItemsEntriesTable from 'containers/Entries/EditableItemsEntriesTable';
|
import EditableItemsEntriesTable from 'containers/Entries/EditableItemsEntriesTable';
|
||||||
|
|
||||||
export default function EstimateFormBody() {
|
export default function EstimateFormBody({ defaultEstimate }) {
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||||
<EditableItemsEntriesTable filterSellableItems={true} />
|
<EditableItemsEntriesTable
|
||||||
|
defaultEntry={defaultEstimate}
|
||||||
|
filterSellableItems={true}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user