BC-4: feat: base currency withCurrentOrganization

This commit is contained in:
elforjani3
2021-09-07 00:16:46 +02:00
parent 6401692903
commit 39ba31a842
31 changed files with 152 additions and 213 deletions

View File

@@ -19,7 +19,7 @@ import { FormattedMessage as T } from 'components';
import classNames from 'classnames';
import { useItemFormContext } from './ItemFormProvider';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { ACCOUNT_PARENT_TYPE } from 'common/accountTypes';
import { compose, inputIntent } from 'utils';
@@ -35,7 +35,7 @@ import {
/**
* Item form body.
*/
function ItemFormBody({ baseCurrency }) {
function ItemFormBody({ organization: { base_currency } }) {
const { accounts } = useItemFormContext();
const { values } = useFormikContext();
@@ -76,7 +76,7 @@ function ItemFormBody({ baseCurrency }) {
inline={true}
>
<ControlGroup>
<InputPrependText text={baseCurrency} />
<InputPrependText text={base_currency} />
<MoneyInputGroup
value={value}
inputGroupProps={{ fill: true }}
@@ -182,7 +182,7 @@ function ItemFormBody({ baseCurrency }) {
inline={true}
>
<ControlGroup>
<InputPrependText text={baseCurrency} />
<InputPrependText text={base_currency} />
<MoneyInputGroup
value={value}
inputGroupProps={{ medium: true }}
@@ -259,8 +259,4 @@ function ItemFormBody({ baseCurrency }) {
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(ItemFormBody);
export default compose(withCurrentOrganization())(ItemFormBody);

View File

@@ -6,7 +6,7 @@ import { CLASSES } from 'common/classes';
import { FormattedMessage as T } from 'components';
import classNames from 'classnames';
import withSettings from 'containers/Settings/withSettings';
import withCurrentOrganization from 'containers/Organization/withCurrentOrganization';
import { accountsFieldShouldUpdate } from './utils';
import { compose, inputIntent } from 'utils';
@@ -16,7 +16,7 @@ import { useItemFormContext } from './ItemFormProvider';
/**
* Item form inventory sections.
*/
function ItemFormInventorySection({ baseCurrency }) {
function ItemFormInventorySection({ organization: { base_currency } }) {
const { accounts } = useItemFormContext();
return (
@@ -63,8 +63,4 @@ function ItemFormInventorySection({ baseCurrency }) {
);
}
export default compose(
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,
})),
)(ItemFormInventorySection);
export default compose(withCurrentOrganization())(ItemFormInventorySection);