From 7d069ac3ba095abee5d6a08e7b9230ef943aa63b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 5 May 2024 18:36:15 +0530 Subject: [PATCH 01/65] add new chat type --- src/CONST.ts | 1 + src/components/ReportActionItem/TripDetailsView.tsx | 0 2 files changed, 1 insertion(+) create mode 100644 src/components/ReportActionItem/TripDetailsView.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 566d5179f86a..48e33f0b0f5d 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -50,6 +50,7 @@ const KEYBOARD_SHORTCUT_NAVIGATION_TYPE = 'NAVIGATION_SHORTCUT'; const chatTypes = { POLICY_ANNOUNCE: 'policyAnnounce', POLICY_ADMINS: 'policyAdmins', + POLICY_TRIP_ROOM: 'policyTripRoom', GROUP: 'group', DOMAIN_ALL: 'domainAll', POLICY_ROOM: 'policyRoom', diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx new file mode 100644 index 000000000000..e69de29bb2d1 From 48d51c4984812a3271253eafa0c8798f3a05bf9c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 5 May 2024 18:38:58 +0530 Subject: [PATCH 02/65] add isTripRoom --- src/libs/ReportUtils.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8dd04d168717..d29f66a9ffde 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -879,6 +879,13 @@ function isInvoiceRoom(report: OnyxEntry): boolean { return getChatType(report) === CONST.REPORT.CHAT_TYPE.INVOICE; } +/** + * Checks if a report is a completed task report. + */ +function isTripRoom(report: OnyxEntry): boolean { + return getChatType(report) === CONST.REPORT.CHAT_TYPE.POLICY_TRIP_ROOM; +} + function isCurrentUserInvoiceReceiver(report: OnyxEntry): boolean { if (report?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL) { return currentUserAccountID === report.invoiceReceiver.accountID; @@ -6619,6 +6626,7 @@ export { isCanceledTaskReport, isChatReport, isChatRoom, + isTripRoom, isChatThread, isChildReport, isClosedExpenseReportWithNoExpenses, From 37b5a9d17e9d059b0058f114ccec7c15908502ff Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 5 May 2024 18:40:02 +0530 Subject: [PATCH 03/65] add isTripRoom --- 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 d29f66a9ffde..eeba76346478 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -883,7 +883,7 @@ function isInvoiceRoom(report: OnyxEntry): boolean { * Checks if a report is a completed task report. */ function isTripRoom(report: OnyxEntry): boolean { - return getChatType(report) === CONST.REPORT.CHAT_TYPE.POLICY_TRIP_ROOM; + return isChatReport(report) && getChatType(report) === CONST.REPORT.CHAT_TYPE.POLICY_TRIP_ROOM; } function isCurrentUserInvoiceReceiver(report: OnyxEntry): boolean { From dc2aba95e4e8e159fcdf0da401cb081cba8c6d56 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 5 May 2024 20:17:34 +0530 Subject: [PATCH 04/65] show trip details in report action item --- src/components/ReportActionItem/TripDetailsView.tsx | 7 +++++++ src/pages/home/report/ReportActionItem.tsx | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index e69de29bb2d1..9533436082e4 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -0,0 +1,7 @@ +import {View} from 'react-native'; + +function TripDetailsView() { + return ; +} + +export default TripDetailsView; diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 5697807ca825..8c7170fcc616 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -28,6 +28,7 @@ import ReportPreview from '@components/ReportActionItem/ReportPreview'; import TaskAction from '@components/ReportActionItem/TaskAction'; import TaskPreview from '@components/ReportActionItem/TaskPreview'; import TaskView from '@components/ReportActionItem/TaskView'; +import TripDetailsView from '@components/ReportActionItem/TripDetailsView'; import {ShowContextMenuContext} from '@components/ShowContextMenuContext'; import SpacerView from '@components/SpacerView'; import Text from '@components/Text'; @@ -834,6 +835,15 @@ function ReportActionItem({ ); } + + if (ReportUtils.isTripRoom(report)) { + return ( + + + + ); + } + if (ReportUtils.isExpenseReport(report) || ReportUtils.isIOUReport(report) || ReportUtils.isInvoiceReport(report)) { return ( From 942c06848ca5f39be2c0be55ba4c20f7f2cc7666 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 5 May 2024 20:28:13 +0530 Subject: [PATCH 05/65] pass chatreport id to trip details --- .../ReportActionItem/TripDetailsView.tsx | 19 +++++++++++++++++-- src/pages/home/report/ReportActionItem.tsx | 5 ++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 9533436082e4..9b560a0a037c 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -1,7 +1,22 @@ import {View} from 'react-native'; +import Text from '@components/Text'; -function TripDetailsView() { - return ; +type TripDetailsViewProps = { + /** The active IOUReport, used for Onyx subscription */ + iouReportID?: string; + + /** Whether we should display the horizontal rule below the component */ + shouldShowHorizontalRule: boolean; +}; + +function TripDetailsView({iouReportID, shouldShowHorizontalRule}: TripDetailsViewProps) { + return ( + + + Hello world ${iouReportID} ${shouldShowHorizontalRule} + + + ); } export default TripDetailsView; diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 8c7170fcc616..e4f3b06fd182 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -839,7 +839,10 @@ function ReportActionItem({ if (ReportUtils.isTripRoom(report)) { return ( - + ); } From 770d39e92f4b2677851f9a4f99556d94088094e5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sun, 5 May 2024 20:49:20 +0530 Subject: [PATCH 06/65] add styles and copy trip details view --- src/CONST.ts | 8 + .../ReportActionItem/TripDetailsView.tsx | 211 +++++++++++++++++- src/styles/index.ts | 30 +++ 3 files changed, 245 insertions(+), 4 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 48e33f0b0f5d..07102e422981 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4682,6 +4682,14 @@ const CONST = { INITIAL_URL: 'INITIAL_URL', }, + RESERVATION_TYPE: { + CAR: 'car', + HOTEL: 'hotel', + FLIGHT: 'flight', + RAIL: 'rail', + MISC: 'misc', + }, + DOT_SEPARATOR: '•', DEFAULT_TAX: { diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 9b560a0a037c..804dc2e731fc 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -1,5 +1,94 @@ +import React from 'react'; import {View} from 'react-native'; +import Icon from '@components/Icon'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import SpacerView from '@components/SpacerView'; import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useStyleUtils from '@hooks/useStyleUtils'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import useWindowDimensions from '@hooks/useWindowDimensions'; +import DateUtils from '@libs/DateUtils'; +import AnimatedEmptyStateBackground from '@pages/home/report/AnimatedEmptyStateBackground'; +import variables from '@styles/variables'; +import * as Expensicons from '@src/components/Icon/Expensicons'; +import CONST from '@src/CONST'; +import * as ReportUtils from '@src/libs/ReportUtils'; +import * as TripReservationUtils from '@src/libs/TripReservationUtils'; +import type {Reservation, ReservationTimeDetails} from '@src/types/onyx/Transaction'; + +// TODO: to be removed once backend is ready +const testReservationsList: Reservation[] = [ + { + company: { + longName: 'American Airlines', + shortName: 'AA', + }, + confirmations: [ + { + name: 'Confirmation Number', + value: 'DDPNOF', + }, + ], + start: { + address: 'AA Address', + date: '2022-08-21 21:36', + longName: 'Philadelphia', + shortName: 'PHL', + timezoneOffset: -360, + }, + end: { + address: 'BB Address', + date: '2022-11-10 12:36', + longName: 'San Francisco', + shortName: 'SFO', + timezoneOffset: -360, + }, + numPassengers: 2, + route: { + class: '', + number: '2579', + }, + type: CONST.RESERVATION_TYPE.FLIGHT, + }, + { + company: { + longName: 'W San Francisco', + }, + confirmations: [ + { + name: 'Booking Number', + value: 'SUDMBE', + }, + { + name: 'Confirmation Number', + value: 'GGGGGGG-HHHHHH-IIIIII', + }, + ], + start: { + address: '181 3rd St, San Francisco, CA 94103', + date: '2023-01-22 21:40', + longName: 'SFO123', + shortName: 'SFO', + timezoneOffset: -420, + }, + end: { + address: 'DD Address', + date: '2023-02-10 12:00', + longName: 'Denver-Denver Intl', + shortName: 'DEN', + timezoneOffset: -420, + }, + numberOfRooms: 3, + route: { + class: '', + number: '46564', + }, + type: CONST.RESERVATION_TYPE.HOTEL, + }, +]; type TripDetailsViewProps = { /** The active IOUReport, used for Onyx subscription */ @@ -9,14 +98,128 @@ type TripDetailsViewProps = { shouldShowHorizontalRule: boolean; }; +type ReservationViewProps = { + reservation: Reservation; +}; + +function ReservationView({reservation}: ReservationViewProps) { + const theme = useTheme(); + const styles = useThemeStyles(); + + const reservationIcon = TripReservationUtils.getTripReservationIcon(reservation.type); + + const formatAirportInfo = (reservationTimeDetails: ReservationTimeDetails) => `${reservationTimeDetails.longName} (${reservationTimeDetails.shortName})`; + + const getFormattedDate = () => { + switch (reservation.type) { + case CONST.RESERVATION_TYPE.FLIGHT: + case CONST.RESERVATION_TYPE.RAIL: + return DateUtils.getFormattedTransportDate(new Date(reservation.start.date)); + case CONST.RESERVATION_TYPE.HOTEL: + return DateUtils.getFormattedReservationRangeDate(new Date(reservation.start.date), new Date(reservation.end.date)); + default: + return DateUtils.formatToLongDateWithWeekday(new Date(reservation.start.date)); + } + }; + + const formattedDate = getFormattedDate(); + + const bottomDescription = `${reservation.confirmations.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}${ + reservation.type === CONST.RESERVATION_TYPE.FLIGHT + ? `${reservation.company.longName} • ${reservation.company.shortName ?? ''} ${reservation.route.number}` + : reservation.start.address + }`; + + const titleComponent = ( + + {reservation.type === CONST.RESERVATION_TYPE.FLIGHT ? ( + + {formatAirportInfo(reservation.start)} + + {formatAirportInfo(reservation.end)} + + ) : ( + + {reservation.company.longName} + + )} + {bottomDescription} + + ); + + return ( + {}} + iconHeight={20} + iconWidth={20} + iconStyles={[styles.tripReservationIconContainer(true), styles.mr2]} + secondaryIconFill={theme.icon} + /> + ); +} + function TripDetailsView({iouReportID, shouldShowHorizontalRule}: TripDetailsViewProps) { + const StyleUtils = useStyleUtils(); + const {isSmallScreenWidth} = useWindowDimensions(); + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + // TODO: once backend is ready uncomment lines below and remove test data + const reservations = testReservationsList; + // const tripTransactions = ReportUtils.getTripTransactions(iouReportID); + + // const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); + return ( - - - Hello world ${iouReportID} ${shouldShowHorizontalRule} - + + + + + + + {translate('travel.tripSummary')} + + + + <> + {reservations.map((reservation) => ( + + + + ))} + + + ); } +TripDetailsView.displayName = 'TripDetailsView'; + export default TripDetailsView; diff --git a/src/styles/index.ts b/src/styles/index.ts index 1b1587d81bce..076bb0b562fb 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -412,6 +412,11 @@ const styles = (theme: ThemeColors) => fontSize: variables.fontSizeExtraSmall, }, + textNormalBold: { + fontSize: variables.fontSizeNormal, + fontWeight: 'bold', + }, + textNormal: { fontSize: variables.fontSizeNormal, }, @@ -1327,6 +1332,18 @@ const styles = (theme: ThemeColors) => lineHeight: variables.lineHeightNormal, }, + textSupportingSmallSize: { + fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, + fontSize: variables.fontSizeSmall, + color: theme.textSupporting, + }, + + textSupportingNormalSize: { + fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, + fontSize: variables.fontSizeNormal, + color: theme.textSupporting, + }, + textLabelSupporting: { fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, fontSize: variables.fontSizeLabel, @@ -1373,6 +1390,10 @@ const styles = (theme: ThemeColors) => color: theme.textSupporting, }, + lh14: { + lineHeight: 14, + }, + lh16: { lineHeight: 16, }, @@ -4876,6 +4897,15 @@ const styles = (theme: ThemeColors) => fontSize: variables.fontSizeXLarge, }, + tripReservationIconContainer: (isBiggerIcon: boolean) => ({ + width: isBiggerIcon ? 40 : 32, + height: isBiggerIcon ? 40 : 32, + backgroundColor: theme.overlay, + borderRadius: isBiggerIcon ? 40 : 32, + alignItems: 'center', + justifyContent: 'center', + }), + textLineThrough: { textDecorationLine: 'line-through', }, From 0079ccc62e71bbc634946ab2ef588aabcad87e38 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 6 May 2024 05:43:18 +0530 Subject: [PATCH 07/65] add dateutils and lang --- src/languages/en.ts | 10 ++++++ src/languages/es.ts | 10 ++++++ src/libs/DateUtils.ts | 72 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/src/languages/en.ts b/src/languages/en.ts index aadd6ac03f58..9fa4953e5e1c 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -224,6 +224,7 @@ export default { tomorrowAt: 'Tomorrow at', yesterdayAt: 'Yesterday at', conjunctionAt: 'at', + conjunctionTo: 'to', genericErrorMessage: 'Oops... something went wrong and your request could not be completed. Please try again later.', error: { invalidAmount: 'Invalid amount.', @@ -1860,6 +1861,15 @@ export default { agree: 'I agree to the travel ', error: 'You must accept the Terms & Conditions for travel to continue', }, + flight: 'Flight', + hotel: 'Hotel', + car: 'Car', + misc: 'Miscellaneous', + rail: 'Rail', + viewTrip: 'View trip', + trip: 'Trip', + tripSummary: 'Trip summary', + departs: 'Departs', }, workspace: { common: { diff --git a/src/languages/es.ts b/src/languages/es.ts index d4efe11a51b0..629270d0f4dc 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -214,6 +214,7 @@ export default { tomorrowAt: 'Mañana a las', yesterdayAt: 'Ayer a las', conjunctionAt: 'a', + conjunctionTo: 'a', genericErrorMessage: 'Ups... algo no ha ido bien y la acción no se ha podido completar. Por favor, inténtalo más tarde.', error: { invalidAmount: 'Importe no válido.', @@ -1884,6 +1885,15 @@ export default { agree: 'Acepto los ', error: 'Debes aceptar los Términos y condiciones para que el viaje continúe', }, + flight: 'Vuelo', + hotel: 'Hotel', + car: 'Auto', + misc: 'Misceláneo', + rail: 'Carril', + viewTrip: 'Ver viaje', + trip: 'Viaje', + tripSummary: 'Resumen del viaje', + departs: 'Sale', }, workspace: { common: { diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 22c5a7d907cc..6b2cd3c4bf98 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -15,8 +15,10 @@ import { isAfter, isBefore, isSameDay, + isSameMonth, isSameSecond, isSameYear, + isThisYear, isValid, parse, set, @@ -764,6 +766,73 @@ function getLastBusinessDayOfMonth(inputDate: Date): number { return getDate(currentDate); } +/** + * Returns a formatted date range from date 1 to date 2. + * Dates are formatted as follows: + * 1. When both dates refer to the same day: Mar 17 + * 2. When both dates refer to the same month: Mar 17-20 + * 3. When both dates refer to the same year: Feb 28 to Mar 1 + * 4. When the dates are from different years: Dec 28, 2023 to Jan 5, 2024 + */ +function getFormattedDateRange(date1: Date, date2: Date): string { + const {translateLocal} = Localize; + + if (isSameDay(date1, date2)) { + // Dates are from the same day + return format(date1, 'MMM d'); + } + if (isSameMonth(date1, date2)) { + // Dates in the same month and year, differ by days + return `${format(date1, 'MMM d')}-${format(date2, 'd')}`; + } + if (isSameYear(date1, date2)) { + // Dates are in the same year, differ by months + return `${format(date1, 'MMM d')} ${translateLocal('common.to').toLowerCase()} ${format(date2, 'MMM d')}`; + } + // Dates differ by years, months, days + return `${format(date1, 'MMM d, yyyy')} ${translateLocal('common.to').toLowerCase()} ${format(date2, 'MMM d, yyyy')}`; +} + +/** + * Returns a formatted date range from date 1 to date 2 of a reservation. + * Dates are formatted as follows: + * 1. When both dates refer to the same day and the current year: Sunday, Mar 17 + * 2. When both dates refer to the same day but not the current year: Wednesday, Mar 17, 2023 + * 3. When both dates refer to the current year: Sunday, Mar 17 to Wednesday, Mar 20 + * 4. When the dates are from different years or from a year which is not current: Wednesday, Mar 17, 2023 to Saturday, Jan 20, 2024 + */ +function getFormattedReservationRangeDate(date1: Date, date2: Date): string { + const {translateLocal} = Localize; + if (isSameDay(date1, date2) && isThisYear(date1)) { + // Dates are from the same day + return format(date1, 'EEEE, MMM d, yyyy'); + } + if (isSameDay(date1, date2)) { + // Dates are from the same day + return format(date1, 'EEEE, MMM d'); + } + if (isSameYear(date1, date2) && isThisYear(date1)) { + // Dates are in the current year, differ by months + return `${format(date1, 'EEEE, MMM d')} ${translateLocal('common.conjunctionTo')} ${format(date2, 'EEEE, MMM d')}`; + } + // Dates differ by years, months, days or only by months but the year is not current + return `${format(date1, 'EEEE, MMM d, yyyy')} ${translateLocal('common.conjunctionTo')} ${format(date2, 'EEEE, MMM d, yyyy')}`; +} + +/** + * Returns a formatted date of a transport mean departure. + * Dates are formatted as follows: + * 1. When the date reffers to the current day: Departs on Sunday, Mar 17 at 8:00 + * 2. When the date reffers not to the current day: Departs on Wednesday, Mar 17, 2023 at 8:00 + */ +function getFormattedTransportDate(date: Date): string { + const {translateLocal} = Localize; + if (isThisYear(date)) { + return `${translateLocal('travel.departs')} ${format(date, 'EEEE, MMM d')} ${translateLocal('common.conjunctionAt')} ${format(date, 'HH:MM')}`; + } + return `${translateLocal('travel.departs')} ${format(date, 'EEEE, MMM d, yyyy')} ${translateLocal('common.conjunctionAt')} ${format(date, 'HH:MM')}`; +} + const DateUtils = { formatToDayOfWeek, formatToLongDateWithWeekday, @@ -811,6 +880,9 @@ const DateUtils = { formatToSupportedTimezone, enrichMoneyRequestTimestamp, getLastBusinessDayOfMonth, + getFormattedDateRange, + getFormattedReservationRangeDate, + getFormattedTransportDate, }; export default DateUtils; From 0d7db3783da45b37e1648d8dff1d5afcf4b5c6f7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 6 May 2024 05:48:50 +0530 Subject: [PATCH 08/65] add reservation type --- src/libs/TripReservationUtils.ts | 31 +++++++++++++++ src/types/onyx/Transaction.ts | 66 ++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 src/libs/TripReservationUtils.ts diff --git a/src/libs/TripReservationUtils.ts b/src/libs/TripReservationUtils.ts new file mode 100644 index 000000000000..c0b1724d4835 --- /dev/null +++ b/src/libs/TripReservationUtils.ts @@ -0,0 +1,31 @@ +import * as Expensicons from '@src/components/Icon/Expensicons'; +import CONST from '@src/CONST'; +import type {Reservation, ReservationType} from '@src/types/onyx/Transaction'; +import type Transaction from '@src/types/onyx/Transaction'; +import type IconAsset from '@src/types/utils/IconAsset'; + +function getTripReservationIcon(reservationType: ReservationType): IconAsset { + switch (reservationType) { + case CONST.RESERVATION_TYPE.FLIGHT: + return Expensicons.Plane; + case CONST.RESERVATION_TYPE.HOTEL: + return Expensicons.Bed; + case CONST.RESERVATION_TYPE.CAR: + return Expensicons.CarWithKey; + case CONST.RESERVATION_TYPE.MISC: + return Expensicons.Luggage; + case CONST.RESERVATION_TYPE.RAIL: + return Expensicons.Train; + default: + return Expensicons.CarWithKey; + } +} + +function getReservationsFromTripTransactions(transactions: Transaction[]): Reservation[] { + return transactions + .map((item) => item?.reservationList ?? []) + .filter((item) => item.length > 0) + .flat(); +} + +export {getTripReservationIcon, getReservationsFromTripTransactions}; diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 7894876fdcdf..065ddba4b847 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -107,6 +107,64 @@ type TaxRate = { data?: TaxRateData; }; +type Fare = { + amount: number; + convertedAmount: number; + convertedCurrency: string; + currencyCode: string; +}; + +type SpotnanaPayload = { + tripId: string; + pnrId: string; + bookingStatus: string; + documents: unknown[]; + carPnr?: unknown; + airPnr?: unknown; + totalFare: Fare; + totalFareAmount: { + base: Fare; + tax: Fare; + }; + version: number; +}; + +type Reservation = { + reservationID?: string; + start: ReservationTimeDetails; + end: ReservationTimeDetails; + type: ReservationType; + company?: Company; + confirmations?: ReservationConfirmation[]; + numPassengers?: number; + numberOfRooms?: number; + route?: { + class: string; + number: string; + }; +}; + +type ReservationTimeDetails = { + date: string; + address?: string; + longName?: string; + shortName?: string; + timezoneOffset?: number; +}; + +type Company = { + longName: string; + shortName?: string; + phone?: string; +}; + +type ReservationConfirmation = { + name: string; + value: string; +}; + +type ReservationType = ValueOf; + type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< { /** The original transaction amount */ @@ -225,6 +283,11 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< /** Indicates transaction loading */ isLoading?: boolean; + /** Travel reserviation list */ + reservationList?: Reservation[]; + + originalSpotnanaPayload?: SpotnanaPayload; + /** The actionable report action ID associated with the transaction */ actionableWhisperReportActionID?: string; @@ -264,6 +327,9 @@ export type { TransactionPendingFieldsKey, TransactionChanges, TaxRate, + Reservation, + ReservationTimeDetails, + ReservationType, ReceiptSource, TransactionCollectionDataSet, }; From 26c0c880225456b1c908d770d80b00e0a946138c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 6 May 2024 05:49:42 +0530 Subject: [PATCH 09/65] add assets --- assets/images/bed.svg | 1 + assets/images/car-with-key.svg | 1 + assets/images/plane.svg | 1 + assets/images/train.svg | 1 + 4 files changed, 4 insertions(+) create mode 100644 assets/images/bed.svg create mode 100644 assets/images/car-with-key.svg create mode 100644 assets/images/plane.svg create mode 100644 assets/images/train.svg diff --git a/assets/images/bed.svg b/assets/images/bed.svg new file mode 100644 index 000000000000..fd654c036a7c --- /dev/null +++ b/assets/images/bed.svg @@ -0,0 +1 @@ + diff --git a/assets/images/car-with-key.svg b/assets/images/car-with-key.svg new file mode 100644 index 000000000000..1586c0dfecfa --- /dev/null +++ b/assets/images/car-with-key.svg @@ -0,0 +1 @@ + diff --git a/assets/images/plane.svg b/assets/images/plane.svg new file mode 100644 index 000000000000..bf4d56875239 --- /dev/null +++ b/assets/images/plane.svg @@ -0,0 +1 @@ + diff --git a/assets/images/train.svg b/assets/images/train.svg new file mode 100644 index 000000000000..9b838708ecdf --- /dev/null +++ b/assets/images/train.svg @@ -0,0 +1 @@ + From 5497a13eb45112c175b86a3b6748b10dc650fa49 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 6 May 2024 05:51:29 +0530 Subject: [PATCH 10/65] add assets --- src/components/Icon/Expensicons.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/Icon/Expensicons.ts b/src/components/Icon/Expensicons.ts index 74dbf8622a24..a4848eb5ec83 100644 --- a/src/components/Icon/Expensicons.ts +++ b/src/components/Icon/Expensicons.ts @@ -17,6 +17,7 @@ import NotificationsAvatar from '@assets/images/avatars/notifications-avatar.svg import ActiveRoomAvatar from '@assets/images/avatars/room.svg'; import BackArrow from '@assets/images/back-left.svg'; import Bank from '@assets/images/bank.svg'; +import Bed from '@assets/images/bed.svg'; import Bell from '@assets/images/bell.svg'; import BellSlash from '@assets/images/bellSlash.svg'; import Bill from '@assets/images/bill.svg'; @@ -26,6 +27,7 @@ import Bug from '@assets/images/bug.svg'; import Building from '@assets/images/building.svg'; import Calendar from '@assets/images/calendar.svg'; import Camera from '@assets/images/camera.svg'; +import CarWithKey from '@assets/images/car-with-key.svg'; import Car from '@assets/images/car.svg'; import CardsAndDomains from '@assets/images/cards-and-domains.svg'; import Cash from '@assets/images/cash.svg'; @@ -120,6 +122,7 @@ import Paycheck from '@assets/images/paycheck.svg'; import Pencil from '@assets/images/pencil.svg'; import Phone from '@assets/images/phone.svg'; import Pin from '@assets/images/pin.svg'; +import Plane from '@assets/images/plane.svg'; import Play from '@assets/images/play.svg'; import Plus from '@assets/images/plus.svg'; import Printer from '@assets/images/printer.svg'; @@ -151,6 +154,7 @@ import Task from '@assets/images/task.svg'; import Thread from '@assets/images/thread.svg'; import ThreeDots from '@assets/images/three-dots.svg'; import ThumbsUp from '@assets/images/thumbs-up.svg'; +import Train from '@assets/images/train.svg'; import Transfer from '@assets/images/transfer.svg'; import Trashcan from '@assets/images/trashcan.svg'; import Unlock from '@assets/images/unlock.svg'; @@ -334,6 +338,10 @@ export { ChatBubbleUnread, ChatBubbleReply, Lightbulb, + Plane, + Bed, + CarWithKey, DocumentPlus, + Train, Clear, }; From 3adc30918ce4786d5badbab93b6feecd6eb1e99f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 6 May 2024 06:00:40 +0530 Subject: [PATCH 11/65] add title style to menu item --- src/components/MenuItem.tsx | 22 +++++++++++++++++-- .../ReportActionItem/TripDetailsView.tsx | 8 +++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index bf35d65340fc..bd949bf8910d 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -105,6 +105,8 @@ type MenuItemBaseProps = { /** The fill color to pass into the secondary icon. */ secondaryIconFill?: string; + isSecondaryIconHoverable?: boolean; + /** Icon Width */ iconWidth?: number; @@ -170,6 +172,12 @@ type MenuItemBaseProps = { /** Text to display for the item */ title?: string; + /** Component to display as the title */ + titleComponent?: ReactElement; + + /** Any additional styles to apply to the container for title components */ + titleContainerStyle?: StyleProp; + /** A right-aligned subtitle for this menu option */ subtitle?: string | number; @@ -285,6 +293,7 @@ function MenuItem( secondaryIcon, secondaryIconFill, iconType = CONST.ICON_TYPE_ICON, + isSecondaryIconHoverable = false, iconWidth, iconHeight, iconStyles, @@ -302,6 +311,8 @@ function MenuItem( focused = false, disabled = false, title, + titleComponent, + titleContainerStyle, subtitle, shouldShowBasicTitle, label, @@ -528,7 +539,13 @@ function MenuItem( )} {secondaryIcon && ( - + )} - + {!!description && shouldShowDescriptionOnTop && ( )} + {titleComponent} diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 804dc2e731fc..685b015ecf82 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -124,9 +124,9 @@ function ReservationView({reservation}: ReservationViewProps) { const formattedDate = getFormattedDate(); - const bottomDescription = `${reservation.confirmations.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}${ + const bottomDescription = `${reservation.confirmations?.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}${ reservation.type === CONST.RESERVATION_TYPE.FLIGHT - ? `${reservation.company.longName} • ${reservation.company.shortName ?? ''} ${reservation.route.number}` + ? `${reservation.company?.longName} • ${reservation?.company?.shortName ?? ''} ${reservation.route?.number}` : reservation.start.address }`; @@ -148,7 +148,7 @@ function ReservationView({reservation}: ReservationViewProps) { numberOfLines={1} style={[styles.textNormalBold, styles.lh20]} > - {reservation.company.longName} + {reservation.company?.longName} )} {bottomDescription} @@ -158,7 +158,7 @@ function ReservationView({reservation}: ReservationViewProps) { return ( Date: Mon, 13 May 2024 08:43:24 +0530 Subject: [PATCH 12/65] fix margin and gap for trip summary --- src/components/ReportActionItem/TripDetailsView.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 685b015ecf82..9c6544439d23 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -131,7 +131,7 @@ function ReservationView({reservation}: ReservationViewProps) { }`; const titleComponent = ( - + {reservation.type === CONST.RESERVATION_TYPE.FLIGHT ? ( {formatAirportInfo(reservation.start)} @@ -172,7 +172,7 @@ function ReservationView({reservation}: ReservationViewProps) { onSecondaryInteraction={() => {}} iconHeight={20} iconWidth={20} - iconStyles={[styles.tripReservationIconContainer(true), styles.mr2]} + iconStyles={[styles.tripReservationIconContainer(true), styles.mr3]} secondaryIconFill={theme.icon} /> ); From 724c980aef1402de173b34d853c1e309f3942ec8 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 13 May 2024 22:01:45 +0530 Subject: [PATCH 13/65] fix empty div when no title present --- src/components/MenuItem.tsx | 50 +++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index 6599edde0022..f562614a7532 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -574,30 +574,32 @@ function MenuItem( {description} )} - - {!!title && (shouldRenderAsHTML || (shouldParseTitle && !!html.length)) && ( - - - - )} - {!shouldRenderAsHTML && !shouldParseTitle && !!title && ( - - {renderTitleContent()} - - )} - {shouldShowTitleIcon && titleIcon && ( - - - - )} - + {(!!title || !!shouldShowTitleIcon) && ( + + {!!title && (shouldRenderAsHTML || (shouldParseTitle && !!html.length)) && ( + + + + )} + {!shouldRenderAsHTML && !shouldParseTitle && !!title && ( + + {renderTitleContent()} + + )} + {shouldShowTitleIcon && titleIcon && ( + + + + )} + + )} {!!description && !shouldShowDescriptionOnTop && ( Date: Mon, 13 May 2024 22:02:00 +0530 Subject: [PATCH 14/65] add 4px gap --- src/components/ReportActionItem/TripDetailsView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 9c6544439d23..8309f0ac3feb 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -160,7 +160,7 @@ function ReservationView({reservation}: ReservationViewProps) { description={formattedDate} descriptionTextStyle={[styles.textLabelSupporting, styles.lh16]} titleComponent={titleComponent} - titleContainerStyle={styles.justifyContentStart} + titleContainerStyle={[styles.justifyContentStart, styles.gap1]} secondaryIcon={reservationIcon} isSecondaryIconHoverable shouldShowRightIcon From b3c8abbfc22e77b738607e8ccded303cf4b5ea0d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 15 May 2024 22:22:38 +0530 Subject: [PATCH 15/65] update const chat type --- src/CONST.ts | 2 +- src/libs/ReportUtils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index f9db6f5aeb16..647e4d3c6710 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -50,7 +50,7 @@ const KEYBOARD_SHORTCUT_NAVIGATION_TYPE = 'NAVIGATION_SHORTCUT'; const chatTypes = { POLICY_ANNOUNCE: 'policyAnnounce', POLICY_ADMINS: 'policyAdmins', - POLICY_TRIP_ROOM: 'policyTripRoom', + TRIP_ROOM: 'tripRoom', GROUP: 'group', DOMAIN_ALL: 'domainAll', POLICY_ROOM: 'policyRoom', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0bbe14119726..b1505a48d5b8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -912,7 +912,7 @@ function isInvoiceRoom(report: OnyxEntry): boolean { * Checks if a report is a completed task report. */ function isTripRoom(report: OnyxEntry): boolean { - return isChatReport(report) && getChatType(report) === CONST.REPORT.CHAT_TYPE.POLICY_TRIP_ROOM; + return isChatReport(report) && getChatType(report) === CONST.REPORT.CHAT_TYPE.TRIP_ROOM; } function isCurrentUserInvoiceReceiver(report: OnyxEntry): boolean { From bc7a0f896ae7a83f7bb2d84622e5307b16999a5b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 15 May 2024 22:25:56 +0530 Subject: [PATCH 16/65] merge main --- src/components/MenuItem.tsx | 366 ++++++++++++++++++------------------ 1 file changed, 180 insertions(+), 186 deletions(-) diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index f562614a7532..ad06f9fcb78c 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -105,8 +105,6 @@ type MenuItemBaseProps = { /** The fill color to pass into the secondary icon. */ secondaryIconFill?: string; - isSecondaryIconHoverable?: boolean; - /** Icon Width */ iconWidth?: number; @@ -152,12 +150,12 @@ type MenuItemBaseProps = { /** Should the description be shown above the title (instead of the other way around) */ shouldShowDescriptionOnTop?: boolean; - /** Error to display below the title */ - error?: string; - /** Error to display at the bottom of the component */ errorText?: MaybePhraseKey; + /** Hint to display at the bottom of the component */ + hintText?: MaybePhraseKey; + /** A boolean flag that gives the icon a green fill if true */ success?: boolean; @@ -178,12 +176,6 @@ type MenuItemBaseProps = { /** Text to display for the item */ title?: string; - /** Component to display as the title */ - titleComponent?: ReactElement; - - /** Any additional styles to apply to the container for title components */ - titleContainerStyle?: StyleProp; - /** A right-aligned subtitle for this menu option */ subtitle?: string | number; @@ -273,6 +265,9 @@ type MenuItemBaseProps = { /** Handles what to do when the item is focused */ onFocus?: () => void; + + /** Optional account id if it's user avatar or policy id if it's workspace avatar */ + avatarID?: number | string; }; type MenuItemProps = (IconProps | AvatarProps | NoIcon) & MenuItemBaseProps; @@ -299,7 +294,6 @@ function MenuItem( secondaryIcon, secondaryIconFill, iconType = CONST.ICON_TYPE_ICON, - isSecondaryIconHoverable = false, iconWidth, iconHeight, iconStyles, @@ -313,14 +307,12 @@ function MenuItem( description, helperText, helperTextStyle, - error, errorText, + hintText, success = false, focused = false, disabled = false, title, - titleComponent, - titleContainerStyle, subtitle, shouldShowBasicTitle, label, @@ -353,6 +345,7 @@ function MenuItem( isPaneMenu = false, shouldPutLeftPaddingWhenNoIcon = false, onFocus, + avatarID, }: MenuItemProps, ref: PressableRef, ) { @@ -466,7 +459,6 @@ function MenuItem( style={({pressed}) => [ containerStyle, - errorText ? styles.pb5 : {}, combinedStyle, !interactive && styles.cursorDefault, StyleUtils.getButtonBackgroundColorStyle(getButtonState(focused || isHovered, pressed, success, disabled, interactive), true), @@ -484,97 +476,97 @@ function MenuItem( onFocus={onFocus} > {({pressed}) => ( - <> - - {!!label && isLabelHoverable && ( - - - {label} - - - )} - - {!!icon && Array.isArray(icon) && ( - + + + + {!!label && isLabelHoverable && ( + + + {label} + + )} - {!icon && shouldPutLeftPaddingWhenNoIcon && } - {icon && !Array.isArray(icon) && ( - - {typeof icon !== 'string' && iconType === CONST.ICON_TYPE_ICON && ( + + {!!icon && Array.isArray(icon) && ( + + )} + {!icon && shouldPutLeftPaddingWhenNoIcon && } + {icon && !Array.isArray(icon) && ( + + {typeof icon !== 'string' && iconType === CONST.ICON_TYPE_ICON && ( + + )} + {icon && iconType === CONST.ICON_TYPE_WORKSPACE && ( + + )} + {iconType === CONST.ICON_TYPE_AVATAR && ( + + )} + + )} + {secondaryIcon && ( + - )} - {icon && iconType === CONST.ICON_TYPE_WORKSPACE && ( - - )} - {iconType === CONST.ICON_TYPE_AVATAR && ( - - )} - - )} - {secondaryIcon && ( - - - - )} - - {!!description && shouldShowDescriptionOnTop && ( - - {description} - + )} - {(!!title || !!shouldShowTitleIcon) && ( + + {!!description && shouldShowDescriptionOnTop && ( + + {description} + + )} {!!title && (shouldRenderAsHTML || (shouldParseTitle && !!html.length)) && ( @@ -599,100 +591,94 @@ function MenuItem( )} - )} - {!!description && !shouldShowDescriptionOnTop && ( - - {description} - - )} - {!!error && ( - - {error} - - )} - {!!furtherDetails && ( - - {!!furtherDetailsIcon && ( - - )} + {!!description && !shouldShowDescriptionOnTop && ( - {furtherDetails} + {description} - - )} - {titleComponent} + )} + {!!furtherDetails && ( + + {!!furtherDetailsIcon && ( + + )} + + {furtherDetails} + + + )} + - - - {badgeText && ( - - )} - {/* Since subtitle can be of type number, we should allow 0 to be shown */} - {(subtitle === 0 || subtitle) && ( - - {subtitle} - - )} - {floatRightAvatars?.length > 0 && ( - - {shouldShowSubscriptRightAvatar ? ( - + {badgeText && ( + + )} + {/* Since subtitle can be of type number, we should allow 0 to be shown */} + {(subtitle === 0 || subtitle) && ( + + {subtitle} + + )} + {floatRightAvatars?.length > 0 && ( + + {shouldShowSubscriptRightAvatar ? ( + + ) : ( + + )} + + )} + {!!brickRoadIndicator && ( + + - ) : ( - + )} + {!title && !!rightLabel && !errorText && ( + + {rightLabel} + + )} + {shouldShowRightIcon && ( + + - )} - - )} - {!!brickRoadIndicator && ( - - - - )} - {!title && !!rightLabel && ( - - {rightLabel} - - )} - {shouldShowRightIcon && ( - - - - )} - {shouldShowRightComponent && rightComponent} - {shouldShowSelectedState && } + + )} + {shouldShowRightComponent && rightComponent} + {shouldShowSelectedState && } + {!!errorText && ( )} - + {!!hintText && ( + + )} + )} )} From 9318abb836e0485366e961326e9ec9d540b79d05 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 15 May 2024 22:31:12 +0530 Subject: [PATCH 17/65] merge main --- src/components/MenuItem.tsx | 76 ++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index ad06f9fcb78c..61f29f44b00c 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -1,6 +1,6 @@ import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import type {ImageContentFit} from 'expo-image'; -import type {ReactNode} from 'react'; +import type {ReactElement, ReactNode} from 'react'; import React, {forwardRef, useContext, useMemo} from 'react'; import type {GestureResponderEvent, StyleProp, TextStyle, ViewStyle} from 'react-native'; import {View} from 'react-native'; @@ -105,6 +105,8 @@ type MenuItemBaseProps = { /** The fill color to pass into the secondary icon. */ secondaryIconFill?: string; + isSecondaryIconHoverable?: boolean; + /** Icon Width */ iconWidth?: number; @@ -176,6 +178,12 @@ type MenuItemBaseProps = { /** Text to display for the item */ title?: string; + /** Component to display as the title */ + titleComponent?: ReactElement; + + /** Any additional styles to apply to the container for title components */ + titleContainerStyle?: StyleProp; + /** A right-aligned subtitle for this menu option */ subtitle?: string | number; @@ -294,6 +302,7 @@ function MenuItem( secondaryIcon, secondaryIconFill, iconType = CONST.ICON_TYPE_ICON, + isSecondaryIconHoverable = false, iconWidth, iconHeight, iconStyles, @@ -313,6 +322,8 @@ function MenuItem( focused = false, disabled = false, title, + titleComponent, + titleContainerStyle, subtitle, shouldShowBasicTitle, label, @@ -545,7 +556,13 @@ function MenuItem( )} {secondaryIcon && ( - + )} - + {!!description && shouldShowDescriptionOnTop && ( )} - - {!!title && (shouldRenderAsHTML || (shouldParseTitle && !!html.length)) && ( - - - - )} - {!shouldRenderAsHTML && !shouldParseTitle && !!title && ( - - {renderTitleContent()} - - )} - {shouldShowTitleIcon && titleIcon && ( - - - - )} - + {(!!title || !!shouldShowTitleIcon) && ( + + {!!title && (shouldRenderAsHTML || (shouldParseTitle && !!html.length)) && ( + + + + )} + {!shouldRenderAsHTML && !shouldParseTitle && !!title && ( + + {renderTitleContent()} + + )} + {shouldShowTitleIcon && titleIcon && ( + + + + )} + + )} {!!description && !shouldShowDescriptionOnTop && ( )} + {titleComponent} From e6b529645c428e4bf4546b611674d16cef29e1d6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 15 May 2024 23:23:49 +0530 Subject: [PATCH 18/65] update trip report type --- src/CONST.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CONST.ts b/src/CONST.ts index 4472c7732195..733e55967190 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -703,6 +703,7 @@ const CONST = { TASK_COMPLETED: 'TASKCOMPLETED', TASK_EDITED: 'TASKEDITED', TASK_REOPENED: 'TASKREOPENED', + TRIPPREVIEW: 'TRIPPREVIEW', UNAPPROVED: 'UNAPPROVED', // OldDot Action UNHOLD: 'UNHOLD', UNSHARE: 'UNSHARE', // OldDot Action From 548f81d20d04a6b29654f4d2eda18242970b251d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 15 May 2024 23:24:23 +0530 Subject: [PATCH 19/65] show trip preview and check for trip room --- src/pages/home/report/ReportActionItem.tsx | 26 +++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 423364f3837c..a3242b3f25a8 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -774,6 +774,21 @@ function ReportActionItem({ return {content}; }; + console.log('action.actionName', action.actionName); + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW) { + console.log('Hello'); + if (ReportUtils.isTripRoom(report)) { + return ( + + + + ); + } + } + if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { if (ReportActionsUtils.isTransactionThread(parentReportAction)) { const isReversedTransaction = ReportActionsUtils.isReversedTransaction(parentReportAction); @@ -845,17 +860,6 @@ function ReportActionItem({ ); } - if (ReportUtils.isTripRoom(report)) { - return ( - - - - ); - } - if (ReportUtils.isExpenseReport(report) || ReportUtils.isIOUReport(report) || ReportUtils.isInvoiceReport(report)) { return ( From d78fe79843d5ce33bd6703e779fdb5fc386c018a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 15 May 2024 23:24:43 +0530 Subject: [PATCH 20/65] onyx add trip preview type --- src/types/onyx/OriginalMessage.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index b079a64ebb4b..b9b6f08a8b8e 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -27,6 +27,7 @@ type OriginalMessageActionName = | 'ACTIONABLEMENTIONWHISPER' | 'ACTIONABLEREPORTMENTIONWHISPER' | 'ACTIONABLETRACKEXPENSEWHISPER' + | 'TRIPPREVIEW' | ValueOf; type OriginalMessageApproved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; @@ -342,6 +343,13 @@ type OriginalMessageDismissedViolation = { }; }; +type OriginalMessageTripRoomPreview = { + actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTION_TRIPPREVIEW; + originalMessage: { + // @TODO: Add types here + }; +}; + type OriginalMessage = | OriginalMessageApproved | OriginalMessageIOU @@ -366,6 +374,7 @@ type OriginalMessage = | OriginalMessageReimbursementDequeued | OriginalMessageMoved | OriginalMessageMarkedReimbursed + | OriginalMessageTripRoomPreview | OriginalMessageActionableTrackedExpenseWhisper | OriginalMessageMergedWithCashTransaction | OriginalMessageDismissedViolation; From c155df816606fe89290a808e7f7ed45d297612ae Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Wed, 15 May 2024 23:25:26 +0530 Subject: [PATCH 21/65] rm console log --- src/pages/home/report/ReportActionItem.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index a3242b3f25a8..c1c80dc8f5f8 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -774,9 +774,7 @@ function ReportActionItem({ return {content}; }; - console.log('action.actionName', action.actionName); if (action.actionName === CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW) { - console.log('Hello'); if (ReportUtils.isTripRoom(report)) { return ( From 3e4d438e8df6382d0e5bc08eebcfde3dc41d719f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 16 May 2024 08:47:12 +0530 Subject: [PATCH 22/65] add trip header and trip transactins --- src/libs/ReportUtils.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8bfacc78fdb7..6aa592c5b6d2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3187,6 +3187,11 @@ function getReportName(report: OnyxEntry, policy: OnyxEntry = nu if (ReportActionsUtils.isModifiedExpenseAction(parentReportAction)) { return ModifiedExpenseMessage.getForReportAction(report?.reportID, parentReportAction); } + + if (isTripRoom(report)) { + return report?.reportName ?? ''; + } + return parentReportActionMessage; } @@ -6516,6 +6521,12 @@ function shouldCreateNewMoneyRequestReport(existingIOUReport: OnyxEntry return !existingIOUReport || hasIOUWaitingOnCurrentUserBankAccount(chatReport) || !canAddOrDeleteTransactions(existingIOUReport); } +function getTripTransactions(expenseReportID: string | undefined): Transaction[] { + const transactions = TransactionUtils.getAllReportTransactions(expenseReportID); + console.log('transactions: ', transactions); + return transactions.filter((transaction) => TransactionUtils.hasReservationList(transaction)); +} + /** * Checks if report contains actions with errors */ @@ -6947,6 +6958,7 @@ export { updateOptimisticParentReportAction, updateReportPreview, temporary_getMoneyRequestOptions, + getTripTransactions, buildOptimisticInvoiceReport, getInvoiceChatByParticipants, shouldShowMerchantColumn, From 1d151298a1a2ba5d1180151f05bfbd8838d72fba Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Fri, 17 May 2024 21:41:52 +0530 Subject: [PATCH 23/65] working report --- src/components/ReportActionItem/TripDetailsView.tsx | 9 +++++---- src/libs/TransactionUtils.ts | 5 +++++ src/pages/home/report/ReportActionItem.tsx | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 8309f0ac3feb..bc8328ad22a7 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -185,10 +185,11 @@ function TripDetailsView({iouReportID, shouldShowHorizontalRule}: TripDetailsVie const {translate} = useLocalize(); // TODO: once backend is ready uncomment lines below and remove test data - const reservations = testReservationsList; - // const tripTransactions = ReportUtils.getTripTransactions(iouReportID); - - // const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); + // const reservations = testReservationsList; + const tripTransactions = ReportUtils.getTripTransactions(iouReportID); + console.log('reportId: ', iouReportID); + console.log('**', tripTransactions); + const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); return ( diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index aa9a87404924..1cf03b88cc65 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -647,6 +647,10 @@ function isCustomUnitRateIDForP2P(transaction: OnyxEntry): boolean return transaction?.comment?.customUnit?.customUnitRateID === CONST.CUSTOM_UNITS.FAKE_P2P_ID; } +function hasReservationList(transaction: Transaction | undefined | null): boolean { + return !!transaction?.reservationList && transaction?.reservationList?.length > 0; +} + /** * Get rate ID from the transaction object */ @@ -766,6 +770,7 @@ export { getWaypointIndex, waypointHasValidAddress, getRecentTransactions, + hasReservationList, hasViolation, hasNoticeTypeViolation, isCustomUnitRateIDForP2P, diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index c1c80dc8f5f8..993bd5993037 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -774,12 +774,13 @@ function ReportActionItem({ return {content}; }; + console.log(report); if (action.actionName === CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW) { if (ReportUtils.isTripRoom(report)) { return ( From da2b2f4a0533353c3f542d2ccdfd8abbb7e2eda7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 20 May 2024 12:27:04 +0530 Subject: [PATCH 24/65] get trip transactions --- src/libs/ReportUtils.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6aa592c5b6d2..fd62a9b4e7a1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6521,10 +6521,9 @@ function shouldCreateNewMoneyRequestReport(existingIOUReport: OnyxEntry return !existingIOUReport || hasIOUWaitingOnCurrentUserBankAccount(chatReport) || !canAddOrDeleteTransactions(existingIOUReport); } -function getTripTransactions(expenseReportID: string | undefined): Transaction[] { - const transactions = TransactionUtils.getAllReportTransactions(expenseReportID); - console.log('transactions: ', transactions); - return transactions.filter((transaction) => TransactionUtils.hasReservationList(transaction)); +function getTripTransactions(tripRoomReportID: string | undefined): Transaction[] | undefined { + const tripTransactionReportIDs = Object.values(allReports ?? {}).filter((report) => report && report?.parentReportID === tripRoomReportID); + return Object.values(tripTransactionReportIDs ?? {}).map((report) => report && TransactionUtils.getAllReportTransactions(report?.reportID)); } /** From 1812e1b1958a244f7a5b85913dfa5213f48565d8 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 20 May 2024 12:27:22 +0530 Subject: [PATCH 25/65] get trip reservations method --- src/libs/TripReservationUtils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/TripReservationUtils.ts b/src/libs/TripReservationUtils.ts index c0b1724d4835..b525ccd520fe 100644 --- a/src/libs/TripReservationUtils.ts +++ b/src/libs/TripReservationUtils.ts @@ -23,7 +23,8 @@ function getTripReservationIcon(reservationType: ReservationType): IconAsset { function getReservationsFromTripTransactions(transactions: Transaction[]): Reservation[] { return transactions - .map((item) => item?.reservationList ?? []) + .flat() + .map((item) => item?.receipt?.reservationList ?? []) .filter((item) => item.length > 0) .flat(); } From 0229a52f71c452337dbe7a43a701adc70d770642 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 20 May 2024 12:27:34 +0530 Subject: [PATCH 26/65] rm console --- src/pages/home/report/ReportActionItem.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 993bd5993037..fb06018c9e74 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -774,13 +774,12 @@ function ReportActionItem({ return {content}; }; - console.log(report); if (action.actionName === CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW) { if (ReportUtils.isTripRoom(report)) { return ( From 876c40320157983ad1652e561002010ed297315b Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 20 May 2024 12:27:49 +0530 Subject: [PATCH 27/65] add reservation to receipt --- src/types/onyx/Transaction.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 3e3291cab4ea..11b0d9a4fa45 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -79,6 +79,7 @@ type Receipt = { filename?: string; state?: ValueOf; type?: string; + reservationList?: Reservation[]; }; type Route = { @@ -107,7 +108,6 @@ type TaxRate = { data?: TaxRateData; }; - type Fare = { amount: number; convertedAmount: number; @@ -140,7 +140,8 @@ type Reservation = { numPassengers?: number; numberOfRooms?: number; route?: { - class: string; + airlineCode: string; + class?: string; number: string; }; }; @@ -150,7 +151,7 @@ type ReservationTimeDetails = { address?: string; longName?: string; shortName?: string; - timezoneOffset?: number; + timezoneOffset?: string; }; type Company = { @@ -291,10 +292,6 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< /** Indicates transaction loading */ isLoading?: boolean; - - /** Travel reserviation list */ - reservationList?: Reservation[]; - originalSpotnanaPayload?: SpotnanaPayload; /** Holds individual shares of a split keyed by accountID, only used locally */ @@ -303,7 +300,6 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< /** Holds the accountIDs of accounts who paid the split, for now only supports a single payer */ splitPayerAccountIDs?: number[]; - /** The actionable report action ID associated with the transaction */ actionableWhisperReportActionID?: string; From 658ba4b4b9be2c47504c7753681b59ec1d72b82d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 20 May 2024 12:28:46 +0530 Subject: [PATCH 28/65] add reservation to receipt --- .../ReportActionItem/TripDetailsView.tsx | 44 +++++++++++++++---- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index bc8328ad22a7..a7f34be668bf 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -1,5 +1,6 @@ import React from 'react'; import {View} from 'react-native'; +import Onyx from 'react-native-onyx'; import Icon from '@components/Icon'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -91,8 +92,8 @@ const testReservationsList: Reservation[] = [ ]; type TripDetailsViewProps = { - /** The active IOUReport, used for Onyx subscription */ - iouReportID?: string; + /** The active tripRoomReportID, used for Onyx subscription */ + tripRoomReportID?: string; /** Whether we should display the horizontal rule below the component */ shouldShowHorizontalRule: boolean; @@ -108,14 +109,15 @@ function ReservationView({reservation}: ReservationViewProps) { const reservationIcon = TripReservationUtils.getTripReservationIcon(reservation.type); - const formatAirportInfo = (reservationTimeDetails: ReservationTimeDetails) => `${reservationTimeDetails.longName} (${reservationTimeDetails.shortName})`; - + const formatAirportInfo = (reservationTimeDetails: ReservationTimeDetails) => + `${reservationTimeDetails?.longName ? `${reservationTimeDetails?.longName} ` : ''}${reservationTimeDetails?.shortName}`; const getFormattedDate = () => { switch (reservation.type) { case CONST.RESERVATION_TYPE.FLIGHT: case CONST.RESERVATION_TYPE.RAIL: return DateUtils.getFormattedTransportDate(new Date(reservation.start.date)); case CONST.RESERVATION_TYPE.HOTEL: + case CONST.RESERVATION_TYPE.CAR: return DateUtils.getFormattedReservationRangeDate(new Date(reservation.start.date), new Date(reservation.end.date)); default: return DateUtils.formatToLongDateWithWeekday(new Date(reservation.start.date)); @@ -178,17 +180,41 @@ function ReservationView({reservation}: ReservationViewProps) { ); } -function TripDetailsView({iouReportID, shouldShowHorizontalRule}: TripDetailsViewProps) { +function TripDetailsView({tripRoomReportID, shouldShowHorizontalRule}: TripDetailsViewProps) { const StyleUtils = useStyleUtils(); const {isSmallScreenWidth} = useWindowDimensions(); const styles = useThemeStyles(); const {translate} = useLocalize(); // TODO: once backend is ready uncomment lines below and remove test data - // const reservations = testReservationsList; - const tripTransactions = ReportUtils.getTripTransactions(iouReportID); - console.log('reportId: ', iouReportID); - console.log('**', tripTransactions); + Onyx.merge('transactions_3369516381858695612', { + receipt: {reservationList: [{end: {date: '2024-05-24T19:00:00'}, reservationID: '1174780760', start: {date: '2024-05-23T19:00:00'}, type: 'car'}]}, + }); + + Onyx.merge('transactions_2415242883159099811', { + receipt: { + reservationList: [ + { + company: {longName: 'Gulf Air', phone: '', shortName: 'GF'}, + confirmations: [{name: 'Confirmation Number', value: 'QXHLBH'}], + end: {date: '2024-05-23T07:30:00', shortName: 'BAH', timezoneOffset: ''}, + route: {airlineCode: 'GF57', number: '57'}, + start: {date: '2024-05-23T06:30:00', shortName: 'BOM', timezoneOffset: ''}, + type: 'flight', + }, + { + company: {longName: 'Gulf Air', phone: '', shortName: 'GF'}, + confirmations: [{name: 'Confirmation Number', value: 'QXHLBH'}], + end: {date: '2024-05-23T20:55:00', shortName: 'BOM', timezoneOffset: ''}, + route: {airlineCode: 'GF64', number: '64'}, + start: {date: '2024-05-23T14:30:00', shortName: 'BAH', timezoneOffset: ''}, + type: 'flight', + }, + ], + }, + }); + + const tripTransactions = ReportUtils.getTripTransactions(tripRoomReportID); const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); return ( From 854ac5b1c36cf2b53c5a54aa351922cc8623bf26 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 20 May 2024 12:29:15 +0530 Subject: [PATCH 29/65] add reservation details --- .../ReportActionItem/TripDetailsView.tsx | 71 ------------------- 1 file changed, 71 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index a7f34be668bf..31d93c43be44 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -20,77 +20,6 @@ import * as ReportUtils from '@src/libs/ReportUtils'; import * as TripReservationUtils from '@src/libs/TripReservationUtils'; import type {Reservation, ReservationTimeDetails} from '@src/types/onyx/Transaction'; -// TODO: to be removed once backend is ready -const testReservationsList: Reservation[] = [ - { - company: { - longName: 'American Airlines', - shortName: 'AA', - }, - confirmations: [ - { - name: 'Confirmation Number', - value: 'DDPNOF', - }, - ], - start: { - address: 'AA Address', - date: '2022-08-21 21:36', - longName: 'Philadelphia', - shortName: 'PHL', - timezoneOffset: -360, - }, - end: { - address: 'BB Address', - date: '2022-11-10 12:36', - longName: 'San Francisco', - shortName: 'SFO', - timezoneOffset: -360, - }, - numPassengers: 2, - route: { - class: '', - number: '2579', - }, - type: CONST.RESERVATION_TYPE.FLIGHT, - }, - { - company: { - longName: 'W San Francisco', - }, - confirmations: [ - { - name: 'Booking Number', - value: 'SUDMBE', - }, - { - name: 'Confirmation Number', - value: 'GGGGGGG-HHHHHH-IIIIII', - }, - ], - start: { - address: '181 3rd St, San Francisco, CA 94103', - date: '2023-01-22 21:40', - longName: 'SFO123', - shortName: 'SFO', - timezoneOffset: -420, - }, - end: { - address: 'DD Address', - date: '2023-02-10 12:00', - longName: 'Denver-Denver Intl', - shortName: 'DEN', - timezoneOffset: -420, - }, - numberOfRooms: 3, - route: { - class: '', - number: '46564', - }, - type: CONST.RESERVATION_TYPE.HOTEL, - }, -]; - type TripDetailsViewProps = { /** The active tripRoomReportID, used for Onyx subscription */ tripRoomReportID?: string; From 97b1d61605d1b8938539d0d7649180883bfd336e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 20 May 2024 12:31:33 +0530 Subject: [PATCH 30/65] hide horizontal rule --- src/pages/home/report/ReportActionItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index fb06018c9e74..21c87f25155f 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -780,7 +780,7 @@ function ReportActionItem({ ); From fdbc3d32f908752b5d27af34eecfa585a0daadaa Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 19:03:34 +0530 Subject: [PATCH 31/65] add trip transaction util --- 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 e33f2dbe7d12..33797c5a4fac 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6517,7 +6517,7 @@ function shouldCreateNewMoneyRequestReport(existingIOUReport: OnyxEntry return !existingIOUReport || hasIOUWaitingOnCurrentUserBankAccount(chatReport) || !canAddOrDeleteTransactions(existingIOUReport); } -function getTripTransactions(tripRoomReportID: string | undefined): Transaction[] | undefined { +function getTripTransactions(tripRoomReportID: string | undefined): Transaction[] { const tripTransactionReportIDs = Object.values(allReports ?? {}).filter((report) => report && report?.parentReportID === tripRoomReportID); return Object.values(tripTransactionReportIDs ?? {}).map((report) => report && TransactionUtils.getAllReportTransactions(report?.reportID)); } From 97219045ad0a0e68df4be19b3f412d2b0e4ee4d1 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 19:03:55 +0530 Subject: [PATCH 32/65] type for address --- src/types/onyx/Transaction.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 11b0d9a4fa45..e5d3b9cd47de 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -149,6 +149,7 @@ type Reservation = { type ReservationTimeDetails = { date: string; address?: string; + location?: string; longName?: string; shortName?: string; timezoneOffset?: string; From f2ea7f57164317cff0c182b041bfe2c8800ec3fc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 19:04:08 +0530 Subject: [PATCH 33/65] get trip from backend --- .../ReportActionItem/TripDetailsView.tsx | 73 +++++-------------- 1 file changed, 20 insertions(+), 53 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 31d93c43be44..e32566a55e58 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -1,6 +1,5 @@ import React from 'react'; import {View} from 'react-native'; -import Onyx from 'react-native-onyx'; import Icon from '@components/Icon'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -12,7 +11,6 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import DateUtils from '@libs/DateUtils'; -import AnimatedEmptyStateBackground from '@pages/home/report/AnimatedEmptyStateBackground'; import variables from '@styles/variables'; import * as Expensicons from '@src/components/Icon/Expensicons'; import CONST from '@src/CONST'; @@ -58,7 +56,7 @@ function ReservationView({reservation}: ReservationViewProps) { const bottomDescription = `${reservation.confirmations?.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}${ reservation.type === CONST.RESERVATION_TYPE.FLIGHT ? `${reservation.company?.longName} • ${reservation?.company?.shortName ?? ''} ${reservation.route?.number}` - : reservation.start.address + : reservation.start.address ?? reservation.start.location }`; const titleComponent = ( @@ -115,63 +113,32 @@ function TripDetailsView({tripRoomReportID, shouldShowHorizontalRule}: TripDetai const styles = useThemeStyles(); const {translate} = useLocalize(); - // TODO: once backend is ready uncomment lines below and remove test data - Onyx.merge('transactions_3369516381858695612', { - receipt: {reservationList: [{end: {date: '2024-05-24T19:00:00'}, reservationID: '1174780760', start: {date: '2024-05-23T19:00:00'}, type: 'car'}]}, - }); - - Onyx.merge('transactions_2415242883159099811', { - receipt: { - reservationList: [ - { - company: {longName: 'Gulf Air', phone: '', shortName: 'GF'}, - confirmations: [{name: 'Confirmation Number', value: 'QXHLBH'}], - end: {date: '2024-05-23T07:30:00', shortName: 'BAH', timezoneOffset: ''}, - route: {airlineCode: 'GF57', number: '57'}, - start: {date: '2024-05-23T06:30:00', shortName: 'BOM', timezoneOffset: ''}, - type: 'flight', - }, - { - company: {longName: 'Gulf Air', phone: '', shortName: 'GF'}, - confirmations: [{name: 'Confirmation Number', value: 'QXHLBH'}], - end: {date: '2024-05-23T20:55:00', shortName: 'BOM', timezoneOffset: ''}, - route: {airlineCode: 'GF64', number: '64'}, - start: {date: '2024-05-23T14:30:00', shortName: 'BAH', timezoneOffset: ''}, - type: 'flight', - }, - ], - }, - }); - const tripTransactions = ReportUtils.getTripTransactions(tripRoomReportID); const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); return ( - - - - - - {translate('travel.tripSummary')} - - + + + + {translate('travel.tripSummary')} + - <> - {reservations.map((reservation) => ( - - - - ))} - - + <> + {reservations.map((reservation) => ( + + + + ))} + + ); } From c381f99a859cb560d0e1d5104acb3fd3f4ffd56a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 19:59:37 +0530 Subject: [PATCH 34/65] show reservation code for hotel booking and hotel name --- .../ReportActionItem/TripDetailsView.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index e32566a55e58..7049cb5b73cf 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useMemo} from 'react'; import {View} from 'react-native'; import Icon from '@components/Icon'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; @@ -53,11 +53,16 @@ function ReservationView({reservation}: ReservationViewProps) { const formattedDate = getFormattedDate(); - const bottomDescription = `${reservation.confirmations?.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}${ - reservation.type === CONST.RESERVATION_TYPE.FLIGHT - ? `${reservation.company?.longName} • ${reservation?.company?.shortName ?? ''} ${reservation.route?.number}` - : reservation.start.address ?? reservation.start.location - }`; + const bottomDescription = useMemo(() => { + const code = `${reservation.confirmations && reservation.confirmations?.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}`; + if (reservation.type === CONST.RESERVATION_TYPE.FLIGHT) { + return `${code}${reservation.company?.longName} • ${reservation?.company?.shortName ?? ''} ${reservation.route?.number}`; + } + if (reservation.type === CONST.RESERVATION_TYPE.HOTEL) { + return `${code}${reservation.start.address}`; + } + return reservation.start.address ?? reservation.start.location; + }, [reservation]); const titleComponent = ( @@ -77,10 +82,10 @@ function ReservationView({reservation}: ReservationViewProps) { numberOfLines={1} style={[styles.textNormalBold, styles.lh20]} > - {reservation.company?.longName} + {reservation.start.longName} )} - {bottomDescription} + {bottomDescription && {bottomDescription}} ); @@ -115,6 +120,7 @@ function TripDetailsView({tripRoomReportID, shouldShowHorizontalRule}: TripDetai const tripTransactions = ReportUtils.getTripTransactions(tripRoomReportID); const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); + console.log(reservations); return ( From d855793215bbbed6e99d2a8964527b34a7188d05 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 20:30:25 +0530 Subject: [PATCH 35/65] show car info --- .../ReportActionItem/TripDetailsView.tsx | 48 +++++++++++-------- src/types/onyx/Transaction.ts | 7 +++ 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 7049cb5b73cf..55f5c76f0a81 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -61,39 +61,49 @@ function ReservationView({reservation}: ReservationViewProps) { if (reservation.type === CONST.RESERVATION_TYPE.HOTEL) { return `${code}${reservation.start.address}`; } + if (reservation.type === CONST.RESERVATION_TYPE.CAR) { + return `${reservation.vendor} • ${reservation.start.location}`; + } return reservation.start.address ?? reservation.start.location; }, [reservation]); - const titleComponent = ( - - {reservation.type === CONST.RESERVATION_TYPE.FLIGHT ? ( - - {formatAirportInfo(reservation.start)} - - {formatAirportInfo(reservation.end)} + const titleComponent = () => { + if (reservation.type === CONST.RESERVATION_TYPE.FLIGHT) { + return ( + + + {formatAirportInfo(reservation.start)} + + {formatAirportInfo(reservation.end)} + + {bottomDescription && {bottomDescription}} - ) : ( + ); + } + + return ( + - {reservation.start.longName} + {reservation.type === CONST.RESERVATION_TYPE.CAR ? reservation.carInfo?.name : reservation.start.longName} - )} - {bottomDescription && {bottomDescription}} - - ); + {bottomDescription && {bottomDescription}} + + ); + }; return ( ; type SplitShare = { From 25caa283a9bf63850a02bf4eeb6c771f472ebb85 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 20:36:28 +0530 Subject: [PATCH 36/65] rm console --- src/components/ReportActionItem/TripDetailsView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 55f5c76f0a81..1e4da93ab466 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -130,7 +130,6 @@ function TripDetailsView({tripRoomReportID, shouldShowHorizontalRule}: TripDetai const tripTransactions = ReportUtils.getTripTransactions(tripRoomReportID); const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); - console.log(reservations); return ( From 2a07889dd6bf7db9fb7a09821388908872f9ae6e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 20:56:29 +0530 Subject: [PATCH 37/65] fix transaction type --- src/libs/ReportUtils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 33797c5a4fac..e22ad203ffea 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6518,8 +6518,10 @@ function shouldCreateNewMoneyRequestReport(existingIOUReport: OnyxEntry } function getTripTransactions(tripRoomReportID: string | undefined): Transaction[] { - const tripTransactionReportIDs = Object.values(allReports ?? {}).filter((report) => report && report?.parentReportID === tripRoomReportID); - return Object.values(tripTransactionReportIDs ?? {}).map((report) => report && TransactionUtils.getAllReportTransactions(report?.reportID)); + const tripTransactionReportIDs = Object.values(allReports ?? {}) + .filter((report) => report && report?.parentReportID === tripRoomReportID) + .map((report) => report?.reportID); + return tripTransactionReportIDs.map((reportID) => TransactionUtils.getAllReportTransactions(reportID)).flat(); } /** From f4bfc633806fbdc8702b88a22fe99d585e6992e2 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 20:57:19 +0530 Subject: [PATCH 38/65] use flatmap --- 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 e22ad203ffea..f1ac2a535aa0 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6521,7 +6521,7 @@ function getTripTransactions(tripRoomReportID: string | undefined): Transaction[ const tripTransactionReportIDs = Object.values(allReports ?? {}) .filter((report) => report && report?.parentReportID === tripRoomReportID) .map((report) => report?.reportID); - return tripTransactionReportIDs.map((reportID) => TransactionUtils.getAllReportTransactions(reportID)).flat(); + return tripTransactionReportIDs.flatMap((reportID) => TransactionUtils.getAllReportTransactions(reportID)); } /** From 06f36fb5ba33411698c23e787b6b50299b7d15c9 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Sat, 25 May 2024 21:15:07 +0530 Subject: [PATCH 39/65] rm flat --- src/libs/TripReservationUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/TripReservationUtils.ts b/src/libs/TripReservationUtils.ts index b525ccd520fe..53955a0a57f4 100644 --- a/src/libs/TripReservationUtils.ts +++ b/src/libs/TripReservationUtils.ts @@ -23,7 +23,6 @@ function getTripReservationIcon(reservationType: ReservationType): IconAsset { function getReservationsFromTripTransactions(transactions: Transaction[]): Reservation[] { return transactions - .flat() .map((item) => item?.receipt?.reservationList ?? []) .filter((item) => item.length > 0) .flat(); From d4e2562489db9d1896d7ef0a323304e0ad272619 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 04:36:12 +0530 Subject: [PATCH 40/65] fix original message type --- src/types/onyx/OriginalMessage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index b9b6f08a8b8e..2709fb1e882e 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -344,7 +344,7 @@ type OriginalMessageDismissedViolation = { }; type OriginalMessageTripRoomPreview = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.ACTION_TRIPPREVIEW; + actionName: typeof CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW; originalMessage: { // @TODO: Add types here }; From 788b76534fd0d6bb194336d9a61139119347f545 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 04:45:01 +0530 Subject: [PATCH 41/65] has reservation list fix type --- src/libs/TransactionUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/TransactionUtils.ts b/src/libs/TransactionUtils.ts index e937e847714c..8d0e00376d9f 100644 --- a/src/libs/TransactionUtils.ts +++ b/src/libs/TransactionUtils.ts @@ -684,7 +684,7 @@ function isCustomUnitRateIDForP2P(transaction: OnyxEntry): boolean } function hasReservationList(transaction: Transaction | undefined | null): boolean { - return !!transaction?.reservationList && transaction?.reservationList?.length > 0; + return !!transaction?.receipt?.reservationList && transaction?.receipt?.reservationList.length > 0; } /** From fcd5684260710a70934ab34a268adcba8ad13799 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 04:57:28 +0530 Subject: [PATCH 42/65] rm original msg --- src/types/onyx/OriginalMessage.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 2709fb1e882e..05e579ef7736 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -343,13 +343,6 @@ type OriginalMessageDismissedViolation = { }; }; -type OriginalMessageTripRoomPreview = { - actionName: typeof CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW; - originalMessage: { - // @TODO: Add types here - }; -}; - type OriginalMessage = | OriginalMessageApproved | OriginalMessageIOU @@ -374,7 +367,6 @@ type OriginalMessage = | OriginalMessageReimbursementDequeued | OriginalMessageMoved | OriginalMessageMarkedReimbursed - | OriginalMessageTripRoomPreview | OriginalMessageActionableTrackedExpenseWhisper | OriginalMessageMergedWithCashTransaction | OriginalMessageDismissedViolation; From 3822694eb2e877ba4450d5f11e64d02e85175d9d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 04:58:28 +0530 Subject: [PATCH 43/65] rm original msg --- src/types/onyx/OriginalMessage.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 05e579ef7736..b079a64ebb4b 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -27,7 +27,6 @@ type OriginalMessageActionName = | 'ACTIONABLEMENTIONWHISPER' | 'ACTIONABLEREPORTMENTIONWHISPER' | 'ACTIONABLETRACKEXPENSEWHISPER' - | 'TRIPPREVIEW' | ValueOf; type OriginalMessageApproved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; From 5ed20abd8f53845e2f94ac492b467d0e54c8e64a Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 05:03:22 +0530 Subject: [PATCH 44/65] Revert "rm original msg" This reverts commit 3822694eb2e877ba4450d5f11e64d02e85175d9d. --- src/types/onyx/OriginalMessage.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index b079a64ebb4b..05e579ef7736 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -27,6 +27,7 @@ type OriginalMessageActionName = | 'ACTIONABLEMENTIONWHISPER' | 'ACTIONABLEREPORTMENTIONWHISPER' | 'ACTIONABLETRACKEXPENSEWHISPER' + | 'TRIPPREVIEW' | ValueOf; type OriginalMessageApproved = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.APPROVED; From d1ded814a3e2a64310b8362634d65ee6bb36faa6 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 05:03:43 +0530 Subject: [PATCH 45/65] Revert "rm original msg" This reverts commit fcd5684260710a70934ab34a268adcba8ad13799. --- src/types/onyx/OriginalMessage.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 05e579ef7736..2709fb1e882e 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -343,6 +343,13 @@ type OriginalMessageDismissedViolation = { }; }; +type OriginalMessageTripRoomPreview = { + actionName: typeof CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW; + originalMessage: { + // @TODO: Add types here + }; +}; + type OriginalMessage = | OriginalMessageApproved | OriginalMessageIOU @@ -367,6 +374,7 @@ type OriginalMessage = | OriginalMessageReimbursementDequeued | OriginalMessageMoved | OriginalMessageMarkedReimbursed + | OriginalMessageTripRoomPreview | OriginalMessageActionableTrackedExpenseWhisper | OriginalMessageMergedWithCashTransaction | OriginalMessageDismissedViolation; From 844c7e1c045b45bdea85c1ef0e9c9ae7cb13a688 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 05:14:33 +0530 Subject: [PATCH 46/65] add type for trip room original msg --- src/types/onyx/OriginalMessage.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 2709fb1e882e..c62bd8f34f24 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -346,7 +346,9 @@ type OriginalMessageDismissedViolation = { type OriginalMessageTripRoomPreview = { actionName: typeof CONST.REPORT.ACTIONS.TYPE.TRIPPREVIEW; originalMessage: { - // @TODO: Add types here + linkedReportID: string; + lastModified?: string; + whisperedTo?: number[]; }; }; From 95ca8cf548a9beebfcf6c2cd32838f0988cde666 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 16:11:31 +0530 Subject: [PATCH 47/65] rm train svg --- assets/images/train.svg | 1 - 1 file changed, 1 deletion(-) delete mode 100644 assets/images/train.svg diff --git a/assets/images/train.svg b/assets/images/train.svg deleted file mode 100644 index 9b838708ecdf..000000000000 --- a/assets/images/train.svg +++ /dev/null @@ -1 +0,0 @@ - From 2e48b57649040b5805d45acea9325ecfdf493755 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 16:11:55 +0530 Subject: [PATCH 48/65] rm train and misc from reservation type --- src/CONST.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 9afe1d4b6ac5..4d380504ab32 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4740,8 +4740,6 @@ const CONST = { CAR: 'car', HOTEL: 'hotel', FLIGHT: 'flight', - RAIL: 'rail', - MISC: 'misc', }, DOT_SEPARATOR: '•', From 90d2a0cd7fe57bca8587820ed0c8bc234bfa1f6c Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 16:12:15 +0530 Subject: [PATCH 49/65] rm train svg --- src/components/Icon/Expensicons.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/Icon/Expensicons.ts b/src/components/Icon/Expensicons.ts index 2e3eb2d7f6e4..7aa0c1fdda7d 100644 --- a/src/components/Icon/Expensicons.ts +++ b/src/components/Icon/Expensicons.ts @@ -155,7 +155,6 @@ import Task from '@assets/images/task.svg'; import Thread from '@assets/images/thread.svg'; import ThreeDots from '@assets/images/three-dots.svg'; import ThumbsUp from '@assets/images/thumbs-up.svg'; -import Train from '@assets/images/train.svg'; import Transfer from '@assets/images/transfer.svg'; import Trashcan from '@assets/images/trashcan.svg'; import Unlock from '@assets/images/unlock.svg'; @@ -344,6 +343,5 @@ export { Bed, CarWithKey, DocumentPlus, - Train, Clear, }; From 48bdd41a00431aa7fdc07cdc8d3fd90db80dfd3d Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 16:13:20 +0530 Subject: [PATCH 50/65] add comment --- src/components/MenuItem.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index 61f29f44b00c..8ead4920a635 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -105,6 +105,7 @@ type MenuItemBaseProps = { /** The fill color to pass into the secondary icon. */ secondaryIconFill?: string; + /** Whether the secondary icon should have hover style */ isSecondaryIconHoverable?: boolean; /** Icon Width */ From 29a670f1d1ff4de90d801bdaddfbf645a42a9210 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Tue, 28 May 2024 16:18:37 +0530 Subject: [PATCH 51/65] rm type rail from lang --- src/components/ReportActionItem/TripDetailsView.tsx | 1 - src/languages/en.ts | 2 -- src/languages/es.ts | 2 -- src/libs/TripReservationUtils.ts | 6 +----- 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 1e4da93ab466..72c2527b8af1 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -41,7 +41,6 @@ function ReservationView({reservation}: ReservationViewProps) { const getFormattedDate = () => { switch (reservation.type) { case CONST.RESERVATION_TYPE.FLIGHT: - case CONST.RESERVATION_TYPE.RAIL: return DateUtils.getFormattedTransportDate(new Date(reservation.start.date)); case CONST.RESERVATION_TYPE.HOTEL: case CONST.RESERVATION_TYPE.CAR: diff --git a/src/languages/en.ts b/src/languages/en.ts index f9dc7c95bc95..0bbfda9aba6f 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1880,8 +1880,6 @@ export default { flight: 'Flight', hotel: 'Hotel', car: 'Car', - misc: 'Miscellaneous', - rail: 'Rail', viewTrip: 'View trip', trip: 'Trip', tripSummary: 'Trip summary', diff --git a/src/languages/es.ts b/src/languages/es.ts index e17b623e60ed..621546b0d1a5 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1904,8 +1904,6 @@ export default { flight: 'Vuelo', hotel: 'Hotel', car: 'Auto', - misc: 'Misceláneo', - rail: 'Carril', viewTrip: 'Ver viaje', trip: 'Viaje', tripSummary: 'Resumen del viaje', diff --git a/src/libs/TripReservationUtils.ts b/src/libs/TripReservationUtils.ts index 53955a0a57f4..ead786b8eafd 100644 --- a/src/libs/TripReservationUtils.ts +++ b/src/libs/TripReservationUtils.ts @@ -12,12 +12,8 @@ function getTripReservationIcon(reservationType: ReservationType): IconAsset { return Expensicons.Bed; case CONST.RESERVATION_TYPE.CAR: return Expensicons.CarWithKey; - case CONST.RESERVATION_TYPE.MISC: - return Expensicons.Luggage; - case CONST.RESERVATION_TYPE.RAIL: - return Expensicons.Train; default: - return Expensicons.CarWithKey; + return Expensicons.Luggage; } } From 7df2a5617a9466d153b3a85f30633ad7cc813fd8 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 08:56:36 +0300 Subject: [PATCH 52/65] Update src/libs/DateUtils.ts Co-authored-by: Amy Evans --- src/libs/DateUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 0f9ff7fcbc3a..0a5af37a0f8c 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -786,8 +786,8 @@ function getFormattedReservationRangeDate(date1: Date, date2: Date): string { /** * Returns a formatted date of a transport mean departure. * Dates are formatted as follows: - * 1. When the date reffers to the current day: Departs on Sunday, Mar 17 at 8:00 - * 2. When the date reffers not to the current day: Departs on Wednesday, Mar 17, 2023 at 8:00 + * 1. When the date refers to the current day: Departs on Sunday, Mar 17 at 8:00 + * 2. When the date refers not to the current day: Departs on Wednesday, Mar 17, 2023 at 8:00 */ function getFormattedTransportDate(date: Date): string { const {translateLocal} = Localize; From d3708b79ea60e59b1b0b446a84f9905358f3abd5 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 11:34:32 +0530 Subject: [PATCH 53/65] show year only if not this year --- src/libs/DateUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 0a5af37a0f8c..2793ccd4f96d 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -769,11 +769,11 @@ function getFormattedReservationRangeDate(date1: Date, date2: Date): string { const {translateLocal} = Localize; if (isSameDay(date1, date2) && isThisYear(date1)) { // Dates are from the same day - return format(date1, 'EEEE, MMM d, yyyy'); + return format(date1, 'EEEE, MMM d'); } if (isSameDay(date1, date2)) { - // Dates are from the same day - return format(date1, 'EEEE, MMM d'); + // Dates are from the same day but not this year + return format(date1, 'EEEE, MMM d, yyyy'); } if (isSameYear(date1, date2) && isThisYear(date1)) { // Dates are in the current year, differ by months From 41fb5468e293c3a8797c7ddaf8db2b448b6f46d7 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 11:36:24 +0530 Subject: [PATCH 54/65] simplify comment --- src/libs/DateUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/DateUtils.ts b/src/libs/DateUtils.ts index 2793ccd4f96d..50cb9a20dff6 100644 --- a/src/libs/DateUtils.ts +++ b/src/libs/DateUtils.ts @@ -784,7 +784,7 @@ function getFormattedReservationRangeDate(date1: Date, date2: Date): string { } /** - * Returns a formatted date of a transport mean departure. + * Returns a formatted date of departure. * Dates are formatted as follows: * 1. When the date refers to the current day: Departs on Sunday, Mar 17 at 8:00 * 2. When the date refers not to the current day: Departs on Wednesday, Mar 17, 2023 at 8:00 From dee1f1c5af735e4e613b0c40ee358ece8745abfc Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 11:38:35 +0530 Subject: [PATCH 55/65] rm type --- src/types/onyx/Transaction.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index 78a990fff8f0..d4a6557662ac 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -303,8 +303,6 @@ type Transaction = OnyxCommon.OnyxValueWithOfflineFeedback< /** Indicates transaction loading */ isLoading?: boolean; - originalSpotnanaPayload?: SpotnanaPayload; - /** Holds individual shares of a split keyed by accountID, only used locally */ splitShares?: SplitShares; From b9b96a888dd2ef3c1b56410a1654724704445374 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 11:39:21 +0530 Subject: [PATCH 56/65] rm type --- src/types/onyx/Transaction.ts | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/types/onyx/Transaction.ts b/src/types/onyx/Transaction.ts index d4a6557662ac..47ed18348275 100644 --- a/src/types/onyx/Transaction.ts +++ b/src/types/onyx/Transaction.ts @@ -111,28 +111,6 @@ type TaxRate = { data?: TaxRateData; }; -type Fare = { - amount: number; - convertedAmount: number; - convertedCurrency: string; - currencyCode: string; -}; - -type SpotnanaPayload = { - tripId: string; - pnrId: string; - bookingStatus: string; - documents: unknown[]; - carPnr?: unknown; - airPnr?: unknown; - totalFare: Fare; - totalFareAmount: { - base: Fare; - tax: Fare; - }; - version: number; -}; - type Reservation = { reservationID?: string; start: ReservationTimeDetails; From 89c35973fc9df5042bc6faba0810000c34556173 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 11:53:08 +0530 Subject: [PATCH 57/65] fix spacing when values are not present --- src/components/ReportActionItem/TripDetailsView.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 72c2527b8af1..9be3f35ff886 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -55,13 +55,16 @@ function ReservationView({reservation}: ReservationViewProps) { const bottomDescription = useMemo(() => { const code = `${reservation.confirmations && reservation.confirmations?.length > 0 ? `${reservation.confirmations[0].value} • ` : ''}`; if (reservation.type === CONST.RESERVATION_TYPE.FLIGHT) { - return `${code}${reservation.company?.longName} • ${reservation?.company?.shortName ?? ''} ${reservation.route?.number}`; + const longName = reservation.company?.longName ? `${reservation.company?.longName} • ` : ''; + const shortName = reservation?.company?.shortName ? `${reservation?.company?.shortName} ` : ''; + return `${code}${longName}${shortName}${reservation.route?.number}`; } if (reservation.type === CONST.RESERVATION_TYPE.HOTEL) { return `${code}${reservation.start.address}`; } if (reservation.type === CONST.RESERVATION_TYPE.CAR) { - return `${reservation.vendor} • ${reservation.start.location}`; + const vendor = reservation.vendor ? `${reservation.vendor} • ` : ''; + return `${vendor}${reservation.start.location}`; } return reservation.start.address ?? reservation.start.location; }, [reservation]); From 415e62a127bbccc42f0e2ac560bd705185848e3e Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 12:02:08 +0530 Subject: [PATCH 58/65] use empty state bg --- src/components/ReportActionItem/TripDetailsView.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 9be3f35ff886..80256c891e90 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -17,6 +17,7 @@ import CONST from '@src/CONST'; import * as ReportUtils from '@src/libs/ReportUtils'; import * as TripReservationUtils from '@src/libs/TripReservationUtils'; import type {Reservation, ReservationTimeDetails} from '@src/types/onyx/Transaction'; +import AnimatedEmptyStateBackground from '@pages/home/report/AnimatedEmptyStateBackground'; type TripDetailsViewProps = { /** The active tripRoomReportID, used for Onyx subscription */ @@ -125,8 +126,6 @@ function ReservationView({reservation}: ReservationViewProps) { } function TripDetailsView({tripRoomReportID, shouldShowHorizontalRule}: TripDetailsViewProps) { - const StyleUtils = useStyleUtils(); - const {isSmallScreenWidth} = useWindowDimensions(); const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -134,7 +133,8 @@ function TripDetailsView({tripRoomReportID, shouldShowHorizontalRule}: TripDetai const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); return ( - + + Date: Thu, 30 May 2024 12:27:37 +0530 Subject: [PATCH 59/65] rm animated state bg --- src/components/ReportActionItem/TripDetailsView.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 80256c891e90..1c8b2a27d6b4 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -6,10 +6,8 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import SpacerView from '@components/SpacerView'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; -import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; import DateUtils from '@libs/DateUtils'; import variables from '@styles/variables'; import * as Expensicons from '@src/components/Icon/Expensicons'; @@ -17,7 +15,6 @@ import CONST from '@src/CONST'; import * as ReportUtils from '@src/libs/ReportUtils'; import * as TripReservationUtils from '@src/libs/TripReservationUtils'; import type {Reservation, ReservationTimeDetails} from '@src/types/onyx/Transaction'; -import AnimatedEmptyStateBackground from '@pages/home/report/AnimatedEmptyStateBackground'; type TripDetailsViewProps = { /** The active tripRoomReportID, used for Onyx subscription */ @@ -133,8 +130,7 @@ function TripDetailsView({tripRoomReportID, shouldShowHorizontalRule}: TripDetai const reservations: Reservation[] = TripReservationUtils.getReservationsFromTripTransactions(tripTransactions); return ( - - + Date: Thu, 30 May 2024 12:45:33 +0530 Subject: [PATCH 60/65] show paranthesis only when both short and long name are present --- src/components/ReportActionItem/TripDetailsView.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 1c8b2a27d6b4..863531bc7e0a 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -34,8 +34,15 @@ function ReservationView({reservation}: ReservationViewProps) { const reservationIcon = TripReservationUtils.getTripReservationIcon(reservation.type); - const formatAirportInfo = (reservationTimeDetails: ReservationTimeDetails) => - `${reservationTimeDetails?.longName ? `${reservationTimeDetails?.longName} ` : ''}${reservationTimeDetails?.shortName}`; + const formatAirportInfo = (reservationTimeDetails: ReservationTimeDetails) => { + const longName = reservationTimeDetails?.longName ? `${reservationTimeDetails?.longName} ` : ''; + let shortName = reservationTimeDetails?.shortName ? `${reservationTimeDetails?.shortName}` : ''; + + shortName = longName && shortName ? `(${shortName})` : shortName; + + return `${longName}${shortName}`; + }; + const getFormattedDate = () => { switch (reservation.type) { case CONST.RESERVATION_TYPE.FLIGHT: From 56ed4e12accdcf0ab2d84765f459f97e59350a7f Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 18:28:19 +0530 Subject: [PATCH 61/65] handle text overflow on native --- src/components/ReportActionItem/TripDetailsView.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 863531bc7e0a..23bfce42c469 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -6,6 +6,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import SpacerView from '@components/SpacerView'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import DateUtils from '@libs/DateUtils'; @@ -31,6 +32,7 @@ type ReservationViewProps = { function ReservationView({reservation}: ReservationViewProps) { const theme = useTheme(); const styles = useThemeStyles(); + const {shouldUseNarrowLayout} = useResponsiveLayout(); const reservationIcon = TripReservationUtils.getTripReservationIcon(reservation.type); @@ -79,14 +81,14 @@ function ReservationView({reservation}: ReservationViewProps) { return ( - {formatAirportInfo(reservation.start)} + {formatAirportInfo(reservation.start)} - {formatAirportInfo(reservation.end)} + {formatAirportInfo(reservation.end)} {bottomDescription && {bottomDescription}} From c4b5df5b90b41759e4a9ff043cee6bd0c5fb28d3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 23:05:53 +0530 Subject: [PATCH 62/65] use font size small --- src/components/ReportActionItem/TripDetailsView.tsx | 6 +++--- src/styles/index.ts | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 23bfce42c469..41cafe26c385 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -81,14 +81,14 @@ function ReservationView({reservation}: ReservationViewProps) { return ( - {formatAirportInfo(reservation.start)} + {formatAirportInfo(reservation.start)} - {formatAirportInfo(reservation.end)} + {formatAirportInfo(reservation.end)} {bottomDescription && {bottomDescription}} @@ -99,7 +99,7 @@ function ReservationView({reservation}: ReservationViewProps) { {reservation.type === CONST.RESERVATION_TYPE.CAR ? reservation.carInfo?.name : reservation.start.longName} diff --git a/src/styles/index.ts b/src/styles/index.ts index 01ca246722b5..8c4a67162e3e 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -413,11 +413,6 @@ const styles = (theme: ThemeColors) => fontSize: variables.fontSizeExtraSmall, }, - textNormalBold: { - fontSize: variables.fontSizeNormal, - fontWeight: 'bold', - }, - textNormal: { fontSize: variables.fontSizeNormal, }, From 22c472e8071ce90e97b477127ab1862f190ee879 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Thu, 30 May 2024 23:27:01 +0530 Subject: [PATCH 63/65] use existing styles --- .../ReportActionItem/TripDetailsView.tsx | 6 ++-- src/styles/index.ts | 31 +++++++------------ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 41cafe26c385..0e4816a86e8d 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -90,7 +90,7 @@ function ReservationView({reservation}: ReservationViewProps) { /> {formatAirportInfo(reservation.end)} - {bottomDescription && {bottomDescription}} + {bottomDescription && {bottomDescription}} ); } @@ -103,7 +103,7 @@ function ReservationView({reservation}: ReservationViewProps) { > {reservation.type === CONST.RESERVATION_TYPE.CAR ? reservation.carInfo?.name : reservation.start.longName} - {bottomDescription && {bottomDescription}} + {bottomDescription && {bottomDescription}} ); }; @@ -125,7 +125,7 @@ function ReservationView({reservation}: ReservationViewProps) { onSecondaryInteraction={() => {}} iconHeight={20} iconWidth={20} - iconStyles={[styles.tripReservationIconContainer(true), styles.mr3]} + iconStyles={[styles.tripReservationIconContainer, styles.mr3]} secondaryIconFill={theme.icon} /> ); diff --git a/src/styles/index.ts b/src/styles/index.ts index 8c4a67162e3e..dd123986a929 100644 --- a/src/styles/index.ts +++ b/src/styles/index.ts @@ -386,6 +386,11 @@ const styles = (theme: ThemeColors) => lineHeight: variables.lineHeightNormal, }, + textSmall: { + fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, + fontSize: variables.fontSizeSmall, + }, + textMicro: { fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, fontSize: variables.fontSizeSmall, @@ -1331,18 +1336,6 @@ const styles = (theme: ThemeColors) => lineHeight: variables.lineHeightNormal, }, - textSupportingSmallSize: { - fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, - fontSize: variables.fontSizeSmall, - color: theme.textSupporting, - }, - - textSupportingNormalSize: { - fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, - fontSize: variables.fontSizeNormal, - color: theme.textSupporting, - }, - textLabelSupporting: { fontFamily: FontUtils.fontFamily.platform.EXP_NEUE, fontSize: variables.fontSizeLabel, @@ -1390,7 +1383,7 @@ const styles = (theme: ThemeColors) => }, lh14: { - lineHeight: 14, + lineHeight: variables.lineHeightSmall, }, lh16: { @@ -4941,14 +4934,14 @@ const styles = (theme: ThemeColors) => flex: 1, }, - tripReservationIconContainer: (isBiggerIcon: boolean) => ({ - width: isBiggerIcon ? 40 : 32, - height: isBiggerIcon ? 40 : 32, - backgroundColor: theme.overlay, - borderRadius: isBiggerIcon ? 40 : 32, + tripReservationIconContainer: { + width: variables.avatarSizeNormal, + height: variables.avatarSizeNormal, + backgroundColor: theme.border, + borderRadius: variables.componentBorderRadiusXLarge, alignItems: 'center', justifyContent: 'center', - }), + }, textLineThrough: { textDecorationLine: 'line-through', From 80cd508049fd3fe7ad1116f03dbea04bd2d5f428 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 3 Jun 2024 01:47:26 +0300 Subject: [PATCH 64/65] add hover style --- src/components/MenuItem.tsx | 2 +- src/components/ReportActionItem/TripDetailsView.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index 7f9a729c161a..44463e1aa08a 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -570,7 +570,7 @@ function MenuItem( style={[ styles.popoverMenuIcon, iconStyles, - isSecondaryIconHoverable && StyleUtils.getBackgroundAndBorderStyle(focused || isHovered ? theme.hoverComponentBG : theme.overlay), + isSecondaryIconHoverable && StyleUtils.getBackgroundAndBorderStyle(theme.border), ]} > ); } From f23f0c18b8a063bd2f899d6df9951f7886126edf Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 3 Jun 2024 12:26:01 +0300 Subject: [PATCH 65/65] prettier --- src/components/MenuItem.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/MenuItem.tsx b/src/components/MenuItem.tsx index 44463e1aa08a..7fd5024f6734 100644 --- a/src/components/MenuItem.tsx +++ b/src/components/MenuItem.tsx @@ -566,13 +566,7 @@ function MenuItem( )} {secondaryIcon && ( - +