feat(SW-706): make eslint rule 'formatjs/no-literal-string-in-jsx' pass

This commit is contained in:
Michael Zetterberg
2025-02-07 06:51:36 +01:00
parent e22fc1f3c8
commit 440e1f92df
393 changed files with 4839 additions and 1554 deletions

View File

@@ -26,10 +26,11 @@ export default function Alerts({ booking }: BookingConfirmationAlertsProps) {
<Alert
type={AlertTypeEnum.Info}
heading={intl.formatMessage({
id: "Failed to verify membership",
defaultMessage: "Failed to verify membership",
})}
text={intl.formatMessage({
id: "The first or last name doesn't match the membership number you provided. Your booking(s) is confirmed but to get the membership attached you'll need to present your existing membership number upon check-in. If you have booked with a member discount, you'll either need to present your existing membership number upon check-in, become a member or pay the price difference at the hotel. Signing up is preferably done online before the stay, or we can assist upon arrival.",
defaultMessage:
"The first or last name doesn't match the membership number you provided. Your booking(s) is confirmed but to get the membership attached you'll need to present your existing membership number upon check-in. If you have booked with a member discount, you'll either need to present your existing membership number upon check-in, become a member or pay the price difference at the hotel. Signing up is preferably done online before the stay, or we can assist upon arrival.",
})}
/>
)}
@@ -38,10 +39,11 @@ export default function Alerts({ booking }: BookingConfirmationAlertsProps) {
<Alert
type={AlertTypeEnum.Info}
heading={intl.formatMessage({
id: "Failed to verify membership",
defaultMessage: "Failed to verify membership",
})}
text={intl.formatMessage({
id: "Your booking(s) is confirmed but we could not verify your membership. If you have booked with a member discount, you'll either need to present your existing membership number upon check-in, become a member or pay the price difference at the hotel. Signing up is preferably done online before the stay.",
defaultMessage:
"Your booking(s) is confirmed but we could not verify your membership. If you have booked with a member discount, you'll either need to present your existing membership number upon check-in, become a member or pay the price difference at the hotel. Signing up is preferably done online before the stay.",
})}
/>
)}

View File

@@ -15,7 +15,9 @@ export default function AddToCalendarButton({
return (
<Button intent="text" size="small" theme="base" wrapping onPress={onPress}>
<MaterialIcon icon="calendar_add_on" color="CurrentColor" />
{intl.formatMessage({ id: "Add to calendar" })}
{intl.formatMessage({
defaultMessage: "Add to calendar",
})}
</Button>
)
}

View File

@@ -26,7 +26,9 @@ export default function DownloadInvoice({ mainRef }: DownloadInvoiceProps) {
wrapping
>
<MaterialIcon icon="download" color="CurrentColor" />
{intl.formatMessage({ id: "Download invoice" })}
{intl.formatMessage({
defaultMessage: "Download invoice",
})}
</Button>
)
}

View File

@@ -22,7 +22,9 @@ export default function ManageBooking({ bookingUrl }: ManageBookingProps) {
>
<Link color="none" href={bookingUrl} weight="bold">
<MaterialIcon icon="edit_square" color="CurrentColor" />
{intl.formatMessage({ id: "Manage booking" })}
{intl.formatMessage({
defaultMessage: "Manage booking",
})}
</Link>
</Button>
)

View File

@@ -32,7 +32,8 @@ export default function Header({
const text = intl.formatMessage(
{
id: "Thank you for booking with us! We look forward to welcoming you and hope you have a pleasant stay. If you have any questions or need to make changes to your reservation, please <emailLink>contact us.</emailLink>",
defaultMessage:
"Thank you for booking with us! We look forward to welcoming you and hope you have a pleasant stay. If you have any questions or need to make changes to your reservation, please <emailLink>contact us.</emailLink>",
},
{
emailLink: (str) => (
@@ -68,7 +69,9 @@ export default function Header({
<header className={styles.header}>
<hgroup className={styles.hgroup}>
<Title as="h2" color="red" textTransform="uppercase" type="h2">
{intl.formatMessage({ id: "Booking confirmation" })}
{intl.formatMessage({
defaultMessage: "Booking confirmation",
})}
</Title>
<Title as="h2" color="burgundy" textTransform="uppercase" type="h1">
{hotel.name}
@@ -76,7 +79,9 @@ export default function Header({
</hgroup>
<Subtitle color="uiTextHighContrast" type="two">
{intl.formatMessage(
{ id: "Booking number {value}" },
{
defaultMessage: "Booking number {value}",
},
{
value: booking.confirmationNumber,
}

View File

@@ -18,13 +18,17 @@ export default function HotelDetails({
<div className={styles.container}>
<div className={styles.details}>
<Subtitle color="uiTextHighContrast" type="two">
{intl.formatMessage({ id: "Hotel details" })}
{intl.formatMessage({
defaultMessage: "Hotel details",
})}
</Subtitle>
<div className={styles.hotel}>
<Body color="uiTextHighContrast">{hotel.name}</Body>
<Body color="uiTextHighContrast">
{intl.formatMessage(
{ id: "{streetAddress}, {zipCode} {city}" },
{
defaultMessage: "{streetAddress}, {zipCode} {city}",
},
{
streetAddress: hotel.address.streetAddress,
zipCode: hotel.address.zipCode,

View File

@@ -24,13 +24,17 @@ export default function PaymentDetails() {
return (
<div className={styles.details}>
<Subtitle color="uiTextHighContrast" type="two">
{intl.formatMessage({ id: "Payment details" })}
{intl.formatMessage({
defaultMessage: "Payment details",
})}
</Subtitle>
<div className={styles.payment}>
{hasAllRoomsLoaded ? (
<Body color="uiTextHighContrast">
{intl.formatMessage(
{ id: "Total cost: {amount}" },
{
defaultMessage: "Total cost: {amount}",
},
{
amount: formattedTotalCost,
}

View File

@@ -117,7 +117,9 @@ export default function PriceDetailsModal() {
const diff = dt(checkOutDate).diff(checkInDate, "days")
const nights = intl.formatMessage(
{ id: "{totalNights, plural, one {# night} other {# nights}}" },
{
defaultMessage: "{totalNights, plural, one {# night} other {# nights}}",
},
{ totalNights: diff }
)
@@ -126,11 +128,15 @@ export default function PriceDetailsModal() {
${dt(toDate).locale(lang).format("ddd, D MMM")} (${nights})`
return (
<Modal
title={intl.formatMessage({ id: "Price details" })}
title={intl.formatMessage({
defaultMessage: "Price details",
})}
trigger={
<Button intent="text">
<Caption color="burgundy">
{intl.formatMessage({ id: "Price details" })}
{intl.formatMessage({
defaultMessage: "Price details",
})}
</Caption>
<MaterialIcon icon="chevron_right" color="CurrentColor" size={20} />
</Button>
@@ -144,7 +150,9 @@ export default function PriceDetailsModal() {
{rooms.length > 1 && (
<TableSectionHeader
title={intl.formatMessage(
{ id: "Room {roomIndex}" },
{
defaultMessage: "Room {roomIndex}",
},
{ roomIndex: idx + 1 }
)}
bold
@@ -172,7 +180,9 @@ export default function PriceDetailsModal() {
) : null}
<Row
bold
label={intl.formatMessage({ id: "Room charge" })}
label={intl.formatMessage({
defaultMessage: "Room charge",
})}
value={room.formattedRoomCost}
/>
</TableSection>
@@ -182,7 +192,8 @@ export default function PriceDetailsModal() {
<Row
label={intl.formatMessage(
{
id: "Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}",
defaultMessage:
"Breakfast ({totalAdults, plural, one {# adult} other {# adults}}) x {totalBreakfasts}",
},
{ totalAdults: room.adults, totalBreakfasts: diff }
)}
@@ -196,7 +207,8 @@ export default function PriceDetailsModal() {
<Row
label={intl.formatMessage(
{
id: "Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
defaultMessage:
"Breakfast ({totalChildren, plural, one {# child} other {# children}}) x {totalBreakfasts}",
},
{
totalChildren: room.childrenAges.length,
@@ -209,7 +221,7 @@ export default function PriceDetailsModal() {
<Row
bold
label={intl.formatMessage({
id: "Breakfast charge",
defaultMessage: "Breakfast charge",
})}
value={formatPrice(
intl,
@@ -223,15 +235,26 @@ export default function PriceDetailsModal() {
) : null
})}
<TableSection>
<TableSectionHeader title={intl.formatMessage({ id: "Total" })} />
<TableSectionHeader
title={intl.formatMessage({
defaultMessage: "Total",
})}
/>
{isVatCurrency ? (
<>
<Row
label={intl.formatMessage({ id: "Price excluding VAT" })}
label={intl.formatMessage({
defaultMessage: "Price excluding VAT",
})}
value={formatPrice(intl, bookingTotal.priceExVat, currencyCode)}
/>
<Row
label={intl.formatMessage({ id: "VAT {vat}%" }, { vat })}
label={intl.formatMessage(
{
defaultMessage: "VAT {vat}%",
},
{ vat }
)}
value={formatPrice(intl, bookingTotal.vatAmount, currencyCode)}
/>
</>
@@ -239,7 +262,11 @@ export default function PriceDetailsModal() {
<tr className={styles.row}>
<td>
<Typography variant="Body/Paragraph/mdBold">
<span>{intl.formatMessage({ id: "Price including VAT" })}</span>
<span>
{intl.formatMessage({
defaultMessage: "Price including VAT",
})}
</span>
</Typography>
</td>
<td className={styles.price}>
@@ -257,7 +284,10 @@ export default function PriceDetailsModal() {
icon={<DiscountIcon color="Icon/Feedback/Information" />}
>
{intl.formatMessage(
{ id: "<strong>Booking code</strong>: {value}" },
{
defaultMessage:
"<strong>Booking code</strong>: {value}",
},
{
value: bookingCode,
strong: (text) => (

View File

@@ -25,20 +25,30 @@ export default function Promos({
return (
<div className={styles.promos}>
<Promo
buttonText={intl.formatMessage({ id: "View and buy add-ons" })}
buttonText={intl.formatMessage({
defaultMessage: "View and buy add-ons",
})}
href={`${myBookingUrl}?bookingId=${confirmationNumber}&lastName=${lastName}`}
text={intl.formatMessage({
id: "Discover the little extra touches to make your upcoming stay even more unforgettable.",
defaultMessage:
"Discover the little extra touches to make your upcoming stay even more unforgettable.",
})}
title={intl.formatMessage({
defaultMessage: "Spice things up",
})}
title={intl.formatMessage({ id: "Spice things up" })}
/>
<Promo
buttonText={intl.formatMessage({ id: "Book another stay" })}
buttonText={intl.formatMessage({
defaultMessage: "Book another stay",
})}
href={`${homeUrl}?hotel=${hotelId}`}
text={intl.formatMessage({
id: "Get inspired and start dreaming beyond your next trip. Explore more Scandic destinations.",
defaultMessage:
"Get inspired and start dreaming beyond your next trip. Explore more Scandic destinations.",
})}
title={intl.formatMessage({
defaultMessage: "Book your next stay",
})}
title={intl.formatMessage({ id: "Book your next stay" })}
/>
</div>
)

View File

@@ -66,7 +66,10 @@ export default function ReceiptRoom({
<Typography variant="Body/Paragraph/mdRegular">
<p className={styles.uiTextMediumContrast}>
{intl.formatMessage(
{ id: "{totalAdults, plural, one {# adult} other {# adults}}" },
{
defaultMessage:
"{totalAdults, plural, one {# adult} other {# adults}}",
},
{
totalAdults: room.adults,
}
@@ -88,7 +91,9 @@ export default function ReceiptRoom({
textDecoration="underline"
variant="icon"
>
{intl.formatMessage({ id: "Reservation policy" })}
{intl.formatMessage({
defaultMessage: "Reservation policy",
})}
<MaterialIcon icon="info" color="CurrentColor" />
</Link>
</Button>
@@ -101,8 +106,12 @@ export default function ReceiptRoom({
subtitle={
room.rateDefinition.cancellationRule ===
CancellationRuleEnum.CancellableBefore6PM
? intl.formatMessage({ id: "Pay later" })
: intl.formatMessage({ id: "Pay now" })
? intl.formatMessage({
defaultMessage: "Pay later",
})
: intl.formatMessage({
defaultMessage: "Pay now",
})
}
>
<div className={styles.terms}>
@@ -161,14 +170,18 @@ export default function ReceiptRoom({
<Typography variant="Body/Paragraph/mdRegular">
<p className={styles.uiTextHighContrast}>
{intl.formatMessage(
{ id: "Crib (child) × {count}" },
{
defaultMessage: "Crib (child) × {count}",
},
{ count: childBedCrib.quantity }
)}
</p>
</Typography>
<Typography variant="Body/Supporting text (caption)/smRegular">
<p className={styles.uiTextHighContrast}>
{intl.formatMessage({ id: "Based on availability" })}
{intl.formatMessage({
defaultMessage: "Based on availability",
})}
</p>
</Typography>
</div>
@@ -185,7 +198,9 @@ export default function ReceiptRoom({
<Typography variant="Body/Paragraph/mdRegular">
<p className={styles.uiTextHighContrast}>
{intl.formatMessage(
{ id: "Extra bed (child) × {count}" },
{
defaultMessage: "Extra bed (child) × {count}",
},
{
count: childBedExtraBed.quantity,
}
@@ -203,12 +218,18 @@ export default function ReceiptRoom({
{room.breakfast || breakfastIncluded ? (
<div className={styles.entry}>
<Typography variant="Body/Paragraph/mdRegular">
<p>{intl.formatMessage({ id: "Breakfast buffet" })}</p>
<p>
{intl.formatMessage({
defaultMessage: "Breakfast buffet",
})}
</p>
</Typography>
{breakfastIncluded ? (
<Typography variant="Body/Paragraph/mdRegular">
<p className={styles.red}>
{intl.formatMessage({ id: "Included" })}
{intl.formatMessage({
defaultMessage: "Included",
})}
</p>
</Typography>
) : null}

View File

@@ -30,7 +30,11 @@ export default function TotalPrice() {
<div className={styles.price}>
<div className={styles.entry}>
<Typography variant="Body/Paragraph/mdBold">
<p>{intl.formatMessage({ id: "Total price" })}</p>
<p>
{intl.formatMessage({
defaultMessage: "Total price",
})}
</p>
</Typography>
{hasAllRoomsLoaded ? (
<Typography variant="Body/Paragraph/mdBold">

View File

@@ -19,7 +19,9 @@ export default function Receipt() {
return (
<section className={styles.receipt}>
<Subtitle type="two">
{intl.formatMessage({ id: "Booking summary" })}
{intl.formatMessage({
defaultMessage: "Booking summary",
})}
</Subtitle>
{rooms.map((room, idx) => (
@@ -27,7 +29,9 @@ export default function Receipt() {
{rooms.length > 1 ? (
<Body color="uiTextHighContrast" textTransform={"bold"}>
{intl.formatMessage(
{ id: "Room {roomIndex}" },
{
defaultMessage: "Room {roomIndex}",
},
{ roomIndex: idx + 1 }
)}
</Body>

View File

@@ -13,10 +13,16 @@ export default function Retry({ handleRefetch }: RetryProps) {
const intl = useIntl()
return (
<div className={styles.retry}>
<Body>{intl.formatMessage({ id: "Something went wrong!" })}</Body>
<Body>
{intl.formatMessage({
defaultMessage: "Something went wrong!",
})}
</Body>
<Button size={"small"} onPress={handleRefetch}>
{intl.formatMessage({ id: "Try again" })}
{intl.formatMessage({
defaultMessage: "Try again",
})}
</Button>
</div>
)

View File

@@ -50,7 +50,9 @@ export default function Room({
size={20}
/>
<Caption>
{intl.formatMessage({ id: "Membership benefits applied" })}
{intl.formatMessage({
defaultMessage: "Membership benefits applied",
})}
</Caption>
</>
) : null}
@@ -65,10 +67,15 @@ export default function Room({
<Typography variant="Body/Supporting text (caption)/smRegular">
<p>
<strong>
{intl.formatMessage({ id: "Booking guaranteed." })}
</strong>{" "}
{intl.formatMessage({
defaultMessage: "Booking guaranteed.",
})}
</strong>
{/* eslint-disable formatjs/no-literal-string-in-jsx */}{" "}
{/* eslint-enable formatjs/no-literal-string-in-jsx */}
{intl.formatMessage({
id: "Your room will remain available for check-in even after 18:00.",
defaultMessage:
"Your room will remain available for check-in even after 18:00.",
})}
</p>
</Typography>
@@ -92,7 +99,9 @@ export default function Room({
{roomName}
</Subtitle>
<Link color="burgundy" href="" variant="icon">
{intl.formatMessage({ id: "View room details" })}
{intl.formatMessage({
defaultMessage: "View room details",
})}
<MaterialIcon
icon="chevron_right"
size={20}
@@ -103,11 +112,15 @@ export default function Room({
<ul className={styles.details}>
<li className={styles.listItem}>
<Body color="uiTextPlaceholder">
{intl.formatMessage({ id: "Check-in" })}
{intl.formatMessage({
defaultMessage: "Check-in",
})}
</Body>
<Body color="uiTextHighContrast">
{intl.formatMessage(
{ id: "{checkInDate} from {checkInTime}" },
{
defaultMessage: "{checkInDate} from {checkInTime}",
},
{
checkInDate: fromDate.format("ddd, D MMM"),
checkInTime: checkInTime,
@@ -117,11 +130,15 @@ export default function Room({
</li>
<li className={styles.listItem}>
<Body color="uiTextPlaceholder">
{intl.formatMessage({ id: "Check-out" })}
{intl.formatMessage({
defaultMessage: "Check-out",
})}
</Body>
<Body color="uiTextHighContrast">
{intl.formatMessage(
{ id: "{checkOutDate} from {checkOutTime}" },
{
defaultMessage: "{checkOutDate} from {checkOutTime}",
},
{
checkOutDate: toDate.format("ddd, D MMM"),
checkOutTime: checkOutTime,
@@ -131,7 +148,9 @@ export default function Room({
</li>
<li className={styles.listItem}>
<Body color="uiTextPlaceholder">
{intl.formatMessage({ id: "Cancellation policy" })}
{intl.formatMessage({
defaultMessage: "Cancellation policy",
})}
</Body>
<Body color="uiTextHighContrast">
{booking.rateDefinition.cancellationText}
@@ -140,11 +159,15 @@ export default function Room({
{isFlexBooking || isChangeBooking ? (
<li className={styles.listItem}>
<Body color="uiTextPlaceholder">
{intl.formatMessage({ id: "Rebooking" })}
{intl.formatMessage({
defaultMessage: "Rebooking",
})}
</Body>
<Body color="uiTextHighContrast">
{intl.formatMessage(
{ id: "Until {time}, {date}" },
{
defaultMessage: "Until {time}, {date}",
},
{ time: "18:00", date: fromDate.format("dddd D MMM") }
)}
</Body>
@@ -153,13 +176,17 @@ export default function Room({
</ul>
<div className={styles.guest}>
<Body color="uiTextPlaceholder">
{intl.formatMessage({ id: "Main guest" })}
{intl.formatMessage({
defaultMessage: "Main guest",
})}
</Body>
<Body color="uiTextHighContrast">{guestName}</Body>
{booking.guest.membershipNumber ? (
<Body color="uiTextHighContrast">
{intl.formatMessage(
{ id: "Friend no. {value}" },
{
defaultMessage: "Friend no. {value}",
},
{
value: booking.guest.membershipNumber,
}

View File

@@ -22,7 +22,12 @@ export default async function Rooms({
<div className={styles.room}>
{linkedReservations.length ? (
<Subtitle color="mainGrey60" type="two">
{intl.formatMessage({ id: "Room {roomIndex}" }, { roomIndex: 1 })}
{intl.formatMessage(
{
defaultMessage: "Room {roomIndex}",
},
{ roomIndex: 1 }
)}
</Subtitle>
) : null}
<Room
@@ -38,7 +43,9 @@ export default async function Rooms({
<div className={styles.room} key={reservation.confirmationNumber}>
<Subtitle color="mainGrey60" type="two">
{intl.formatMessage(
{ id: "Room {roomIndex}" },
{
defaultMessage: "Room {roomIndex}",
},
{ roomIndex: idx + 2 }
)}
</Subtitle>