From fa7ba2770d09fc6f70ee64633c699ed77c49af45 Mon Sep 17 00:00:00 2001 From: Hans Date: Sun, 5 May 2024 16:43:30 +0700 Subject: [PATCH] add shouldBeBlocked for AccessOrNotFoundWrapper --- src/components/SelectionScreen.tsx | 5 +++++ src/pages/workspace/AccessOrNotFoundWrapper.tsx | 8 ++++++-- .../xero/advanced/XeroInvoiceAccountSelectorPage.tsx | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/SelectionScreen.tsx b/src/components/SelectionScreen.tsx index 2d6c6e299a1d..a2ab477accef 100644 --- a/src/components/SelectionScreen.tsx +++ b/src/components/SelectionScreen.tsx @@ -49,6 +49,9 @@ type SelectionScreenProps = { /** The current feature name that the user tries to get access to */ featureName?: PolicyFeatureName; + + /** Whether or not to block user from accessing the page */ + shouldBeBlocked?: boolean; }; function SelectionScreen({ @@ -63,6 +66,7 @@ function SelectionScreen({ policyID, accessVariants, featureName, + shouldBeBlocked, }: SelectionScreenProps) { const {translate} = useLocalize(); return ( @@ -70,6 +74,7 @@ function SelectionScreen({ policyID={policyID} accessVariants={accessVariants} featureName={featureName} + shouldBeBlocked={shouldBeBlocked} > ; type PageNotFoundFallbackProps = Pick & {shouldShowFullScreenFallback: boolean}; @@ -68,7 +71,7 @@ function PageNotFoundFallback({policyID, shouldShowFullScreenFallback, fullPageN ); } -function AccessOrNotFoundWrapper({accessVariants = [], fullPageNotFoundViewProps, ...props}: AccessOrNotFoundWrapperProps) { +function AccessOrNotFoundWrapper({accessVariants = [], fullPageNotFoundViewProps, shouldBeBlocked, ...props}: AccessOrNotFoundWrapperProps) { const {policy, policyID, featureName, isLoadingReportData} = props; const isPolicyIDInRoute = !!policyID?.length; @@ -92,7 +95,8 @@ function AccessOrNotFoundWrapper({accessVariants = [], fullPageNotFoundViewProps return acc && accessFunction(policy); }, true); - const shouldShowNotFoundPage = isEmptyObject(policy) || (Object.keys(policy).length === 1 && !isEmptyObject(policy.errors)) || !policy?.id || !isPageAccessible || !isFeatureEnabled; + const shouldShowNotFoundPage = + isEmptyObject(policy) || (Object.keys(policy).length === 1 && !isEmptyObject(policy.errors)) || !policy?.id || !isPageAccessible || !isFeatureEnabled || shouldBeBlocked; if (shouldShowFullScreenLoadingIndicator) { return ; diff --git a/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx b/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx index 23c3bfc8af29..460eca1a153b 100644 --- a/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx +++ b/src/pages/workspace/accounting/xero/advanced/XeroInvoiceAccountSelectorPage.tsx @@ -20,7 +20,7 @@ function XeroInvoiceAccountSelectorPage({policy}: WithPolicyConnectionsProps) { const policyID = policy?.id ?? ''; const {bankAccounts} = policy?.connections?.xero?.data ?? {}; - const {invoiceCollectionsAccountID} = policy?.connections?.xero?.config.sync ?? {}; + const {invoiceCollectionsAccountID, syncReimbursedReports} = policy?.connections?.xero?.config.sync ?? {}; const xeroSelectorOptions = useMemo( () => @@ -62,6 +62,7 @@ function XeroInvoiceAccountSelectorPage({policy}: WithPolicyConnectionsProps) { displayName={XeroInvoiceAccountSelectorPage.displayName} sections={[{data: xeroSelectorOptions}]} listItem={RadioListItem} + shouldBeBlocked={!syncReimbursedReports} onSelectRow={updateMode} initiallyFocusedOptionKey={initiallyFocusedOptionKey} headerContent={listHeaderComponent}