Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VIP][Travel] View trip details and authenticate to travelDot #43081

Merged
merged 41 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
03af563
add trip data type
rushatgabhane Jun 4, 2024
5b0fd92
get trip id from transaction
rushatgabhane Jun 4, 2024
b2d1aa3
get trip id and should show trip details view
rushatgabhane Jun 4, 2024
d2f6dad
add menu item for trip details
rushatgabhane Jun 4, 2024
2851353
add luggage icon
rushatgabhane Jun 4, 2024
c4f4512
add suitcase icon
rushatgabhane Jun 4, 2024
a408b66
fix type tripid
rushatgabhane Jun 4, 2024
fb7fdec
fix type tripid
rushatgabhane Jun 4, 2024
68ba31d
add trip id url
rushatgabhane Jun 4, 2024
09af194
navigate to trip id url
rushatgabhane Jun 4, 2024
69cf344
handle staging url
rushatgabhane Jun 4, 2024
d0bc4fe
use translate
rushatgabhane Jun 7, 2024
8f8029d
simplify
rushatgabhane Jun 7, 2024
b0bd79d
simplify travel const
rushatgabhane Jun 7, 2024
a6bc038
Merge branch 'Expensify:main' into view-trip-details
rushatgabhane Jun 9, 2024
61e22e0
rm import
rushatgabhane Jun 9, 2024
750856b
add generate spotnana command param type
rushatgabhane Jun 9, 2024
8ad2e06
add tmc id spotnananananananna
rushatgabhane Jun 9, 2024
407b93a
add spotnana token in api response
rushatgabhane Jun 9, 2024
53e65c9
get travel dot from env
rushatgabhane Jun 9, 2024
05a9cc6
build travel dot url
rushatgabhane Jun 9, 2024
c095083
make spotnana token optional
rushatgabhane Jun 9, 2024
5ee49dd
add postlogin url
rushatgabhane Jun 9, 2024
25400ac
get rid of env
rushatgabhane Jun 9, 2024
0f17458
add early return and add login url for trip id
rushatgabhane Jun 9, 2024
17fba2d
add docs
rushatgabhane Jun 9, 2024
deb01aa
add docs
rushatgabhane Jun 9, 2024
57da999
rm dependency of env for travel url
rushatgabhane Jun 9, 2024
9956900
rename to path for clarity
rushatgabhane Jun 9, 2024
997fb34
Merge branch 'Expensify:main' into view-trip-details
rushatgabhane Jun 10, 2024
e15858e
Update MoneyRequestView.tsx
rushatgabhane Jun 10, 2024
a6d48f2
Apply suggestions from code review
rushatgabhane Jun 10, 2024
f0d4fd8
add prod tmc id
rushatgabhane Jun 10, 2024
dae0dd4
tmc id as per environment
rushatgabhane Jun 10, 2024
938b60e
get tmc id as per env for spotnana
rushatgabhane Jun 10, 2024
6895d38
add leading slash if not present to redirect url
rushatgabhane Jun 10, 2024
2e9d622
Update src/languages/es.ts
rushatgabhane Jun 11, 2024
bcde944
Merge branch 'Expensify:main' into view-trip-details
rushatgabhane Jun 13, 2024
d80564d
fix merge
rushatgabhane Jun 14, 2024
e48fc99
fix typescript errs
rushatgabhane Jun 14, 2024
9033b4e
Merge branch 'Expensify:main' into view-trip-details
rushatgabhane Jun 16, 2024
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
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3306,6 +3306,7 @@ const CONST = {

CONCIERGE_TRAVEL_URL: 'https://community.expensify.com/discussion/7066/introducing-concierge-travel',
BOOK_TRAVEL_DEMO_URL: 'https://calendly.com/d/ck2z-xsh-q97/expensify-travel-demo-travel-page',
TRIP_ID_URL: (tripID: string, isProduction: boolean) => (isProduction ? `https://travel.expensify.com/trips/${tripID}` : `https://staging.travel.expensify.com/trips/${tripID}`),
rushatgabhane marked this conversation as resolved.
Show resolved Hide resolved
SCREEN_READER_STATES: {
ALL: 'all',
ACTIVE: 'active',
Expand Down
24 changes: 23 additions & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, {useCallback, useMemo} from 'react';
import {View} from 'react-native';
import {Linking, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import ConfirmedRoute from '@components/ConfirmedRoute';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItem from '@components/MenuItem';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import {useSession} from '@components/OnyxProvider';
Expand All @@ -12,6 +13,7 @@ import ReceiptEmptyState from '@components/ReceiptEmptyState';
import Switch from '@components/Switch';
import Text from '@components/Text';
import ViolationMessages from '@components/ViolationMessages';
import useEnvironment from '@hooks/useEnvironment';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePermissions from '@hooks/usePermissions';
Expand Down Expand Up @@ -99,6 +101,8 @@ function MoneyRequestView({
const session = useSession();
const {isOffline} = useNetwork();
const {translate, toLocaleDigit} = useLocalize();
const {isProduction} = useEnvironment();

const parentReportAction = parentReportActions?.[report.parentReportActionID ?? ''] ?? null;
const isTrackExpense = ReportUtils.isTrackExpenseReport(report);
const {canUseViolations, canUseP2PDistanceRequests} = usePermissions(isTrackExpense ? CONST.IOU.TYPE.TRACK : undefined);
Expand Down Expand Up @@ -171,6 +175,15 @@ function MoneyRequestView({
const shouldShowBillable = isPolicyExpenseChat && (!!transactionBillable || !(policy?.disabledFields?.defaultBillable ?? true));

const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest);
const shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction);
const tripID = ReportUtils.getTripIDFromTransactionParentReport(parentReport);

const navigateToTripID = () => {
if (!tripID) {
return;
}
Linking.openURL(CONST.TRIP_ID_URL(tripID, isProduction));
};

const {getViolationsForField} = useViolations(transactionViolations ?? []);
const hasViolations = useCallback(
Expand Down Expand Up @@ -549,6 +562,15 @@ function MoneyRequestView({
/>
</OfflineWithFeedback>
)}
{shouldShowViewTripDetails && tripID && (
Copy link
Contributor

Choose a reason for hiding this comment

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

if we need tripID to Show the Trip Details, should we include && tripID in shouldShowViewTripDetails declaration

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah that makes sense

<MenuItem
title="View trip details"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add this to translate

Copy link
Member Author

Choose a reason for hiding this comment

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

nice catch

icon={Expensicons.Suitcase}
iconRight={Expensicons.NewWindow}
shouldShowRightIcon
onPress={navigateToTripID}
/>
)}
{shouldShowBillable && (
<View style={[styles.flexRow, styles.optionRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8]}>
<View>
Expand Down
5 changes: 5 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6638,6 +6638,10 @@ function getTripTransactions(tripRoomReportID: string | undefined): Transaction[
return tripTransactionReportIDs.flatMap((reportID) => TransactionUtils.getAllReportTransactions(reportID));
}

function getTripIDFromTransactionParentReport(transactionParentReport: OnyxEntry<Report> | undefined | null): string | undefined {
return getReport(transactionParentReport?.parentReportID)?.tripData?.tripID;
}

/**
* Checks if report contains actions with errors
*/
Expand Down Expand Up @@ -7075,6 +7079,7 @@ export {
updateReportPreview,
temporary_getMoneyRequestOptions,
getTripTransactions,
getTripIDFromTransactionParentReport,
buildOptimisticInvoiceReport,
getInvoiceChatByParticipants,
shouldShowMerchantColumn,
Expand Down
7 changes: 7 additions & 0 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
fieldList?: Record<string, PolicyReportField>;

permissions?: Array<ValueOf<typeof CONST.REPORT.PERMISSIONS>>;

/** The trip data for a trip room */
tripData?: {
startDate: string;
endDate: string;
tripID: string;
};
},
PolicyReportField['fieldID']
>;
Expand Down
Loading