mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
fix(webapp): customer/vendor select should update deps
This commit is contained in:
@@ -140,7 +140,8 @@ function ExpenseFormCustomerSelect() {
|
|||||||
labelInfo={<Hint />}
|
labelInfo={<Hint />}
|
||||||
inline={true}
|
inline={true}
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
customers={customers}
|
fastField={true}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
shouldUpdate={customersFieldShouldUpdate}
|
shouldUpdate={customersFieldShouldUpdate}
|
||||||
>
|
>
|
||||||
<CustomersSelect
|
<CustomersSelect
|
||||||
@@ -149,6 +150,9 @@ function ExpenseFormCustomerSelect() {
|
|||||||
placeholder={<T id={'select_customer_account'} />}
|
placeholder={<T id={'select_customer_account'} />}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
|
fastField={true}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
|
shouldUpdate={customersFieldShouldUpdate}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export const transformToEditForm = (
|
|||||||
*/
|
*/
|
||||||
export const customersFieldShouldUpdate = (newProps, oldProps) => {
|
export const customersFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.customers !== oldProps.customers ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items ||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormGroup, InputGroup, Classes, Position } from '@blueprintjs/core';
|
|
||||||
import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
import { FastField, ErrorMessage, useFormikContext } from 'formik';
|
||||||
|
import { FormGroup, InputGroup, Classes, Position } from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
|
|
||||||
import { FeatureCan, FormattedMessage as T } from '@/components';
|
import { FeatureCan, FormattedMessage as T } from '@/components';
|
||||||
import { CLASSES } from '@/constants/classes';
|
import { CLASSES } from '@/constants/classes';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
FieldRequiredHint,
|
FieldRequiredHint,
|
||||||
@@ -168,9 +168,9 @@ function BillFormVendorField() {
|
|||||||
label={<T id={'vendor_name'} />}
|
label={<T id={'vendor_name'} />}
|
||||||
inline={true}
|
inline={true}
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
vendors={vendors}
|
|
||||||
fastField={true}
|
fastField={true}
|
||||||
shouldUpdate={vendorsFieldShouldUpdate}
|
shouldUpdate={vendorsFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: vendors }}
|
||||||
>
|
>
|
||||||
<VendorsSelect
|
<VendorsSelect
|
||||||
name={'vendor_id'}
|
name={'vendor_id'}
|
||||||
@@ -181,6 +181,9 @@ function BillFormVendorField() {
|
|||||||
setFieldValue('currency_code', contact?.currency_code);
|
setFieldValue('currency_code', contact?.currency_code);
|
||||||
}}
|
}}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
|
fastField={true}
|
||||||
|
shouldUpdate={vendorsFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: vendors }}
|
||||||
/>
|
/>
|
||||||
{values.vendor_id && (
|
{values.vendor_id && (
|
||||||
<VendorButtonLink vendorId={values.vendor_id}>
|
<VendorButtonLink vendorId={values.vendor_id}>
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ import {
|
|||||||
ensureEntriesHaveEmptyLine,
|
ensureEntriesHaveEmptyLine,
|
||||||
} from '@/containers/Entries/utils';
|
} from '@/containers/Entries/utils';
|
||||||
import { useCurrentOrganization } from '@/hooks/state';
|
import { useCurrentOrganization } from '@/hooks/state';
|
||||||
import { isLandedCostDisabled, getEntriesTotal } from '@/containers/Entries/utils';
|
import {
|
||||||
|
isLandedCostDisabled,
|
||||||
|
getEntriesTotal,
|
||||||
|
} from '@/containers/Entries/utils';
|
||||||
import { useBillFormContext } from './BillFormProvider';
|
import { useBillFormContext } from './BillFormProvider';
|
||||||
|
|
||||||
export const MIN_LINES_NUMBER = 1;
|
export const MIN_LINES_NUMBER = 1;
|
||||||
@@ -153,7 +156,7 @@ export const handleDeleteErrors = (errors) => {
|
|||||||
*/
|
*/
|
||||||
export const vendorsFieldShouldUpdate = (newProps, oldProps) => {
|
export const vendorsFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.vendors !== oldProps.vendors ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items ||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -185,9 +185,10 @@ function VendorCreditFormVendorSelect() {
|
|||||||
name={'vendor_id'}
|
name={'vendor_id'}
|
||||||
label={<T id={'vendor_name'} />}
|
label={<T id={'vendor_name'} />}
|
||||||
inline={true}
|
inline={true}
|
||||||
vendors={vendors}
|
|
||||||
shouldUpdate={vendorsFieldShouldUpdate}
|
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
|
fastField={true}
|
||||||
|
shouldUpdate={vendorsFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: vendors }}
|
||||||
>
|
>
|
||||||
<VendorsSelect
|
<VendorsSelect
|
||||||
name={'vendor_id'}
|
name={'vendor_id'}
|
||||||
@@ -199,6 +200,9 @@ function VendorCreditFormVendorSelect() {
|
|||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
|
fastField={true}
|
||||||
|
shouldUpdate={vendorsFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: vendors }}
|
||||||
/>
|
/>
|
||||||
{values.vendor_id && (
|
{values.vendor_id && (
|
||||||
<VendorButtonLink vendorId={values.vendor_id}>
|
<VendorButtonLink vendorId={values.vendor_id}>
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ export const transformFormValuesToRequest = (values) => {
|
|||||||
*/
|
*/
|
||||||
export const vendorsFieldShouldUpdate = (newProps, oldProps) => {
|
export const vendorsFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.vendors !== oldProps.vendors ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items ||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -238,10 +238,11 @@ function PaymentFormVendorSelect() {
|
|||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'vendor_id'}
|
name={'vendor_id'}
|
||||||
label={<T id={'vendor_name'} />}
|
label={<T id={'vendor_name'} />}
|
||||||
inline={true}
|
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
vendors={vendors}
|
inline={true}
|
||||||
|
fastField={true}
|
||||||
shouldUpdate={vendorsFieldShouldUpdate}
|
shouldUpdate={vendorsFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: vendors }}
|
||||||
>
|
>
|
||||||
<VendorsSelect
|
<VendorsSelect
|
||||||
name={'vendor_id'}
|
name={'vendor_id'}
|
||||||
@@ -254,6 +255,9 @@ function PaymentFormVendorSelect() {
|
|||||||
}}
|
}}
|
||||||
disabled={!isNewMode}
|
disabled={!isNewMode}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
|
fastField={true}
|
||||||
|
shouldUpdate={vendorsFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: vendors }}
|
||||||
/>
|
/>
|
||||||
{values.vendor_id && (
|
{values.vendor_id && (
|
||||||
<VendorButtonLink vendorId={values.vendor_id}>
|
<VendorButtonLink vendorId={values.vendor_id}>
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export const transformToNewPageEntries = (entries) => {
|
|||||||
*/
|
*/
|
||||||
export const vendorsFieldShouldUpdate = (newProps, oldProps) => {
|
export const vendorsFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.vendors !== oldProps.vendors ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items ||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -191,11 +191,11 @@ function CreditNoteCustomersSelect() {
|
|||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
label={<T id={'customer_name'} />}
|
label={<T id={'customer_name'} />}
|
||||||
customers={customers}
|
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
inline={true}
|
inline={true}
|
||||||
fastField={true}
|
fastField={true}
|
||||||
shouldUpdate={customerNameFieldShouldUpdate}
|
shouldUpdate={customerNameFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
>
|
>
|
||||||
<CustomersSelect
|
<CustomersSelect
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
@@ -207,6 +207,9 @@ function CreditNoteCustomersSelect() {
|
|||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
|
fastField={true}
|
||||||
|
shouldUpdate={customerNameFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
/>
|
/>
|
||||||
{values.customer_id && (
|
{values.customer_id && (
|
||||||
<CustomerButtonLink customerId={values.customer_id}>
|
<CustomerButtonLink customerId={values.customer_id}>
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ export const transformFormValuesToRequest = (values) => {
|
|||||||
*/
|
*/
|
||||||
export const customerNameFieldShouldUpdate = (newProps, oldProps) => {
|
export const customerNameFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.customers !== oldProps.customers ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items ||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -244,9 +244,9 @@ function EstimateFormCustomerSelect() {
|
|||||||
inline={true}
|
inline={true}
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
customers={customers}
|
|
||||||
shouldUpdate={customersFieldShouldUpdate}
|
|
||||||
fastField={true}
|
fastField={true}
|
||||||
|
shouldUpdate={customersFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
>
|
>
|
||||||
<CustomersSelect
|
<CustomersSelect
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
@@ -259,6 +259,8 @@ function EstimateFormCustomerSelect() {
|
|||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
fastField={true}
|
fastField={true}
|
||||||
|
shouldUpdate={customersFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
/>
|
/>
|
||||||
{values.customer_id && (
|
{values.customer_id && (
|
||||||
<CustomerButtonLink customerId={values.customer_id}>
|
<CustomerButtonLink customerId={values.customer_id}>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export const transformToEditForm = (estimate) => {
|
|||||||
*/
|
*/
|
||||||
export const customersFieldShouldUpdate = (newProps, oldProps) => {
|
export const customersFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.customers !== oldProps.customers ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items ||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -259,12 +259,12 @@ function InvoiceFormCustomerSelect() {
|
|||||||
return (
|
return (
|
||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
customers={customers}
|
|
||||||
shouldUpdate={customerNameFieldShouldUpdate}
|
|
||||||
label={<T id={'customer_name'} />}
|
label={<T id={'customer_name'} />}
|
||||||
inline={true}
|
inline={true}
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
fastField={true}
|
fastField={true}
|
||||||
|
shouldUpdate={customerNameFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
>
|
>
|
||||||
<CustomersSelect
|
<CustomersSelect
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
@@ -276,6 +276,8 @@ function InvoiceFormCustomerSelect() {
|
|||||||
}}
|
}}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
fastField={true}
|
fastField={true}
|
||||||
|
shouldUpdate={customerNameFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
/>
|
/>
|
||||||
{values.customer_id && (
|
{values.customer_id && (
|
||||||
<CustomerButtonLink customerId={values.customer_id}>
|
<CustomerButtonLink customerId={values.customer_id}>
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export const transformErrors = (errors, { setErrors }) => {
|
|||||||
*/
|
*/
|
||||||
export const customerNameFieldShouldUpdate = (newProps, oldProps) => {
|
export const customerNameFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.customers !== oldProps.customers ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -341,9 +341,9 @@ function PaymentReceiveCustomerSelect() {
|
|||||||
inline={true}
|
inline={true}
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
customers={customers}
|
|
||||||
fastField={true}
|
fastField={true}
|
||||||
shouldUpdate={customersFieldShouldUpdate}
|
shouldUpdate={customersFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
>
|
>
|
||||||
<CustomersSelect
|
<CustomersSelect
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
@@ -358,6 +358,8 @@ function PaymentReceiveCustomerSelect() {
|
|||||||
disabled={!isNewMode}
|
disabled={!isNewMode}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
fastField={true}
|
fastField={true}
|
||||||
|
shouldUpdate={customersFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
/>
|
/>
|
||||||
{values.customer_id && (
|
{values.customer_id && (
|
||||||
<CustomerButtonLink customerId={values.customer_id}>
|
<CustomerButtonLink customerId={values.customer_id}>
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ export const fullAmountPaymentEntries = (entries) => {
|
|||||||
*/
|
*/
|
||||||
export const customersFieldShouldUpdate = (newProps, oldProps) => {
|
export const customersFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.customers !== oldProps.customers ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items ||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -245,11 +245,11 @@ function ReceiptFormCustomerSelect() {
|
|||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
label={<T id={'customer_name'} />}
|
label={<T id={'customer_name'} />}
|
||||||
inline={true}
|
|
||||||
labelInfo={<FieldRequiredHint />}
|
labelInfo={<FieldRequiredHint />}
|
||||||
customers={customers}
|
inline={true}
|
||||||
fastField={true}
|
fastField={true}
|
||||||
shouldUpdate={customersFieldShouldUpdate}
|
shouldUpdate={customersFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
>
|
>
|
||||||
<CustomersSelect
|
<CustomersSelect
|
||||||
name={'customer_id'}
|
name={'customer_id'}
|
||||||
@@ -261,6 +261,9 @@ function ReceiptFormCustomerSelect() {
|
|||||||
}}
|
}}
|
||||||
popoverFill={true}
|
popoverFill={true}
|
||||||
allowCreate={true}
|
allowCreate={true}
|
||||||
|
fastField={true}
|
||||||
|
shouldUpdate={customersFieldShouldUpdate}
|
||||||
|
shouldUpdateDeps={{ items: customers }}
|
||||||
/>
|
/>
|
||||||
{values.customer_id && (
|
{values.customer_id && (
|
||||||
<CustomerButtonLink customerId={values.customer_id}>
|
<CustomerButtonLink customerId={values.customer_id}>
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export const accountsFieldShouldUpdate = (newProps, oldProps) => {
|
|||||||
*/
|
*/
|
||||||
export const customersFieldShouldUpdate = (newProps, oldProps) => {
|
export const customersFieldShouldUpdate = (newProps, oldProps) => {
|
||||||
return (
|
return (
|
||||||
newProps.customers !== oldProps.customers ||
|
newProps.shouldUpdateDeps.items !== oldProps.shouldUpdateDeps.items ||
|
||||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user