mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: inject default message value to sales forms
This commit is contained in:
@@ -4,7 +4,7 @@ import intl from 'react-intl-universal';
|
||||
import classNames from 'classnames';
|
||||
import { Formik, Form } from 'formik';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { sumBy, isEmpty } from 'lodash';
|
||||
import { sumBy, isEmpty, defaultTo } from 'lodash';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { CLASSES } from '@/constants/classes';
|
||||
|
||||
@@ -43,6 +43,8 @@ function EstimateForm({
|
||||
estimateNextNumber,
|
||||
estimateNumberPrefix,
|
||||
estimateAutoIncrementMode,
|
||||
estimateCustomerNotes,
|
||||
estimateTermsConditions,
|
||||
|
||||
// #withCurrentOrganization
|
||||
organization: { base_currency },
|
||||
@@ -60,25 +62,23 @@ function EstimateForm({
|
||||
estimateNumberPrefix,
|
||||
estimateNextNumber,
|
||||
);
|
||||
|
||||
// Initial values in create and edit mode.
|
||||
const initialValues = useMemo(
|
||||
() => ({
|
||||
...(!isEmpty(estimate)
|
||||
? { ...transformToEditForm(estimate) }
|
||||
: {
|
||||
...defaultEstimate,
|
||||
// If the auto-increment mode is enabled, take the next estimate
|
||||
// number from the settings.
|
||||
...(estimateAutoIncrementMode && {
|
||||
estimate_number: estimateNumber,
|
||||
}),
|
||||
entries: orderingLinesIndexes(defaultEstimate.entries),
|
||||
currency_code: base_currency,
|
||||
const initialValues = {
|
||||
...(!isEmpty(estimate)
|
||||
? { ...transformToEditForm(estimate) }
|
||||
: {
|
||||
...defaultEstimate,
|
||||
// If the auto-increment mode is enabled, take the next estimate
|
||||
// number from the settings.
|
||||
...(estimateAutoIncrementMode && {
|
||||
estimate_number: estimateNumber,
|
||||
}),
|
||||
}),
|
||||
[estimate, estimateNumber, estimateAutoIncrementMode, base_currency],
|
||||
);
|
||||
entries: orderingLinesIndexes(defaultEstimate.entries),
|
||||
currency_code: base_currency,
|
||||
terms_conditions: defaultTo(estimateTermsConditions, ''),
|
||||
note: defaultTo(estimateCustomerNotes, ''),
|
||||
}),
|
||||
};
|
||||
|
||||
// Handles form submit.
|
||||
const handleFormSubmit = (
|
||||
@@ -181,6 +181,8 @@ export default compose(
|
||||
estimateNextNumber: estimatesSettings?.nextNumber,
|
||||
estimateNumberPrefix: estimatesSettings?.numberPrefix,
|
||||
estimateAutoIncrementMode: estimatesSettings?.autoIncrement,
|
||||
estimateCustomerNotes: estimatesSettings?.customerNotes,
|
||||
estimateTermsConditions: estimatesSettings?.termsConditions,
|
||||
})),
|
||||
withCurrentOrganization(),
|
||||
)(EstimateForm);
|
||||
|
||||
Reference in New Issue
Block a user