Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 36 additions & 34 deletions src/pages/workspace/travel/BookOrManageYourTrip.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,54 @@
import React from 'react';
import BookTravelButton from '@components/BookTravelButton';
import type {FeatureListItem} from '@components/FeatureList';
import FeatureList from '@components/FeatureList';
import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
import MenuItem from '@components/MenuItem';
import Section from '@components/Section';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import usePermissions from '@hooks/usePermissions';
import useThemeStyles from '@hooks/useThemeStyles';
import colors from '@styles/theme/colors';
import {openTravelDotLink} from '@libs/openTravelDotLink';
import CONST from '@src/CONST';
import WorkspaceTravelInvoicingSection from './WorkspaceTravelInvoicingSection';

type GetStartedTravelProps = {
policyID: string;
};

function GetStartedTravel({policyID}: GetStartedTravelProps) {
const handleCtaPress = () => {};

const {translate} = useLocalize();
const styles = useThemeStyles();
const icons = useMemoizedLazyExpensifyIcons(['LuggageWithLines', 'NewWindow'] as const);
const {isBetaEnabled} = usePermissions();
const isTravelInvoicingEnabled = isBetaEnabled(CONST.BETAS.TRAVEL_INVOICING);
const isPreventSpotnanaTravelEnabled = isBetaEnabled(CONST.BETAS.PREVENT_SPOTNANA_TRAVEL);

const illustrations = useMemoizedLazyIllustrations(['PiggyBank', 'TravelAlerts', 'EmptyStateTravel'] as const);
const handleManageTravel = () => {
// TODO: Show the prevention modal when the beta is enabled
if (isPreventSpotnanaTravelEnabled) {
return;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user won't get any UI feedback in this case which is a bad UX, but this is an edge case for admins who are trying to book from here for some reason when they have specifically asked to have travel disabled. I'll improve this later

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up #81764

}
openTravelDotLink(policyID);
Comment thread
stitesExpensify marked this conversation as resolved.
Resolved
};

const tripsFeatures: FeatureListItem[] = [
{
icon: illustrations.PiggyBank,
translationKey: 'travel.features.saveMoney',
},
{
icon: illustrations.TravelAlerts,
translationKey: 'travel.features.alerts',
},
];
return (
<FeatureList
menuItems={tripsFeatures}
title={translate('workspace.moreFeatures.travel.bookOrManageYourTrip.title')}
subtitle={translate('workspace.moreFeatures.travel.bookOrManageYourTrip.subtitle')}
onCtaPress={handleCtaPress}
illustrationBackgroundColor={colors.blue600}
illustration={illustrations.EmptyStateTravel}
illustrationStyle={styles.travelCardIllustration}
illustrationContainerStyle={[styles.emptyStateCardIllustrationContainer, styles.justifyContentCenter]}
titleStyles={styles.textHeadlineH1}
footer={
<BookTravelButton
text={translate('workspace.moreFeatures.travel.bookOrManageYourTrip.ctaText')}
activePolicyID={policyID}
<>
<Section
title={translate('workspace.moreFeatures.travel.travelInvoicing.travelBookingSection.title')}
subtitle={translate('workspace.moreFeatures.travel.travelInvoicing.travelBookingSection.subtitle')}
titleStyles={[styles.accountSettingsSectionTitle]}
subtitleMuted
isCentralPane
>
<MenuItem
title={translate('workspace.moreFeatures.travel.bookOrManageYourTrip.ctaText')}
icon={icons.LuggageWithLines}
onPress={handleManageTravel}
shouldShowRightIcon
iconRight={icons.NewWindow}
wrapperStyle={[styles.sectionMenuItemTopDescription, styles.mt3]}
/>
}
/>
</Section>
{isTravelInvoicingEnabled && <WorkspaceTravelInvoicingSection policyID={policyID} />}
</>
);
}

Expand Down
6 changes: 0 additions & 6 deletions src/pages/workspace/travel/PolicyTravelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import type SCREENS from '@src/SCREENS';
import BookOrManageYourTrip from './BookOrManageYourTrip';
import GetStartedTravel from './GetStartedTravel';
import ReviewingRequest from './ReviewingRequest';
import WorkspaceTravelInvoicingSection from './WorkspaceTravelInvoicingSection';

type WorkspaceTravelPageProps = PlatformStackScreenProps<WorkspaceSplitNavigatorParamList, typeof SCREENS.WORKSPACE.TRAVEL>;

Expand All @@ -42,7 +41,6 @@ function WorkspaceTravelPage({
const {translate} = useLocalize();
const policy = usePolicy(policyID);
const illustrations = useMemoizedLazyIllustrations(['Luggage'] as const);
const isTravelInvoicingEnabled = isBetaEnabled(CONST.BETAS.TRAVEL_INVOICING);
const workspaceAccountID = useWorkspaceAccountID(policyID);

const {login: currentUserLogin} = useCurrentUserPersonalDetails();
Expand Down Expand Up @@ -72,10 +70,6 @@ function WorkspaceTravelPage({
const step = getTravelStep(policy, travelSettings, isBetaEnabled(CONST.BETAS.IS_TRAVEL_VERIFIED), policies, currentUserLogin);

const mainContent = (() => {
// TODO: Remove this conditional when Travel Invoicing feature is fully implemented
if (isTravelInvoicingEnabled) {
return <WorkspaceTravelInvoicingSection policyID={policyID} />;
}
switch (step) {
case CONST.TRAVEL.STEPS.BOOK_OR_MANAGE_YOUR_TRIP:
return <BookOrManageYourTrip policyID={policyID} />;
Expand Down
29 changes: 1 addition & 28 deletions src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import React from 'react';
import {View} from 'react-native';
import AnimatedSubmitButton from '@components/AnimatedSubmitButton';
import MenuItem from '@components/MenuItem';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import Section from '@components/Section';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useSingleExecution from '@hooks/useSingleExecution';
import useThemeStyles from '@hooks/useThemeStyles';
import useWorkspaceAccountID from '@hooks/useWorkspaceAccountID';
import {openExternalLink} from '@libs/actions/Link';
import {clearTravelInvoicingSettlementAccountErrors, clearTravelInvoicingSettlementFrequencyErrors, setTravelInvoicingSettlementAccount} from '@libs/actions/TravelInvoicing';
import {getLastFourDigits} from '@libs/BankAccountUtils';
import {getEligibleBankAccountsForCard} from '@libs/CardUtils';
Expand Down Expand Up @@ -47,8 +43,6 @@ function WorkspaceTravelInvoicingSection({policyID}: WorkspaceTravelInvoicingSec
const styles = useThemeStyles();
const {translate} = useLocalize();
const workspaceAccountID = useWorkspaceAccountID(policyID);
const {isExecuting, singleExecution} = useSingleExecution();
const icons = useMemoizedLazyExpensifyIcons(['LuggageWithLines', 'NewWindow']);

// For Travel Invoicing, we use a travel-specific card settings key
// The format is: private_expensifyCardSettings_{workspaceAccountID}_{feedType}
Expand Down Expand Up @@ -231,28 +225,7 @@ function WorkspaceTravelInvoicingSection({policyID}: WorkspaceTravelInvoicingSec
</Section>
);

return (
<>
<Section
title={translate('workspace.moreFeatures.travel.travelInvoicing.travelBookingSection.title')}
subtitle={translate('workspace.moreFeatures.travel.travelInvoicing.travelBookingSection.subtitle')}
subtitleStyles={styles.mb6}
isCentralPane
subtitleMuted
>
<MenuItem
title={translate('workspace.moreFeatures.travel.travelInvoicing.travelBookingSection.manageTravelLabel')}
onPress={singleExecution(() => openExternalLink(CONST.FOOTER.TRAVEL_URL))}
disabled={isExecuting}
wrapperStyle={styles.sectionMenuItemTopDescription}
iconRight={icons.NewWindow}
icon={icons.LuggageWithLines}
shouldShowRightIcon
/>
</Section>
{optionItems.map(renderOptionItem)}
</>
);
return <>{optionItems.map(renderOptionItem)}</>;
}

export default WorkspaceTravelInvoicingSection;
12 changes: 4 additions & 8 deletions tests/ui/WorkspaceTravelInvoicingSectionTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ describe('WorkspaceTravelInvoicingSection', () => {
// Wait for component to render
await waitForBatchedUpdatesWithAct();

// Then the Travel Booking section should be visible
expect(screen.getByText('Travel booking')).toBeTruthy();
// And the Central Invoicing section should be visible
// Central Invoicing section should be visible
expect(screen.getByText('Central invoicing')).toBeTruthy();
});

Expand All @@ -126,9 +124,7 @@ describe('WorkspaceTravelInvoicingSection', () => {

await waitForBatchedUpdatesWithAct();

// Then the Travel Booking section should be visible
expect(screen.getByText('Travel booking')).toBeTruthy();
// And the Central Invoicing section should be visible
// The Central Invoicing section should be visible
expect(screen.getByText('Central invoicing')).toBeTruthy();
});
});
Expand Down Expand Up @@ -163,8 +159,8 @@ describe('WorkspaceTravelInvoicingSection', () => {

await waitForBatchedUpdatesWithAct();

// Then the section title should be visible
expect(screen.getByText('Travel booking')).toBeTruthy();
// The section title should be visible
expect(screen.getByText('Central invoicing')).toBeTruthy();
});

it('should display current travel spend label when configured', async () => {
Expand Down
Loading