From 772c24e3ef4839cd119e9dcbafa580c5d73394c7 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Thu, 9 Sep 2021 21:05:18 +0200 Subject: [PATCH] fix: organization lock base currency field. --- client/src/containers/Preferences/General/utils.js | 8 ++++++++ client/src/hooks/query/organization.js | 12 ++++++++++++ .../src/store/organizations/organizations.types.js | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 client/src/containers/Preferences/General/utils.js diff --git a/client/src/containers/Preferences/General/utils.js b/client/src/containers/Preferences/General/utils.js new file mode 100644 index 000000000..8e63a84e5 --- /dev/null +++ b/client/src/containers/Preferences/General/utils.js @@ -0,0 +1,8 @@ +import { defaultFastFieldShouldUpdate } from 'utils'; + +export const shouldBaseCurrencyUpdate = (newProps, oldProps) => { + return ( + newProps.baseCurrencyDisabled !== oldProps.baseCurrencyDisabled || + defaultFastFieldShouldUpdate(newProps, oldProps) + ); +}; diff --git a/client/src/hooks/query/organization.js b/client/src/hooks/query/organization.js index 7145cd297..55abdc5c2 100644 --- a/client/src/hooks/query/organization.js +++ b/client/src/hooks/query/organization.js @@ -91,3 +91,15 @@ export function useUpdateOrganization(props) { }, ); } + +export function useOrgBaseCurrencyMutateAbilities(props) { + return useRequestQuery( + [t.ORGANIZATION_MUTATE_BASE_CURRENCY_ABILITIES], + { method: 'get', url: `organization/base_currency_mutate` }, + { + select: (res) => res.data.abilities, + defaultData: [], + ...props, + }, + ); +} diff --git a/client/src/store/organizations/organizations.types.js b/client/src/store/organizations/organizations.types.js index 7f7c90eb6..1ab9f3d00 100644 --- a/client/src/store/organizations/organizations.types.js +++ b/client/src/store/organizations/organizations.types.js @@ -2,5 +2,6 @@ export default { ORGANIZATION_SET: 'ORGANIZATION_SET', ORGANIZATIONS_LIST_SET: 'ORGANIZATIONS_LIST_SET', - SET_ORGANIZATION_CONGRATS: 'SET_ORGANIZATION_CONGRATS' + SET_ORGANIZATION_CONGRATS: 'SET_ORGANIZATION_CONGRATS', + ORGANIZATION_MUTATE_BASE_CURRENCY_ABILITIES: 'ORGANIZATION_MUTATE_BASE_CURRENCY_ABILITIES' }; \ No newline at end of file