Skip to content

Commit

Permalink
Merge pull request #49790 from rezkiy37/feature/45181-invoicing-lhn
Browse files Browse the repository at this point in the history
Add "Invoices" LHN option and badge
  • Loading branch information
madmax330 authored Oct 1, 2024
2 parents a34ef87 + d43fc75 commit 00cec11
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/pages/workspace/WorkspaceInitialPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import useSingleExecution from '@hooks/useSingleExecution';
import useThemeStyles from '@hooks/useThemeStyles';
import useWaitForNavigation from '@hooks/useWaitForNavigation';
import {isConnectionInProgress} from '@libs/actions/connections';
import * as CurrencyUtils from '@libs/CurrencyUtils';
import getTopmostRouteName from '@libs/Navigation/getTopmostRouteName';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
Expand Down Expand Up @@ -62,6 +63,7 @@ type WorkspaceMenuItem = {
| typeof SCREENS.WORKSPACE.COMPANY_CARDS
| typeof SCREENS.WORKSPACE.REPORT_FIELDS
| typeof SCREENS.WORKSPACE.RULES;
badgeText?: string;
};

type WorkspaceInitialPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps<FullScreenNavigatorParamList, typeof SCREENS.WORKSPACE.INITIAL>;
Expand Down Expand Up @@ -106,6 +108,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
[CONST.POLICY.MORE_FEATURES.ARE_EXPENSIFY_CARDS_ENABLED]: policy?.areExpensifyCardsEnabled,
[CONST.POLICY.MORE_FEATURES.ARE_REPORT_FIELDS_ENABLED]: policy?.areReportFieldsEnabled,
[CONST.POLICY.MORE_FEATURES.ARE_RULES_ENABLED]: policy?.areRulesEnabled,
[CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED]: policy?.areInvoicesEnabled,
}),
[policy],
) as PolicyFeatureStates;
Expand Down Expand Up @@ -173,6 +176,21 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
});
}, [policy, isOffline, policyFeatureStates, prevPendingFields]);

if (featureStates?.[CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED]) {
const currencyCode = policy?.outputCurrency ?? CONST.CURRENCY.USD;

protectedCollectPolicyMenuItems.push({
translationKey: 'workspace.common.invoices',
icon: Expensicons.InvoiceGeneric,
action: singleExecution(waitForNavigate(() => Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID)))),
routeName: SCREENS.WORKSPACE.INVOICES,
badgeText: `${CurrencyUtils.getCurrencySymbol(currencyCode)}${CurrencyUtils.convertToFrontendAmountAsString(
policy?.invoice?.bankAccount?.stripeConnectAccountBalance ?? 0,
currencyCode,
)}`,
});
}

if (featureStates?.[CONST.POLICY.MORE_FEATURES.ARE_DISTANCE_RATES_ENABLED]) {
protectedCollectPolicyMenuItems.push({
translationKey: 'workspace.common.distanceRates',
Expand Down Expand Up @@ -392,6 +410,7 @@ function WorkspaceInitialPage({policyDraft, policy: policyProp, route}: Workspac
wrapperStyle={styles.sectionMenuItem}
highlighted={enabledItem?.routeName === item.routeName}
focused={!!(item.routeName && activeRoute?.startsWith(item.routeName))}
badgeText={item.badgeText}
/>
))}
</View>
Expand Down

0 comments on commit 00cec11

Please sign in to comment.