Skip to content

Commit

Permalink
Merge pull request #56036 from software-mansion-labs/travel/cancellat…
Browse files Browse the repository at this point in the history
…ion-policy

Translate cancellation policy for hotel details page, recapitalize hotel names
  • Loading branch information
stitesExpensify authored Jan 30, 2025
2 parents cc95811 + 74f81ab commit 84b7be4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6011,6 +6011,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: {
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/TripDetailsView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {Str} from 'expensify-common';
import React, {useMemo} from 'react';
import {View} from 'react-native';
import Icon from '@components/Icon';
Expand Down Expand Up @@ -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 ?? '')}
</Text>
{!!bottomDescription && <Text style={[styles.textSmall, styles.colorMuted, styles.lh14]}>{bottomDescription}</Text>}
</View>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/TripRoomPreview.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 = (
<Text
Expand Down
6 changes: 6 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2538,6 +2538,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: {
Expand Down
6 changes: 6 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,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: {
Expand Down
12 changes: 10 additions & 2 deletions src/pages/Travel/HotelTripDetails.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,17 +21,24 @@ function HotelTripDetails({reservation, personalDetails}: HotelTripDetailsProps)
const styles = useThemeStyles();
const {translate} = useLocalize();

const cancellationMapping: Record<string, string> = {
[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 (
<>
<Text style={[styles.textHeadlineH1, styles.mh5, styles.mv3]}>{reservation.start.longName}</Text>
<Text style={[styles.textHeadlineH1, styles.mh5, styles.mv3]}>{Str.recapitalize(reservation.start.longName ?? '')}</Text>
<MenuItemWithTopDescription
description={translate('common.address')}
title={reservation.start.address}
Expand Down

0 comments on commit 84b7be4

Please sign in to comment.