From 03af563416663b39f6c6fae4551f9b51a6db8939 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:18:40 +0300 Subject: [PATCH 01/36] add trip data type --- src/types/onyx/Report.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index e388ce2cd33..f6eb9f70464 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -203,6 +203,13 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< fieldList?: Record; permissions?: Array>; + + /** The trip data for a trip room */ + tripData?: { + startDate: string; + endDate: string; + tripId: string; + }; }, PolicyReportField['fieldID'] >; From 5b0fd9266bd20c0649c0121e805dbfd5412b7ce4 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:19:01 +0300 Subject: [PATCH 02/36] get trip id from transaction --- src/libs/ReportUtils.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index d82fb224784..c5c57f1cb62 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6638,6 +6638,10 @@ function getTripTransactions(tripRoomReportID: string | undefined): Transaction[ return tripTransactionReportIDs.flatMap((reportID) => TransactionUtils.getAllReportTransactions(reportID)); } +function getTripIDFromTransactionParentReport(transactionParentReport: OnyxEntry | undefined | null): string | undefined { + return getReport(transactionParentReport?.parentReportID)?.tripData?.tripId; +} + /** * Checks if report contains actions with errors */ @@ -7075,6 +7079,7 @@ export { updateReportPreview, temporary_getMoneyRequestOptions, getTripTransactions, + getTripIDFromTransactionParentReport, buildOptimisticInvoiceReport, getInvoiceChatByParticipants, shouldShowMerchantColumn, From b2d1aa3152d02b142b6e7bf9dad451be2d4df40b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:19:19 +0300 Subject: [PATCH 03/36] get trip id and should show trip details view --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 2987638c759..c24617676f9 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -171,6 +171,8 @@ 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 {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback( From d2f6dad16a67e05d4467d6df5da4e2d973007be1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:27:29 +0300 Subject: [PATCH 04/36] add menu item for trip details --- src/components/ReportActionItem/MoneyRequestView.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index c24617676f9..626b46e8d14 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -4,6 +4,7 @@ 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'; @@ -551,6 +552,13 @@ function MoneyRequestView({ /> )} + {shouldShowViewTripDetails && ( + + )} {shouldShowBillable && ( From 285135379e68e0eb704e2936f691b5468ac41f7c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:27:39 +0300 Subject: [PATCH 05/36] add luggage icon --- src/components/ReportActionItem/MoneyRequestView.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 626b46e8d14..ca0faa4af49 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -555,6 +555,7 @@ function MoneyRequestView({ {shouldShowViewTripDetails && ( From c4f451267037bc8a58adcd47efefe7dbe59ea07b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:28:16 +0300 Subject: [PATCH 06/36] add suitcase icon --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index ca0faa4af49..2cc00e32aab 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -555,7 +555,7 @@ function MoneyRequestView({ {shouldShowViewTripDetails && ( From a408b6667a7f94fe3dc51e20a0e7075ed7a169b3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:37:52 +0300 Subject: [PATCH 07/36] fix type tripid --- src/types/onyx/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index f6eb9f70464..2c45156f40e 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -208,7 +208,7 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< tripData?: { startDate: string; endDate: string; - tripId: string; + tripID: string; }; }, PolicyReportField['fieldID'] From fb7fdec2d4f9027ebbc296acdbc443100ef7be36 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:38:06 +0300 Subject: [PATCH 08/36] fix type tripid --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c5c57f1cb62..4df0939db0b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6639,7 +6639,7 @@ function getTripTransactions(tripRoomReportID: string | undefined): Transaction[ } function getTripIDFromTransactionParentReport(transactionParentReport: OnyxEntry | undefined | null): string | undefined { - return getReport(transactionParentReport?.parentReportID)?.tripData?.tripId; + return getReport(transactionParentReport?.parentReportID)?.tripData?.tripID; } /** From 68ba31dbfd87f3ce4a51bfefb1799b7b8159c266 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:42:08 +0300 Subject: [PATCH 09/36] add trip id url --- src/CONST.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.ts b/src/CONST.ts index bc8f627630a..634e750bf0e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -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) => `https://travel.expensify.com/trips/${tripID}`, SCREEN_READER_STATES: { ALL: 'all', ACTIVE: 'active', From 09af1940a5d7147dedfaa5d46decac86d6deb932 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:42:26 +0300 Subject: [PATCH 10/36] navigate to trip id url --- src/components/ReportActionItem/MoneyRequestView.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 2cc00e32aab..62033c7ea3c 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -1,5 +1,5 @@ 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'; @@ -175,6 +175,13 @@ function MoneyRequestView({ const shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction); const tripID = ReportUtils.getTripIDFromTransactionParentReport(parentReport); + const navigateToTripID = () => { + if (!tripID) { + return; + } + Linking.openURL(CONST.TRIP_ID_URL(tripID)); + }; + const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback( (field: ViolationField, data?: OnyxTypes.TransactionViolation['data']): boolean => !!canUseViolations && getViolationsForField(field, data).length > 0, @@ -552,12 +559,13 @@ function MoneyRequestView({ /> )} - {shouldShowViewTripDetails && ( + {shouldShowViewTripDetails && tripID && ( )} {shouldShowBillable && ( From 69cf344a59178eb4b58414150066dbd5cde45622 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 5 Jun 2024 01:47:53 +0300 Subject: [PATCH 11/36] handle staging url --- src/CONST.ts | 2 +- src/components/ReportActionItem/MoneyRequestView.tsx | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 634e750bf0e..cfa5e52b57e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3306,7 +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) => `https://travel.expensify.com/trips/${tripID}`, + TRIP_ID_URL: (tripID: string, isProduction: boolean) => (isProduction ? `https://travel.expensify.com/trips/${tripID}` : `https://staging.travel.expensify.com/trips/${tripID}`), SCREEN_READER_STATES: { ALL: 'all', ACTIVE: 'active', diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 62033c7ea3c..1a6b3742bb4 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -13,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'; @@ -100,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); @@ -179,7 +182,7 @@ function MoneyRequestView({ if (!tripID) { return; } - Linking.openURL(CONST.TRIP_ID_URL(tripID)); + Linking.openURL(CONST.TRIP_ID_URL(tripID, isProduction)); }; const {getViolationsForField} = useViolations(transactionViolations ?? []); From d0bc4fed3a434a7641f6f584aa1431467bb3890a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 7 Jun 2024 03:19:17 +0300 Subject: [PATCH 12/36] use translate --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- src/languages/en.ts | 1 + src/languages/es.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 1a6b3742bb4..04fc6aeddee 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -564,7 +564,7 @@ function MoneyRequestView({ )} {shouldShowViewTripDetails && tripID && ( Date: Fri, 7 Jun 2024 03:22:01 +0300 Subject: [PATCH 13/36] simplify --- src/components/ReportActionItem/MoneyRequestView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 04fc6aeddee..0ae9289e657 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -175,8 +175,8 @@ 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 shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction) && tripID; const navigateToTripID = () => { if (!tripID) { @@ -562,7 +562,7 @@ function MoneyRequestView({ /> )} - {shouldShowViewTripDetails && tripID && ( + {shouldShowViewTripDetails && ( Date: Fri, 7 Jun 2024 03:27:15 +0300 Subject: [PATCH 14/36] simplify travel const --- src/CONST.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index cfa5e52b57e..8d77aa2eecf 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4,6 +4,7 @@ import dateSubtract from 'date-fns/sub'; import Config from 'react-native-config'; import * as KeyCommand from 'react-native-key-command'; import type {ValueOf} from 'type-fest'; +import {isProduction} from '@libs/Environment/Environment'; import BankAccount from './libs/models/BankAccount'; import * as Url from './libs/Url'; import SCREENS from './SCREENS'; @@ -3306,7 +3307,8 @@ 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}`), + TRAVEL_DOT_URL: (isProduction: boolean) => (isProduction ? 'https://travel.expensify.com' : 'https://staging.travel.expensify.com'), + TRIP_ID_URL: (tripID: string, isProduction: boolean) => `${CONST.TRAVEL_DOT_URL(isProduction)}/trips/${tripID}`, SCREEN_READER_STATES: { ALL: 'all', ACTIVE: 'active', From 61e22e07bbe8c6f726d2fd56321354f53cfbf669 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 21:15:18 +0300 Subject: [PATCH 15/36] rm import --- src/CONST.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index 37bda26a374..26cd1d33f35 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4,7 +4,6 @@ import dateSubtract from 'date-fns/sub'; import Config from 'react-native-config'; import * as KeyCommand from 'react-native-key-command'; import type {ValueOf} from 'type-fest'; -import {isProduction} from '@libs/Environment/Environment'; import BankAccount from './libs/models/BankAccount'; import * as Url from './libs/Url'; import SCREENS from './SCREENS'; From 750856b039bcbe85bfa62a7087101c67c7cc83b2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 21:34:17 +0300 Subject: [PATCH 16/36] add generate spotnana command param type --- src/libs/API/parameters/GenerateSpotnanaTokenParams.ts | 5 +++++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 ++ src/libs/actions/Link.ts | 4 ++++ 4 files changed, 12 insertions(+) create mode 100644 src/libs/API/parameters/GenerateSpotnanaTokenParams.ts diff --git a/src/libs/API/parameters/GenerateSpotnanaTokenParams.ts b/src/libs/API/parameters/GenerateSpotnanaTokenParams.ts new file mode 100644 index 00000000000..bc67e919750 --- /dev/null +++ b/src/libs/API/parameters/GenerateSpotnanaTokenParams.ts @@ -0,0 +1,5 @@ +type GenerateSpotnanaTokenParams = { + policyID: string; +}; + +export default GenerateSpotnanaTokenParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index b853f134b31..5e81ef3e6ef 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -225,3 +225,4 @@ export type {default as SendInvoiceParams} from './SendInvoiceParams'; export type {default as PayInvoiceParams} from './PayInvoiceParams'; export type {default as MarkAsCashParams} from './MarkAsCashParams'; export type {default as SignUpUserParams} from './SignUpUserParams'; +export type {default as GenerateSpotnanaTokenParams} from './GenerateSpotnanaTokenParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 6b34e04e193..ef978ad7d4d 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -548,6 +548,7 @@ const SIDE_EFFECT_REQUEST_COMMANDS = { GET_MISSING_ONYX_MESSAGES: 'GetMissingOnyxMessages', JOIN_POLICY_VIA_INVITE_LINK: 'JoinWorkspaceViaInviteLink', RECONNECT_APP: 'ReconnectApp', + GENERATE_SPOTNANA_TOKEN: 'GenerateSpotnanaToken', } as const; type SideEffectRequestCommand = ValueOf; @@ -560,6 +561,7 @@ type SideEffectRequestCommandParameters = { [SIDE_EFFECT_REQUEST_COMMANDS.GET_MISSING_ONYX_MESSAGES]: Parameters.GetMissingOnyxMessagesParams; [SIDE_EFFECT_REQUEST_COMMANDS.JOIN_POLICY_VIA_INVITE_LINK]: Parameters.JoinPolicyInviteLinkParams; [SIDE_EFFECT_REQUEST_COMMANDS.RECONNECT_APP]: Parameters.ReconnectAppParams; + [SIDE_EFFECT_REQUEST_COMMANDS.GENERATE_SPOTNANA_TOKEN]: Parameters.GenerateSpotnanaTokenParams; }; type ApiRequestCommandParameters = WriteCommandParameters & ReadCommandParameters & SideEffectRequestCommandParameters; diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index c83c946aed4..f2997187828 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -64,6 +64,10 @@ function openOldDotLink(url: string) { ); } +function openTravelDotLink(policyID: string) { + API.makeRequestWithSideEffects() +} + function getInternalNewExpensifyPath(href: string) { const attrPath = Url.getPathFromURL(href); return (Url.hasSameExpensifyOrigin(href, CONST.NEW_EXPENSIFY_URL) || Url.hasSameExpensifyOrigin(href, CONST.STAGING_NEW_EXPENSIFY_URL) || href.startsWith(CONST.DEV_NEW_EXPENSIFY_URL)) && From 8ad2e06f19a0d93b51c1f7abd7f56d8f14c07250 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 22:06:46 +0300 Subject: [PATCH 17/36] add tmc id spotnananananananna --- src/CONST.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.ts b/src/CONST.ts index 26cd1d33f35..fca984de495 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3309,6 +3309,7 @@ const CONST = { BOOK_TRAVEL_DEMO_URL: 'https://calendly.com/d/ck2z-xsh-q97/expensify-travel-demo-travel-page', TRAVEL_DOT_URL: (isProduction: boolean) => (isProduction ? 'https://travel.expensify.com' : 'https://staging.travel.expensify.com'), TRIP_ID_URL: (tripID: string, isProduction: boolean) => `${CONST.TRAVEL_DOT_URL(isProduction)}/trips/${tripID}`, + SPOTNANA_TMC_ID: '7a290c6e-5328-4107-aff6-e48765845b81', SCREEN_READER_STATES: { ALL: 'all', ACTIVE: 'active', From 407b93a74c4dc3d3ffeaab13b84878f94cf16c1b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 22:07:28 +0300 Subject: [PATCH 18/36] add spotnana token in api response --- src/types/onyx/Response.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/onyx/Response.ts b/src/types/onyx/Response.ts index aa060223637..c2628065225 100644 --- a/src/types/onyx/Response.ts +++ b/src/types/onyx/Response.ts @@ -56,6 +56,9 @@ type Response = { /** Short lived auth token generated by API */ shortLivedAuthToken?: string; + /** Short lived token generated by spotnana for authenticating travelDot */ + spotnanaToken?: string; + /** User authorization token to authorize Pusher connections */ auth?: string; From 53e65c929db31173c5f80ba0dbadb9901dc8b23a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 22:08:01 +0300 Subject: [PATCH 19/36] get travel dot from env --- src/libs/Environment/Environment.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libs/Environment/Environment.ts b/src/libs/Environment/Environment.ts index 204e78aa545..a862c4bc0f4 100644 --- a/src/libs/Environment/Environment.ts +++ b/src/libs/Environment/Environment.ts @@ -17,6 +17,13 @@ const OLDDOT_ENVIRONMENT_URLS = { [CONST.ENVIRONMENT.ADHOC]: CONST.STAGING_EXPENSIFY_URL, }; +const TRAVELDOT_ENVIRONMENT_URLS = { + [CONST.ENVIRONMENT.DEV]: CONST.TRAVEL_DOT_URL(false), + [CONST.ENVIRONMENT.STAGING]: CONST.TRAVEL_DOT_URL(false), + [CONST.ENVIRONMENT.PRODUCTION]: CONST.TRAVEL_DOT_URL(true), + [CONST.ENVIRONMENT.ADHOC]: CONST.TRAVEL_DOT_URL(false), +}; + /** * Are we running the app in development? */ @@ -54,4 +61,8 @@ function getOldDotEnvironmentURL(): Promise { return getEnvironment().then((environment) => OLDDOT_ENVIRONMENT_URLS[environment]); } -export {getEnvironment, isInternalTestBuild, isDevelopment, isProduction, getEnvironmentURL, getOldDotEnvironmentURL}; +function getTravelDotEnvironmentURL(): Promise { + return getEnvironment().then((environment) => TRAVELDOT_ENVIRONMENT_URLS[environment]); +} + +export {getEnvironment, isInternalTestBuild, isDevelopment, isProduction, getEnvironmentURL, getOldDotEnvironmentURL, getTravelDotEnvironmentURL}; From 05a9cc65ae0d81ea369008c49b1071cbf4ee5fc7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 22:08:18 +0300 Subject: [PATCH 20/36] build travel dot url --- src/libs/actions/Link.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index f2997187828..61fa66c9f4b 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -1,5 +1,6 @@ import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; +import type {GenerateSpotnanaTokenParams} from '@libs/API/parameters'; import {SIDE_EFFECT_REQUEST_COMMANDS} from '@libs/API/types'; import asyncOpenURL from '@libs/asyncOpenURL'; import * as Environment from '@libs/Environment/Environment'; @@ -64,8 +65,24 @@ function openOldDotLink(url: string) { ); } +function buildTravelDotURL(spotnanaToken: string): Promise { + return Environment.getTravelDotEnvironmentURL().then((environmentURL) => { + const travelDotDomain = Url.addTrailingForwardSlash(environmentURL); + return `${travelDotDomain}auth/code?authCode=${spotnanaToken}&tmcId=${CONST.SPOTNANA_TMC_ID}`; + }); +} + function openTravelDotLink(policyID: string) { - API.makeRequestWithSideEffects() + const parameters: GenerateSpotnanaTokenParams = { + policyID, + }; + asyncOpenURL( + // eslint-disable-next-line rulesdir/no-api-side-effects-method + API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.GENERATE_SPOTNANA_TOKEN, parameters, {}).then( + (response) => response.spotnanaToken && buildTravelDotURL(response.spotnanaToken), + ), + (travelDotURL) => travelDotURL, + ); } function getInternalNewExpensifyPath(href: string) { @@ -125,4 +142,4 @@ function openLink(href: string, environmentURL: string, isAttachment = false) { openExternalLink(href); } -export {buildOldDotURL, openOldDotLink, openExternalLink, openLink, getInternalNewExpensifyPath, getInternalExpensifyPath}; +export {buildOldDotURL, openOldDotLink, openExternalLink, openLink, getInternalNewExpensifyPath, getInternalExpensifyPath, openTravelDotLink}; From c0950833b988c3f1e0b710ee20cc470d37c28d7e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 22:16:01 +0300 Subject: [PATCH 21/36] make spotnana token optional --- src/libs/actions/Link.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 61fa66c9f4b..bbdccd76a87 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -65,10 +65,11 @@ function openOldDotLink(url: string) { ); } -function buildTravelDotURL(spotnanaToken: string): Promise { +function buildTravelDotURL(spotnanaToken?: string): Promise { + const authCode = spotnanaToken ? `authCode=${spotnanaToken}` : ''; return Environment.getTravelDotEnvironmentURL().then((environmentURL) => { const travelDotDomain = Url.addTrailingForwardSlash(environmentURL); - return `${travelDotDomain}auth/code?authCode=${spotnanaToken}&tmcId=${CONST.SPOTNANA_TMC_ID}`; + return `${travelDotDomain}auth/code?${authCode}&tmcId=${CONST.SPOTNANA_TMC_ID}`; }); } @@ -78,9 +79,9 @@ function openTravelDotLink(policyID: string) { }; asyncOpenURL( // eslint-disable-next-line rulesdir/no-api-side-effects-method - API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.GENERATE_SPOTNANA_TOKEN, parameters, {}).then( - (response) => response.spotnanaToken && buildTravelDotURL(response.spotnanaToken), - ), + API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.GENERATE_SPOTNANA_TOKEN, parameters, {}) + .then((response) => (response?.spotnanaToken ? buildTravelDotURL(response.spotnanaToken) : buildTravelDotURL())) + .catch(() => buildTravelDotURL()), (travelDotURL) => travelDotURL, ); } From 5ee49dd304782e4f48a730389da4a3fb88165cb8 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 22:23:03 +0300 Subject: [PATCH 22/36] add postlogin url --- src/libs/actions/Link.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index bbdccd76a87..0e6fb742255 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -65,22 +65,29 @@ function openOldDotLink(url: string) { ); } -function buildTravelDotURL(spotnanaToken?: string): Promise { +function buildTravelDotURL(spotnanaToken?: string, postLoginURL?: string): Promise { const authCode = spotnanaToken ? `authCode=${spotnanaToken}` : ''; + const tmcID = `tmcId=${CONST.SPOTNANA_TMC_ID}`; + const redirectURL = postLoginURL ? `redirectUrl=${postLoginURL}` : ''; + + const paramsArray = [authCode, tmcID, redirectURL]; + const params = paramsArray.filter(Boolean).join('&'); + return Environment.getTravelDotEnvironmentURL().then((environmentURL) => { const travelDotDomain = Url.addTrailingForwardSlash(environmentURL); - return `${travelDotDomain}auth/code?${authCode}&tmcId=${CONST.SPOTNANA_TMC_ID}`; + return `${travelDotDomain}auth/code?${params}`; }); } -function openTravelDotLink(policyID: string) { +function openTravelDotLink(policyID: string, postLoginURL?: string) { const parameters: GenerateSpotnanaTokenParams = { policyID, }; + asyncOpenURL( // eslint-disable-next-line rulesdir/no-api-side-effects-method API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.GENERATE_SPOTNANA_TOKEN, parameters, {}) - .then((response) => (response?.spotnanaToken ? buildTravelDotURL(response.spotnanaToken) : buildTravelDotURL())) + .then((response) => (response?.spotnanaToken ? buildTravelDotURL(response.spotnanaToken, postLoginURL) : buildTravelDotURL())) .catch(() => buildTravelDotURL()), (travelDotURL) => travelDotURL, ); From 25400ac7ceef9c6a39f4fcd166cc99302698c73a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 22:23:27 +0300 Subject: [PATCH 23/36] get rid of env --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 9b1a3f84bae..d995865ead6 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -12,7 +12,6 @@ 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'; @@ -100,7 +99,6 @@ 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); From 0f17458ccb118bb6aceb09c928aab6a8e4b480ef Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 22:32:32 +0300 Subject: [PATCH 24/36] add early return and add login url for trip id --- src/CONST.ts | 2 +- .../ReportActionItem/MoneyRequestView.tsx | 15 +++++---------- src/libs/actions/Link.ts | 7 ++++++- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index fca984de495..b48f0f6db91 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3308,7 +3308,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', TRAVEL_DOT_URL: (isProduction: boolean) => (isProduction ? 'https://travel.expensify.com' : 'https://staging.travel.expensify.com'), - TRIP_ID_URL: (tripID: string, isProduction: boolean) => `${CONST.TRAVEL_DOT_URL(isProduction)}/trips/${tripID}`, + TRIP_ID_PATH: (tripID: string) => `trips/${tripID}`, SPOTNANA_TMC_ID: '7a290c6e-5328-4107-aff6-e48765845b81', SCREEN_READER_STATES: { ALL: 'all', diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index d995865ead6..7c6ac9f4c3e 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -1,6 +1,6 @@ import React, {useCallback, useMemo} from 'react'; -import {Linking, View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; +import {View} from 'react-native'; +import {useOnyx, withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; @@ -34,6 +34,7 @@ import ViolationsUtils from '@libs/Violations/ViolationsUtils'; import Navigation from '@navigation/Navigation'; import AnimatedEmptyStateBackground from '@pages/home/report/AnimatedEmptyStateBackground'; import * as IOU from '@userActions/IOU'; +import * as Link from '@userActions/Link'; import * as Transaction from '@userActions/Transaction'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; @@ -99,6 +100,7 @@ function MoneyRequestView({ const session = useSession(); const {isOffline} = useNetwork(); const {translate, toLocaleDigit} = useLocalize(); + const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID); const parentReportAction = parentReportActions?.[report.parentReportActionID ?? ''] ?? null; const isTrackExpense = ReportUtils.isTrackExpenseReport(report); @@ -173,13 +175,6 @@ function MoneyRequestView({ const tripID = ReportUtils.getTripIDFromTransactionParentReport(parentReport); const shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction) && tripID; - const navigateToTripID = () => { - if (!tripID) { - return; - } - Linking.openURL(CONST.TRIP_ID_URL(tripID, isProduction)); - }; - const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback( (field: ViolationField, data?: OnyxTypes.TransactionViolation['data']): boolean => !!canUseViolations && getViolationsForField(field, data).length > 0, @@ -555,7 +550,7 @@ function MoneyRequestView({ icon={Expensicons.Suitcase} iconRight={Expensicons.NewWindow} shouldShowRightIcon - onPress={navigateToTripID} + onPress={() => Link.openTravelDotLink(activePolicyID, CONST.TRIP_ID_PATH(tripID))} /> )} {shouldShowBillable && ( diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 0e6fb742255..24c5d0be827 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -1,4 +1,5 @@ import Onyx from 'react-native-onyx'; +import type {OnyxEntry} from 'react-native-onyx'; import * as API from '@libs/API'; import type {GenerateSpotnanaTokenParams} from '@libs/API/parameters'; import {SIDE_EFFECT_REQUEST_COMMANDS} from '@libs/API/types'; @@ -79,7 +80,11 @@ function buildTravelDotURL(spotnanaToken?: string, postLoginURL?: string): Promi }); } -function openTravelDotLink(policyID: string, postLoginURL?: string) { +function openTravelDotLink(policyID: OnyxEntry, postLoginURL?: string) { + if (policyID === null) { + return; + } + const parameters: GenerateSpotnanaTokenParams = { policyID, }; From 17fba2d657ed4b58f0a28f3fe578a7eb719ff91a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 23:08:10 +0300 Subject: [PATCH 25/36] add docs --- src/types/onyx/Report.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index 6caebc1b05f..9b0b35a6da7 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -277,8 +277,13 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** The trip data for a trip room */ tripData?: { + /** The start date of a trip */ startDate: string; + + /** The end date of a trip */ endDate: string; + + /** The trip ID in spotnana */ tripID: string; }; }, From deb01aa09f77ac67587a2e22dada43b65720324c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 23:10:35 +0300 Subject: [PATCH 26/36] add docs --- src/libs/actions/Link.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 24c5d0be827..07c94a7c4fc 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -80,6 +80,9 @@ function buildTravelDotURL(spotnanaToken?: string, postLoginURL?: string): Promi }); } +/** + * @param postLoginURL When provided, we will redirect the user to this url post login on travelDot. + */ function openTravelDotLink(policyID: OnyxEntry, postLoginURL?: string) { if (policyID === null) { return; From 57da999ca732e2d6b989e7985a3be0c76b17bb2d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 23:13:14 +0300 Subject: [PATCH 27/36] rm dependency of env for travel url --- src/CONST.ts | 3 ++- src/libs/Environment/Environment.ts | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index b48f0f6db91..c06760216a5 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3307,7 +3307,8 @@ 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', - TRAVEL_DOT_URL: (isProduction: boolean) => (isProduction ? 'https://travel.expensify.com' : 'https://staging.travel.expensify.com'), + TRAVEL_DOT_URL: 'https://travel.expensify.com', + STAGING_TRAVEL_DOT_URL: 'https://staging.travel.expensify.com', TRIP_ID_PATH: (tripID: string) => `trips/${tripID}`, SPOTNANA_TMC_ID: '7a290c6e-5328-4107-aff6-e48765845b81', SCREEN_READER_STATES: { diff --git a/src/libs/Environment/Environment.ts b/src/libs/Environment/Environment.ts index a862c4bc0f4..e7fa66e3743 100644 --- a/src/libs/Environment/Environment.ts +++ b/src/libs/Environment/Environment.ts @@ -18,10 +18,10 @@ const OLDDOT_ENVIRONMENT_URLS = { }; const TRAVELDOT_ENVIRONMENT_URLS = { - [CONST.ENVIRONMENT.DEV]: CONST.TRAVEL_DOT_URL(false), - [CONST.ENVIRONMENT.STAGING]: CONST.TRAVEL_DOT_URL(false), - [CONST.ENVIRONMENT.PRODUCTION]: CONST.TRAVEL_DOT_URL(true), - [CONST.ENVIRONMENT.ADHOC]: CONST.TRAVEL_DOT_URL(false), + [CONST.ENVIRONMENT.DEV]: CONST.STAGING_TRAVEL_DOT_URL, + [CONST.ENVIRONMENT.STAGING]: CONST.STAGING_TRAVEL_DOT_URL, + [CONST.ENVIRONMENT.PRODUCTION]: CONST.TRAVEL_DOT_URL, + [CONST.ENVIRONMENT.ADHOC]: CONST.STAGING_TRAVEL_DOT_URL, }; /** From 99569002e225ce596ab805206474e85ec52caa09 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 9 Jun 2024 23:16:13 +0300 Subject: [PATCH 28/36] rename to path for clarity --- src/libs/actions/Link.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 07c94a7c4fc..6104982da41 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -66,10 +66,10 @@ function openOldDotLink(url: string) { ); } -function buildTravelDotURL(spotnanaToken?: string, postLoginURL?: string): Promise { +function buildTravelDotURL(spotnanaToken?: string, postLoginPath?: string): Promise { const authCode = spotnanaToken ? `authCode=${spotnanaToken}` : ''; const tmcID = `tmcId=${CONST.SPOTNANA_TMC_ID}`; - const redirectURL = postLoginURL ? `redirectUrl=${postLoginURL}` : ''; + const redirectURL = postLoginPath ? `redirectUrl=${postLoginPath}` : ''; const paramsArray = [authCode, tmcID, redirectURL]; const params = paramsArray.filter(Boolean).join('&'); @@ -81,9 +81,9 @@ function buildTravelDotURL(spotnanaToken?: string, postLoginURL?: string): Promi } /** - * @param postLoginURL When provided, we will redirect the user to this url post login on travelDot. + * @param postLoginPath When provided, we will redirect the user to this path post login on travelDot. eg: 'trips/:tripID' */ -function openTravelDotLink(policyID: OnyxEntry, postLoginURL?: string) { +function openTravelDotLink(policyID: OnyxEntry, postLoginPath?: string) { if (policyID === null) { return; } @@ -95,7 +95,7 @@ function openTravelDotLink(policyID: OnyxEntry, postLoginURL?: string) { asyncOpenURL( // eslint-disable-next-line rulesdir/no-api-side-effects-method API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.GENERATE_SPOTNANA_TOKEN, parameters, {}) - .then((response) => (response?.spotnanaToken ? buildTravelDotURL(response.spotnanaToken, postLoginURL) : buildTravelDotURL())) + .then((response) => (response?.spotnanaToken ? buildTravelDotURL(response.spotnanaToken, postLoginPath) : buildTravelDotURL())) .catch(() => buildTravelDotURL()), (travelDotURL) => travelDotURL, ); From e15858ee9ae2517cbc0d29bd666f6e33da07a25b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 10 Jun 2024 16:58:39 +0300 Subject: [PATCH 29/36] Update MoneyRequestView.tsx --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 7c6ac9f4c3e..4edacfffea5 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -173,7 +173,7 @@ function MoneyRequestView({ const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest); const tripID = ReportUtils.getTripIDFromTransactionParentReport(parentReport); - const shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction) && tripID; + const shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction) && Boolean(tripID); const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback( From a6d48f2aa223a6d1aeb24ed03b0317568a3391d4 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 10 Jun 2024 17:20:02 +0300 Subject: [PATCH 30/36] Apply suggestions from code review --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 4edacfffea5..4c721b950fe 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -173,7 +173,7 @@ function MoneyRequestView({ const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest); const tripID = ReportUtils.getTripIDFromTransactionParentReport(parentReport); - const shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction) && Boolean(tripID); + const shouldShowViewTripDetails = TransactionUtils.hasReservationList(transaction) && !!tripID; const {getViolationsForField} = useViolations(transactionViolations ?? []); const hasViolations = useCallback( From f0d4fd880aaf33b98e59106a3e11b63cb99d55f1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 10 Jun 2024 18:44:50 +0300 Subject: [PATCH 31/36] add prod tmc id --- src/CONST.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index c06760216a5..10eb6dd7bd0 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3310,7 +3310,8 @@ const CONST = { TRAVEL_DOT_URL: 'https://travel.expensify.com', STAGING_TRAVEL_DOT_URL: 'https://staging.travel.expensify.com', TRIP_ID_PATH: (tripID: string) => `trips/${tripID}`, - SPOTNANA_TMC_ID: '7a290c6e-5328-4107-aff6-e48765845b81', + SPOTNANA_TMC_ID: '8e8e7258-1cf3-48c0-9cd1-fe78a6e31eed', + STAGING_SPOTNANA_TMC_ID: '7a290c6e-5328-4107-aff6-e48765845b81', SCREEN_READER_STATES: { ALL: 'all', ACTIVE: 'active', From dae0dd4e0d27bf92a78b8b02aa2a9df706531a76 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 10 Jun 2024 18:45:13 +0300 Subject: [PATCH 32/36] tmc id as per environment --- src/libs/Environment/Environment.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libs/Environment/Environment.ts b/src/libs/Environment/Environment.ts index e7fa66e3743..541243edf6b 100644 --- a/src/libs/Environment/Environment.ts +++ b/src/libs/Environment/Environment.ts @@ -24,6 +24,13 @@ const TRAVELDOT_ENVIRONMENT_URLS = { [CONST.ENVIRONMENT.ADHOC]: CONST.STAGING_TRAVEL_DOT_URL, }; +const SPOTNANA_ENVIRONMENT_TMC_ID = { + [CONST.ENVIRONMENT.DEV]: CONST.STAGING_SPOTNANA_TMC_ID, + [CONST.ENVIRONMENT.STAGING]: CONST.STAGING_SPOTNANA_TMC_ID, + [CONST.ENVIRONMENT.PRODUCTION]: CONST.SPOTNANA_TMC_ID, + [CONST.ENVIRONMENT.ADHOC]: CONST.STAGING_SPOTNANA_TMC_ID, +}; + /** * Are we running the app in development? */ @@ -65,4 +72,8 @@ function getTravelDotEnvironmentURL(): Promise { return getEnvironment().then((environment) => TRAVELDOT_ENVIRONMENT_URLS[environment]); } -export {getEnvironment, isInternalTestBuild, isDevelopment, isProduction, getEnvironmentURL, getOldDotEnvironmentURL, getTravelDotEnvironmentURL}; +function getSpotnanaEnvironmentTMCID(): Promise { + return getEnvironment().then((environment) => SPOTNANA_ENVIRONMENT_TMC_ID[environment]); +} + +export {getEnvironment, isInternalTestBuild, isDevelopment, isProduction, getEnvironmentURL, getOldDotEnvironmentURL, getTravelDotEnvironmentURL, getSpotnanaEnvironmentTMCID}; From 938b60e91b486c0ef1d816ea66e8905ac5c595c8 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 10 Jun 2024 18:45:36 +0300 Subject: [PATCH 33/36] get tmc id as per env for spotnana --- src/libs/actions/Link.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 6104982da41..4bc0a61162a 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -67,14 +67,13 @@ function openOldDotLink(url: string) { } function buildTravelDotURL(spotnanaToken?: string, postLoginPath?: string): Promise { - const authCode = spotnanaToken ? `authCode=${spotnanaToken}` : ''; - const tmcID = `tmcId=${CONST.SPOTNANA_TMC_ID}`; - const redirectURL = postLoginPath ? `redirectUrl=${postLoginPath}` : ''; + return Promise.all([Environment.getTravelDotEnvironmentURL(), Environment.getSpotnanaEnvironmentTMCID()]).then(([environmentURL, tmcID]) => { + const authCode = spotnanaToken ? `authCode=${spotnanaToken}` : ''; + const redirectURL = postLoginPath ? `redirectUrl=${postLoginPath}` : ''; + const tmcIDParam = `tmcId=${tmcID}`; - const paramsArray = [authCode, tmcID, redirectURL]; - const params = paramsArray.filter(Boolean).join('&'); - - return Environment.getTravelDotEnvironmentURL().then((environmentURL) => { + const paramsArray = [authCode, tmcIDParam, redirectURL]; + const params = paramsArray.filter(Boolean).join('&'); const travelDotDomain = Url.addTrailingForwardSlash(environmentURL); return `${travelDotDomain}auth/code?${params}`; }); From 6895d38f71a8f46036762b57f05bd4ca84c95537 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 10 Jun 2024 20:32:29 +0300 Subject: [PATCH 34/36] add leading slash if not present to redirect url --- src/libs/Url.ts | 9 ++++++++- src/libs/actions/Link.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libs/Url.ts b/src/libs/Url.ts index 69894147a24..970e6b3ed19 100644 --- a/src/libs/Url.ts +++ b/src/libs/Url.ts @@ -11,6 +11,13 @@ function addTrailingForwardSlash(url: string): string { return url; } +function addLeadingForwardSlash(url: string): string { + if (!url.startsWith('/')) { + return `/${url}`; + } + return url; +} + /** * Get path from URL string */ @@ -63,4 +70,4 @@ function hasURL(text: string) { return urlPattern.test(text); } -export {addTrailingForwardSlash, hasSameExpensifyOrigin, getPathFromURL, appendParam, hasURL}; +export {addTrailingForwardSlash, hasSameExpensifyOrigin, getPathFromURL, appendParam, hasURL, addLeadingForwardSlash}; diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 4bc0a61162a..4b1261dc087 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -69,7 +69,7 @@ function openOldDotLink(url: string) { function buildTravelDotURL(spotnanaToken?: string, postLoginPath?: string): Promise { return Promise.all([Environment.getTravelDotEnvironmentURL(), Environment.getSpotnanaEnvironmentTMCID()]).then(([environmentURL, tmcID]) => { const authCode = spotnanaToken ? `authCode=${spotnanaToken}` : ''; - const redirectURL = postLoginPath ? `redirectUrl=${postLoginPath}` : ''; + const redirectURL = postLoginPath ? `redirectUrl=${Url.addLeadingForwardSlash(postLoginPath)}` : ''; const tmcIDParam = `tmcId=${tmcID}`; const paramsArray = [authCode, tmcIDParam, redirectURL]; From 2e9d6229dd07d4a17be6decfd5cd2743c3534650 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 11 Jun 2024 17:50:20 +0300 Subject: [PATCH 35/36] Update src/languages/es.ts --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 3635723b597..9c9cec64072 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1951,7 +1951,7 @@ export default { hotel: 'Hotel', car: 'Auto', viewTrip: 'Ver viaje', - viewTripDetails: 'View trip details', + viewTripDetails: 'Ver detalles del viaje', trip: 'Viaje', tripSummary: 'Resumen del viaje', departs: 'Sale', From e48fc99da53ea5e5d5454ed0008ef81c37488a22 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 14 Jun 2024 19:29:11 +0300 Subject: [PATCH 36/36] fix typescript errs --- src/libs/Environment/Environment.ts | 4 ++-- src/libs/actions/Link.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/Environment/Environment.ts b/src/libs/Environment/Environment.ts index 541243edf6b..1f5a391d3b1 100644 --- a/src/libs/Environment/Environment.ts +++ b/src/libs/Environment/Environment.ts @@ -17,14 +17,14 @@ const OLDDOT_ENVIRONMENT_URLS = { [CONST.ENVIRONMENT.ADHOC]: CONST.STAGING_EXPENSIFY_URL, }; -const TRAVELDOT_ENVIRONMENT_URLS = { +const TRAVELDOT_ENVIRONMENT_URLS: Record = { [CONST.ENVIRONMENT.DEV]: CONST.STAGING_TRAVEL_DOT_URL, [CONST.ENVIRONMENT.STAGING]: CONST.STAGING_TRAVEL_DOT_URL, [CONST.ENVIRONMENT.PRODUCTION]: CONST.TRAVEL_DOT_URL, [CONST.ENVIRONMENT.ADHOC]: CONST.STAGING_TRAVEL_DOT_URL, }; -const SPOTNANA_ENVIRONMENT_TMC_ID = { +const SPOTNANA_ENVIRONMENT_TMC_ID: Record = { [CONST.ENVIRONMENT.DEV]: CONST.STAGING_SPOTNANA_TMC_ID, [CONST.ENVIRONMENT.STAGING]: CONST.STAGING_SPOTNANA_TMC_ID, [CONST.ENVIRONMENT.PRODUCTION]: CONST.SPOTNANA_TMC_ID, diff --git a/src/libs/actions/Link.ts b/src/libs/actions/Link.ts index 816ea090729..f97c4e17a9a 100644 --- a/src/libs/actions/Link.ts +++ b/src/libs/actions/Link.ts @@ -83,7 +83,7 @@ function buildTravelDotURL(spotnanaToken?: string, postLoginPath?: string): Prom * @param postLoginPath When provided, we will redirect the user to this path post login on travelDot. eg: 'trips/:tripID' */ function openTravelDotLink(policyID: OnyxEntry, postLoginPath?: string) { - if (policyID === null) { + if (policyID === null || policyID === undefined) { return; }