mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
Merge pull request #592 from bigcapitalhq/matching-reconcile-branches
fix: Should not load branches on reconcile matching form if the branches not enabled
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { useAccounts, useBranches } from '@/hooks/query';
|
|
||||||
import { Spinner } from '@blueprintjs/core';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Spinner } from '@blueprintjs/core';
|
||||||
|
import { Features } from '@/constants';
|
||||||
|
import { useAccounts, useBranches } from '@/hooks/query';
|
||||||
|
import { useFeatureCan } from '@/hooks/state';
|
||||||
|
|
||||||
interface MatchingReconcileTransactionBootProps {
|
interface MatchingReconcileTransactionBootProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
@@ -15,8 +17,17 @@ const MatchingReconcileTransactionBootContext =
|
|||||||
export function MatchingReconcileTransactionBoot({
|
export function MatchingReconcileTransactionBoot({
|
||||||
children,
|
children,
|
||||||
}: MatchingReconcileTransactionBootProps) {
|
}: MatchingReconcileTransactionBootProps) {
|
||||||
|
// Detarmines whether the feature is enabled.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts({}, {});
|
const { data: accounts, isLoading: isAccountsLoading } = useAccounts({}, {});
|
||||||
const { data: branches, isLoading: isBranchesLoading } = useBranches({}, {});
|
const { data: branches, isLoading: isBranchesLoading } = useBranches(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
enabled: isBranchFeatureCan,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const provider = {
|
const provider = {
|
||||||
accounts,
|
accounts,
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
BranchSelect,
|
BranchSelect,
|
||||||
FDateInput,
|
FDateInput,
|
||||||
|
FeatureCan,
|
||||||
FFormGroup,
|
FFormGroup,
|
||||||
FInputGroup,
|
FInputGroup,
|
||||||
FMoneyInputGroup,
|
FMoneyInputGroup,
|
||||||
@@ -30,6 +31,7 @@ import { useAccountTransactionsContext } from '../../AccountTransactions/Account
|
|||||||
import { MatchingReconcileFormSchema } from './MatchingReconcileTransactionForm.schema';
|
import { MatchingReconcileFormSchema } from './MatchingReconcileTransactionForm.schema';
|
||||||
import { initialValues, transformToReq } from './_utils';
|
import { initialValues, transformToReq } from './_utils';
|
||||||
import { withBanking } from '../../withBanking';
|
import { withBanking } from '../../withBanking';
|
||||||
|
import { Features } from '@/constants';
|
||||||
|
|
||||||
interface MatchingReconcileTransactionFormProps {
|
interface MatchingReconcileTransactionFormProps {
|
||||||
onSubmitSuccess?: (values: any) => void;
|
onSubmitSuccess?: (values: any) => void;
|
||||||
@@ -205,6 +207,7 @@ function CreateReconcileTransactionContent() {
|
|||||||
<FInputGroup name={'reference_no'} />
|
<FInputGroup name={'reference_no'} />
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
|
||||||
|
<FeatureCan feature={Features.Branches}>
|
||||||
<FFormGroup
|
<FFormGroup
|
||||||
name={'branchId'}
|
name={'branchId'}
|
||||||
label={'Branch'}
|
label={'Branch'}
|
||||||
@@ -225,6 +228,7 @@ function CreateReconcileTransactionContent() {
|
|||||||
fastField
|
fastField
|
||||||
/>
|
/>
|
||||||
</FFormGroup>
|
</FFormGroup>
|
||||||
|
</FeatureCan>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user