mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
fix(webapp): warehouse and branch reset on invoice form
This commit is contained in:
@@ -7,8 +7,10 @@ export const mapStateToProps = (state, props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const mapDispatchToProps = (dispatch) => ({
|
export const mapDispatchToProps = (dispatch) => ({
|
||||||
openDialog: (name, payload) => dispatch({ type: t.OPEN_DIALOG, name, payload }),
|
openDialog: (name, payload) =>
|
||||||
closeDialog: (name, payload) => dispatch({ type: t.CLOSE_DIALOG, name, payload }),
|
dispatch({ type: t.OPEN_DIALOG, name, payload }),
|
||||||
|
closeDialog: (name, payload) =>
|
||||||
|
dispatch({ type: t.CLOSE_DIALOG, name, payload }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(null, mapDispatchToProps);
|
export default connect(null, mapDispatchToProps);
|
||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
defaultInvoice,
|
defaultInvoice,
|
||||||
transformErrors,
|
transformErrors,
|
||||||
transformValueToRequest,
|
transformValueToRequest,
|
||||||
|
resetFormState,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import { InvoiceNoSyncSettingsToForm } from './components';
|
import { InvoiceNoSyncSettingsToForm } from './components';
|
||||||
|
|
||||||
@@ -119,10 +120,9 @@ function InvoiceForm({
|
|||||||
history.push('/invoices');
|
history.push('/invoices');
|
||||||
}
|
}
|
||||||
if (submitPayload.resetForm) {
|
if (submitPayload.resetForm) {
|
||||||
resetForm();
|
resetFormState({ resetForm, initialValues, values });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle the request error.
|
// Handle the request error.
|
||||||
const onError = ({
|
const onError = ({
|
||||||
response: {
|
response: {
|
||||||
|
|||||||
@@ -14,6 +14,19 @@ import { useInvoiceTotal } from './utils';
|
|||||||
* Invoice form header section.
|
* Invoice form header section.
|
||||||
*/
|
*/
|
||||||
function InvoiceFormHeader() {
|
function InvoiceFormHeader() {
|
||||||
|
return (
|
||||||
|
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
||||||
|
<InvoiceFormHeaderFields />
|
||||||
|
<InvoiceFormBigTotal />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Big total of invoice form header.
|
||||||
|
* @returns {React.ReactNode}
|
||||||
|
*/
|
||||||
|
function InvoiceFormBigTotal() {
|
||||||
const {
|
const {
|
||||||
values: { currency_code },
|
values: { currency_code },
|
||||||
} = useFormikContext();
|
} = useFormikContext();
|
||||||
@@ -22,14 +35,11 @@ function InvoiceFormHeader() {
|
|||||||
const totalDueAmount = useInvoiceTotal();
|
const totalDueAmount = useInvoiceTotal();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
|
|
||||||
<InvoiceFormHeaderFields />
|
|
||||||
<PageFormBigNumber
|
<PageFormBigNumber
|
||||||
label={intl.get('due_amount')}
|
label={intl.get('due_amount')}
|
||||||
amount={totalDueAmount}
|
amount={totalDueAmount}
|
||||||
currencyCode={currency_code}
|
currencyCode={currency_code}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default InvoiceFormHeader;
|
export default InvoiceFormHeader;
|
||||||
|
|||||||
@@ -269,3 +269,14 @@ export const useInvoiceIsForeignCustomer = () => {
|
|||||||
);
|
);
|
||||||
return isForeignCustomer;
|
return isForeignCustomer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const resetFormState = ({ initialValues, values, resetForm }) => {
|
||||||
|
resetForm({
|
||||||
|
values: {
|
||||||
|
// Reset the all values except the warehouse and brand id.
|
||||||
|
...initialValues,
|
||||||
|
warehouse_id: values.warehouse_id,
|
||||||
|
brand_id: values.brand_id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -123,18 +123,6 @@ export const fullAmountPaymentEntries = (entries) => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Syncs payment receive number settings with form.
|
|
||||||
*/
|
|
||||||
export const useObservePaymentNoSettings = (prefix, nextNumber) => {
|
|
||||||
const { setFieldValue } = useFormikContext();
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
const invoiceNo = transactionNumber(prefix, nextNumber);
|
|
||||||
setFieldValue('payment_receive_no', invoiceNo);
|
|
||||||
}, [setFieldValue, prefix, nextNumber]);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detarmines the customers fast-field should update.
|
* Detarmines the customers fast-field should update.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user