From f9c552a9c1d3294976a02dd39802ea01a137edab Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Thu, 30 Jan 2025 09:22:13 +0100 Subject: [PATCH 1/3] Add cancellation policy mapping --- src/languages/en.ts | 6 ++++++ src/languages/es.ts | 6 ++++++ src/pages/Travel/HotelTripDetails.tsx | 12 ++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index d00812bfec38..4a9bfbaad145 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2537,6 +2537,12 @@ const translations = { cancellation: 'Cancellation policy', cancellationUntil: 'Free cancellation until', confirmation: 'Confirmation number', + cancellationPolicies: { + unknown: 'Unknown', + nonRefundable: 'Non-refundable', + freeCancellationUntil: 'Free cancellation until', + partiallyRefundable: 'Partially refundable', + }, }, car: 'Car', carDetails: { diff --git a/src/languages/es.ts b/src/languages/es.ts index a03b3fc7fc21..abe1bc6df77e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2561,6 +2561,12 @@ const translations = { cancellation: 'Política de cancelación', cancellationUntil: 'Cancelación gratuita hasta el', confirmation: 'Número de confirmación', + cancellationPolicies: { + unknown: 'Desconocido', + nonRefundable: 'No reembolsable', + freeCancellationUntil: 'Cancelación gratuita hasta', + partiallyRefundable: 'Parcialmente reembolsable', + }, }, car: 'Auto', carDetails: { diff --git a/src/pages/Travel/HotelTripDetails.tsx b/src/pages/Travel/HotelTripDetails.tsx index 747dc3ceca70..4df54faf1fc1 100644 --- a/src/pages/Travel/HotelTripDetails.tsx +++ b/src/pages/Travel/HotelTripDetails.tsx @@ -1,3 +1,4 @@ +import {Str} from 'expensify-common'; import React from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -20,17 +21,24 @@ function HotelTripDetails({reservation, personalDetails}: HotelTripDetailsProps) const styles = useThemeStyles(); const {translate} = useLocalize(); + const cancellationMapping: Record = { + [CONST.CANCELLATION_POLICY.UNKNOWN]: translate('travel.hotelDetails.cancellationPolicies.unknown'), + [CONST.CANCELLATION_POLICY.NON_REFUNDABLE]: translate('travel.hotelDetails.cancellationPolicies.nonRefundable'), + [CONST.CANCELLATION_POLICY.FREE_CANCELLATION_UNTIL]: translate('travel.hotelDetails.cancellationPolicies.freeCancellationUntil'), + [CONST.CANCELLATION_POLICY.PARTIALLY_REFUNDABLE]: translate('travel.hotelDetails.cancellationPolicies.partiallyRefundable'), + }; + const checkInDate = DateUtils.getFormattedTransportDateAndHour(new Date(reservation.start.date)); const checkOutDate = DateUtils.getFormattedTransportDateAndHour(new Date(reservation.end.date)); const cancellationText = reservation.cancellationDeadline ? `${translate('travel.hotelDetails.cancellationUntil')} ${DateUtils.getFormattedTransportDateAndHour(new Date(reservation.cancellationDeadline)).date}` - : reservation.cancellationPolicy; + : cancellationMapping[reservation.cancellationPolicy ?? CONST.CANCELLATION_POLICY.UNKNOWN]; const displayName = personalDetails?.displayName ?? reservation.travelerPersonalInfo?.name; return ( <> - {reservation.start.longName} + {Str.recapitalize(reservation.start.longName ?? '')} Date: Thu, 30 Jan 2025 09:22:30 +0100 Subject: [PATCH 2/3] Add CANCELLATION_POLICY constants to CONST --- src/CONST.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 616ac2c60bfb..9a52231785b9 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -6010,6 +6010,13 @@ const CONST = { TRAIN: 'train', }, + CANCELLATION_POLICY: { + UNKNOWN: 'UNKNOWN', + NON_REFUNDABLE: 'NON_REFUNDABLE', + FREE_CANCELLATION_UNTIL: 'FREE_CANCELLATION_UNTIL', + PARTIALLY_REFUNDABLE: 'PARTIALLY_REFUNDABLE', + }, + DOT_SEPARATOR: '•', DEFAULT_TAX: { From 76f9e87520cd2bccb3730b41488d1d10e062286a Mon Sep 17 00:00:00 2001 From: Blazej Kustra Date: Thu, 30 Jan 2025 09:22:51 +0100 Subject: [PATCH 3/3] Capitalize hotel names in trip details and preview --- src/components/ReportActionItem/TripDetailsView.tsx | 3 ++- src/components/ReportActionItem/TripRoomPreview.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/TripDetailsView.tsx b/src/components/ReportActionItem/TripDetailsView.tsx index 72d71b39b9d7..3e4253d848c4 100644 --- a/src/components/ReportActionItem/TripDetailsView.tsx +++ b/src/components/ReportActionItem/TripDetailsView.tsx @@ -1,3 +1,4 @@ +import {Str} from 'expensify-common'; import React, {useMemo} from 'react'; import {View} from 'react-native'; import Icon from '@components/Icon'; @@ -104,7 +105,7 @@ function ReservationView({reservation, transactionID, tripRoomReportID, reservat numberOfLines={1} style={[styles.textStrong, styles.lh20]} > - {reservation.type === CONST.RESERVATION_TYPE.CAR ? reservation.carInfo?.name : reservation.start.longName} + {reservation.type === CONST.RESERVATION_TYPE.CAR ? reservation.carInfo?.name : Str.recapitalize(reservation.start.longName ?? '')} {!!bottomDescription && {bottomDescription}} diff --git a/src/components/ReportActionItem/TripRoomPreview.tsx b/src/components/ReportActionItem/TripRoomPreview.tsx index d85c19d21ee0..d94b30374020 100644 --- a/src/components/ReportActionItem/TripRoomPreview.tsx +++ b/src/components/ReportActionItem/TripRoomPreview.tsx @@ -1,3 +1,4 @@ +import {Str} from 'expensify-common'; import React, {useMemo} from 'react'; import type {ListRenderItemInfo, StyleProp, ViewStyle} from 'react-native'; import {FlatList, View} from 'react-native'; @@ -62,7 +63,7 @@ function ReservationView({reservation}: ReservationViewProps) { const {translate} = useLocalize(); const reservationIcon = getTripReservationIcon(reservation.type); - const title = reservation.type === CONST.RESERVATION_TYPE.CAR ? reservation.carInfo?.name : reservation.start.longName; + const title = reservation.type === CONST.RESERVATION_TYPE.CAR ? reservation.carInfo?.name : Str.recapitalize(reservation.start.longName ?? ''); let titleComponent = (