mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: organization form fields.
This commit is contained in:
@@ -16,6 +16,8 @@ import { getFiscalYear } from 'common/fiscalYearOptions';
|
|||||||
import { getLanguages } from 'common/languagesOptions';
|
import { getLanguages } from 'common/languagesOptions';
|
||||||
import { useGeneralFormContext } from './GeneralFormProvider';
|
import { useGeneralFormContext } from './GeneralFormProvider';
|
||||||
|
|
||||||
|
import { shouldBaseCurrencyUpdate } from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preferences general form.
|
* Preferences general form.
|
||||||
*/
|
*/
|
||||||
@@ -27,7 +29,9 @@ export default function PreferencesGeneralForm({ isSubmitting }) {
|
|||||||
const Languages = getLanguages();
|
const Languages = getLanguages();
|
||||||
const Currencies = getAllCurrenciesOptions();
|
const Currencies = getAllCurrenciesOptions();
|
||||||
|
|
||||||
const { dateFormats } = useGeneralFormContext();
|
const { dateFormats, baseCurrencyMutateAbility } = useGeneralFormContext();
|
||||||
|
|
||||||
|
const baseCurrencyDisabled = baseCurrencyMutateAbility.length > 0;
|
||||||
|
|
||||||
// Handle close click.
|
// Handle close click.
|
||||||
const handleCloseClick = () => {
|
const handleCloseClick = () => {
|
||||||
@@ -96,7 +100,11 @@ export default function PreferencesGeneralForm({ isSubmitting }) {
|
|||||||
</FastField>
|
</FastField>
|
||||||
|
|
||||||
{/* ---------- Base currency ---------- */}
|
{/* ---------- Base currency ---------- */}
|
||||||
<FastField name={'base_currency'}>
|
<FastField
|
||||||
|
name={'base_currency'}
|
||||||
|
baseCurrencyDisabled={baseCurrencyDisabled}
|
||||||
|
shouldUpdate={shouldBaseCurrencyUpdate}
|
||||||
|
>
|
||||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={<T id={'base_currency'} />}
|
label={<T id={'base_currency'} />}
|
||||||
@@ -115,7 +123,7 @@ export default function PreferencesGeneralForm({ isSubmitting }) {
|
|||||||
<ListSelect
|
<ListSelect
|
||||||
items={Currencies}
|
items={Currencies}
|
||||||
onItemSelect={(currency) => {
|
onItemSelect={(currency) => {
|
||||||
form.setFieldValue('base_currency', currency.code);
|
form.setFieldValue('base_currency', currency.key);
|
||||||
}}
|
}}
|
||||||
selectedItem={value}
|
selectedItem={value}
|
||||||
selectedItemProp={'key'}
|
selectedItemProp={'key'}
|
||||||
@@ -123,6 +131,7 @@ export default function PreferencesGeneralForm({ isSubmitting }) {
|
|||||||
textProp={'name'}
|
textProp={'name'}
|
||||||
labelProp={'key'}
|
labelProp={'key'}
|
||||||
popoverProps={{ minimal: true }}
|
popoverProps={{ minimal: true }}
|
||||||
|
disabled={baseCurrencyDisabled}
|
||||||
/>
|
/>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
)}
|
)}
|
||||||
@@ -141,9 +150,9 @@ export default function PreferencesGeneralForm({ isSubmitting }) {
|
|||||||
>
|
>
|
||||||
<ListSelect
|
<ListSelect
|
||||||
items={FiscalYear}
|
items={FiscalYear}
|
||||||
onItemSelect={({ value }) =>
|
onItemSelect={(option) => {
|
||||||
form.setFieldValue('fiscal_year', value)
|
form.setFieldValue('fiscal_year', option.key)
|
||||||
}
|
}}
|
||||||
selectedItem={value}
|
selectedItem={value}
|
||||||
selectedItemProp={'key'}
|
selectedItemProp={'key'}
|
||||||
defaultText={<T id={'select_fiscal_year'} />}
|
defaultText={<T id={'select_fiscal_year'} />}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ function GeneralFormPage({
|
|||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
|
|
||||||
// Reboot the application if the application's language is mutated.
|
// Reboot the application if the application's language is mutated.
|
||||||
if (organization.language !== values.language) {
|
if (organization.metadata?.language !== values.language) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
useCurrentOrganization,
|
useCurrentOrganization,
|
||||||
useUpdateOrganization,
|
useUpdateOrganization,
|
||||||
useDateFormats,
|
useDateFormats,
|
||||||
|
useOrgBaseCurrencyMutateAbilities,
|
||||||
} from 'hooks/query';
|
} from 'hooks/query';
|
||||||
import PreferencesPageLoader from '../PreferencesPageLoader';
|
import PreferencesPageLoader from '../PreferencesPageLoader';
|
||||||
|
|
||||||
@@ -21,6 +22,9 @@ function GeneralFormProvider({ ...props }) {
|
|||||||
const { data: dateFormats, isLoading: isDateFormatsLoading } =
|
const { data: dateFormats, isLoading: isDateFormatsLoading } =
|
||||||
useDateFormats();
|
useDateFormats();
|
||||||
|
|
||||||
|
const { data: baseCurrencyMutateAbility } =
|
||||||
|
useOrgBaseCurrencyMutateAbilities();
|
||||||
|
|
||||||
// Mutate organization information.
|
// Mutate organization information.
|
||||||
const { mutateAsync: updateOrganization } = useUpdateOrganization();
|
const { mutateAsync: updateOrganization } = useUpdateOrganization();
|
||||||
|
|
||||||
@@ -29,6 +33,7 @@ function GeneralFormProvider({ ...props }) {
|
|||||||
isOrganizationLoading,
|
isOrganizationLoading,
|
||||||
isDateFormatsLoading,
|
isDateFormatsLoading,
|
||||||
updateOrganization,
|
updateOrganization,
|
||||||
|
baseCurrencyMutateAbility,
|
||||||
organization,
|
organization,
|
||||||
dateFormats,
|
dateFormats,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user