mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
Fix: Add prepend and money field group to customer & vendors
This commit is contained in:
@@ -1,9 +1,15 @@
|
|||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormGroup, Position, Classes } from '@blueprintjs/core';
|
import { FormGroup, Position, Classes, ControlGroup } from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FastField, ErrorMessage } from 'formik';
|
import { FastField, ErrorMessage } from 'formik';
|
||||||
import { MoneyInputGroup, CurrencySelectList, Row, Col } from 'components';
|
import {
|
||||||
|
MoneyInputGroup,
|
||||||
|
InputPrependText,
|
||||||
|
CurrencySelectList,
|
||||||
|
Row,
|
||||||
|
Col,
|
||||||
|
} from 'components';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
|
||||||
import withCurrencies from 'containers/Currencies/withCurrencies';
|
import withCurrencies from 'containers/Currencies/withCurrencies';
|
||||||
@@ -21,20 +27,7 @@ function CustomerFinancialPanel({
|
|||||||
|
|
||||||
customerId,
|
customerId,
|
||||||
}) {
|
}) {
|
||||||
const [selectedItems, setSelectedItems] = useState();
|
|
||||||
|
|
||||||
const onItemsSelect = useCallback(
|
|
||||||
(filedName) => {
|
|
||||||
return (filed) => {
|
|
||||||
setSelectedItems({
|
|
||||||
...selectedItems,
|
|
||||||
[filedName]: filed,
|
|
||||||
});
|
|
||||||
// setFieldValue(filedName, filed.currency_code);
|
|
||||||
};
|
|
||||||
},
|
|
||||||
[selectedItems],
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<div className={'tab-panel--financial'}>
|
<div className={'tab-panel--financial'}>
|
||||||
<Row>
|
<Row>
|
||||||
@@ -52,7 +45,6 @@ function CustomerFinancialPanel({
|
|||||||
<DateInput
|
<DateInput
|
||||||
{...momentFormatter('YYYY/MM/DD')}
|
{...momentFormatter('YYYY/MM/DD')}
|
||||||
value={tansformDateValue(value)}
|
value={tansformDateValue(value)}
|
||||||
// onChange={}
|
|
||||||
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
popoverProps={{ position: Position.BOTTOM, minimal: true }}
|
||||||
disabled={customerId}
|
disabled={customerId}
|
||||||
/>
|
/>
|
||||||
@@ -62,7 +54,12 @@ function CustomerFinancialPanel({
|
|||||||
|
|
||||||
{/*------------ Opening balance -----------*/}
|
{/*------------ Opening balance -----------*/}
|
||||||
<FastField name={'opening_balance'}>
|
<FastField name={'opening_balance'}>
|
||||||
{({ field, field: { value }, meta: { error, touched } }) => (
|
{({
|
||||||
|
form: { values },
|
||||||
|
field,
|
||||||
|
field: { value },
|
||||||
|
meta: { error, touched },
|
||||||
|
}) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'opening_balance'} />}
|
label={<T id={'opening_balance'} />}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
@@ -72,13 +69,15 @@ function CustomerFinancialPanel({
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
<MoneyInputGroup
|
<ControlGroup>
|
||||||
value={value}
|
<InputPrependText text={values.currency_code} />
|
||||||
prefix={'$'}
|
<MoneyInputGroup
|
||||||
inputGroupProps={{ fill: true }}
|
value={value}
|
||||||
disabled={customerId}
|
inputGroupProps={{ fill: true }}
|
||||||
{...field}
|
disabled={customerId}
|
||||||
/>
|
{...field}
|
||||||
|
/>
|
||||||
|
</ControlGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
@@ -98,7 +97,9 @@ function CustomerFinancialPanel({
|
|||||||
<CurrencySelectList
|
<CurrencySelectList
|
||||||
currenciesList={currenciesList}
|
currenciesList={currenciesList}
|
||||||
selectedCurrencyCode={value}
|
selectedCurrencyCode={value}
|
||||||
onCurrencySelected={onItemsSelect('currency_code')}
|
onCurrencySelected={(currency) => {
|
||||||
|
form.setFieldValue('currency_code', currency.currency_code);
|
||||||
|
}}
|
||||||
disabled={customerId}
|
disabled={customerId}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import withCustomerDetail from 'containers/Customers/withCustomerDetail';
|
|||||||
import withCustomersActions from 'containers/Customers/withCustomersActions';
|
import withCustomersActions from 'containers/Customers/withCustomersActions';
|
||||||
import withMediaActions from 'containers/Media/withMediaActions';
|
import withMediaActions from 'containers/Media/withMediaActions';
|
||||||
import withCustomers from 'containers/Customers//withCustomers';
|
import withCustomers from 'containers/Customers//withCustomers';
|
||||||
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
import useMedia from 'hooks/useMedia';
|
import useMedia from 'hooks/useMedia';
|
||||||
|
|
||||||
import { compose, transformToForm } from 'utils';
|
import { compose, transformToForm } from 'utils';
|
||||||
@@ -73,6 +74,9 @@ function CustomerForm({
|
|||||||
// #withCustomerDetail
|
// #withCustomerDetail
|
||||||
customer,
|
customer,
|
||||||
|
|
||||||
|
// #withSettings
|
||||||
|
baseCurrency,
|
||||||
|
|
||||||
// #withCustomersActions
|
// #withCustomersActions
|
||||||
requestSubmitCustomer,
|
requestSubmitCustomer,
|
||||||
requestEditCustomer,
|
requestEditCustomer,
|
||||||
@@ -151,6 +155,7 @@ function CustomerForm({
|
|||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
...defaultInitialValues,
|
...defaultInitialValues,
|
||||||
|
currency_code: baseCurrency,
|
||||||
...transformToForm(customer, defaultInitialValues),
|
...transformToForm(customer, defaultInitialValues),
|
||||||
}),
|
}),
|
||||||
[customer, defaultInitialValues],
|
[customer, defaultInitialValues],
|
||||||
@@ -271,6 +276,9 @@ export default compose(
|
|||||||
withCustomers(({ customers }) => ({
|
withCustomers(({ customers }) => ({
|
||||||
customers,
|
customers,
|
||||||
})),
|
})),
|
||||||
|
withSettings(({ organizationSettings }) => ({
|
||||||
|
baseCurrency: organizationSettings?.baseCurrency,
|
||||||
|
})),
|
||||||
withDashboardActions,
|
withDashboardActions,
|
||||||
withCustomersActions,
|
withCustomersActions,
|
||||||
withMediaActions,
|
withMediaActions,
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FormGroup, Position, Classes } from '@blueprintjs/core';
|
import { FormGroup, ControlGroup, Position, Classes } from '@blueprintjs/core';
|
||||||
import { DateInput } from '@blueprintjs/datetime';
|
import { DateInput } from '@blueprintjs/datetime';
|
||||||
import { FastField, ErrorMessage } from 'formik';
|
import { FastField, ErrorMessage } from 'formik';
|
||||||
import { MoneyInputGroup, CurrencySelectList, Row, Col } from 'components';
|
import {
|
||||||
|
MoneyInputGroup,
|
||||||
|
InputPrependText,
|
||||||
|
CurrencySelectList,
|
||||||
|
Row,
|
||||||
|
Col,
|
||||||
|
} from 'components';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
|
||||||
import withCurrencies from 'containers/Currencies/withCurrencies';
|
import withCurrencies from 'containers/Currencies/withCurrencies';
|
||||||
@@ -50,7 +56,12 @@ function VendorFinanicalPanelTab({
|
|||||||
</FastField>
|
</FastField>
|
||||||
{/*------------ Opening balance -----------*/}
|
{/*------------ Opening balance -----------*/}
|
||||||
<FastField name={'opening_balance'}>
|
<FastField name={'opening_balance'}>
|
||||||
{({ field, field: { value }, meta: { error, touched } }) => (
|
{({
|
||||||
|
form: { values },
|
||||||
|
field,
|
||||||
|
field: { value },
|
||||||
|
meta: { error, touched },
|
||||||
|
}) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'opening_balance'} />}
|
label={<T id={'opening_balance'} />}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
@@ -60,16 +71,19 @@ function VendorFinanicalPanelTab({
|
|||||||
intent={inputIntent({ error, touched })}
|
intent={inputIntent({ error, touched })}
|
||||||
inline={true}
|
inline={true}
|
||||||
>
|
>
|
||||||
<MoneyInputGroup
|
<ControlGroup>
|
||||||
value={value}
|
<InputPrependText text={values.currency_code } />
|
||||||
onChange={field.onChange}
|
<MoneyInputGroup
|
||||||
prefix={'$'}
|
value={value}
|
||||||
inputGroupProps={{
|
onChange={field.onChange}
|
||||||
fill: true,
|
prefix={'$'}
|
||||||
...field,
|
inputGroupProps={{
|
||||||
}}
|
fill: true,
|
||||||
disabled={vendorId}
|
...field,
|
||||||
/>
|
}}
|
||||||
|
disabled={vendorId}
|
||||||
|
/>
|
||||||
|
</ControlGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
</FastField>
|
</FastField>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import VendorFloatingActions from './VendorFloatingActions';
|
|||||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||||
import withVendorDetail from './withVendorDetail';
|
import withVendorDetail from './withVendorDetail';
|
||||||
import withVendorActions from './withVendorActions';
|
import withVendorActions from './withVendorActions';
|
||||||
|
import withSettings from 'containers/Settings/withSettings';
|
||||||
|
|
||||||
import { compose, transformToForm } from 'utils';
|
import { compose, transformToForm } from 'utils';
|
||||||
|
|
||||||
@@ -73,6 +74,9 @@ function VendorForm({
|
|||||||
requestSubmitVendor,
|
requestSubmitVendor,
|
||||||
requestEditVendor,
|
requestEditVendor,
|
||||||
|
|
||||||
|
// #withSettings
|
||||||
|
baseCurrency,
|
||||||
|
|
||||||
// #OwnProps
|
// #OwnProps
|
||||||
vendorId,
|
vendorId,
|
||||||
}) {
|
}) {
|
||||||
@@ -88,6 +92,7 @@ function VendorForm({
|
|||||||
const initialValues = useMemo(
|
const initialValues = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
...defaultInitialValues,
|
...defaultInitialValues,
|
||||||
|
currency_code: baseCurrency,
|
||||||
...transformToForm(vendor, defaultInitialValues),
|
...transformToForm(vendor, defaultInitialValues),
|
||||||
}),
|
}),
|
||||||
[defaultInitialValues],
|
[defaultInitialValues],
|
||||||
@@ -181,5 +186,8 @@ function VendorForm({
|
|||||||
export default compose(
|
export default compose(
|
||||||
withVendorDetail(),
|
withVendorDetail(),
|
||||||
withDashboardActions,
|
withDashboardActions,
|
||||||
|
withSettings(({ organizationSettings }) => ({
|
||||||
|
baseCurrency: organizationSettings?.baseCurrency,
|
||||||
|
})),
|
||||||
withVendorActions,
|
withVendorActions,
|
||||||
)(VendorForm);
|
)(VendorForm);
|
||||||
|
|||||||
Reference in New Issue
Block a user