Skip to content

Commit

Permalink
Merge pull request #49843 from rezkiy37/feature/49842-invoicing-check…
Browse files Browse the repository at this point in the history
…-if-feature-enabled

Invoicing verify that the user has the feature enabled on the page
  • Loading branch information
MariaHCD authored Oct 2, 2024
2 parents 4878161 + acde545 commit 20ff3be
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import type {FullScreenNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import WorkspacePageWithSections from '@pages/workspace/WorkspacePageWithSections';
import CONST from '@src/CONST';
import type SCREENS from '@src/SCREENS';
Expand All @@ -13,28 +14,33 @@ import WorkspaceInvoicesVBAView from './WorkspaceInvoicesVBAView';
import WorkspaceInvoiceVBASection from './WorkspaceInvoiceVBASection';

type WorkspaceInvoicesPageProps = StackScreenProps<FullScreenNavigatorParamList, typeof SCREENS.WORKSPACE.INVOICES>;

function WorkspaceInvoicesPage({route}: WorkspaceInvoicesPageProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const {shouldUseNarrowLayout} = useResponsiveLayout();
return (
<WorkspacePageWithSections
shouldUseScrollView
headerText={translate('workspace.common.invoices')}
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_INVOICES}
shouldShowOfflineIndicatorInWideScreen
shouldSkipVBBACall={false}
route={route}
<AccessOrNotFoundWrapper
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={route.params.policyID}
featureName={CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED}
>
{(hasVBA?: boolean, policyID?: string) => (
<View style={[styles.mt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{policyID && <WorkspaceInvoiceVBASection policyID={policyID} />}
{!hasVBA && policyID && <WorkspaceInvoicesNoVBAView policyID={policyID} />}
{hasVBA && policyID && <WorkspaceInvoicesVBAView policyID={policyID} />}
</View>
)}
</WorkspacePageWithSections>
<WorkspacePageWithSections
shouldUseScrollView
headerText={translate('workspace.common.invoices')}
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_INVOICES}
shouldShowOfflineIndicatorInWideScreen
shouldSkipVBBACall={false}
route={route}
>
{(hasVBA?: boolean, policyID?: string) => (
<View style={[styles.mt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{policyID && <WorkspaceInvoiceVBASection policyID={policyID} />}
{!hasVBA && policyID && <WorkspaceInvoicesNoVBAView policyID={policyID} />}
{hasVBA && policyID && <WorkspaceInvoicesVBAView policyID={policyID} />}
</View>
)}
</WorkspacePageWithSections>
</AccessOrNotFoundWrapper>
);
}

Expand Down

0 comments on commit 20ff3be

Please sign in to comment.