diff --git a/apps/scandic-web/components/BookingWidget/MobileToggleButton/button.module.css b/apps/scandic-web/components/BookingWidget/MobileToggleButton/button.module.css index d1ded62f8..cf100bcbd 100644 --- a/apps/scandic-web/components/BookingWidget/MobileToggleButton/button.module.css +++ b/apps/scandic-web/components/BookingWidget/MobileToggleButton/button.module.css @@ -24,7 +24,7 @@ .partial { grid-template-columns: - minmax(auto, 120px) min-content minmax(auto, 120px) + minmax(auto, 120px) min-content 1fr auto; } diff --git a/apps/scandic-web/components/BookingWidget/MobileToggleButton/index.tsx b/apps/scandic-web/components/BookingWidget/MobileToggleButton/index.tsx index a50e78f07..4c0246141 100644 --- a/apps/scandic-web/components/BookingWidget/MobileToggleButton/index.tsx +++ b/apps/scandic-web/components/BookingWidget/MobileToggleButton/index.tsx @@ -8,6 +8,7 @@ import { Divider } from "@scandic-hotels/design-system/Divider" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" +import { shortDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import SkeletonShimmer from "@/components/SkeletonShimmer" @@ -32,8 +33,12 @@ export default function MobileToggleButton({ name: "selectedSearch", }) - const selectedFromDate = dt(date.fromDate).locale(lang).format("D MMM") - const selectedToDate = dt(date.toDate).locale(lang).format("D MMM") + const selectedFromDate = dt(date.fromDate) + .locale(lang) + .format(shortDateFormat[lang]) + const selectedToDate = dt(date.toDate) + .locale(lang) + .format(shortDateFormat[lang]) const locationAndDateIsSet = searchTerm && date diff --git a/apps/scandic-web/components/DatePicker/index.tsx b/apps/scandic-web/components/DatePicker/index.tsx index 0a3d921e1..ab68d25ba 100644 --- a/apps/scandic-web/components/DatePicker/index.tsx +++ b/apps/scandic-web/components/DatePicker/index.tsx @@ -3,6 +3,7 @@ import { useCallback, useEffect, useRef, useState } from "react" import { useFormContext, useWatch } from "react-hook-form" import { useIntl } from "react-intl" +import { longDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import Body from "@/components/TempDesignSystem/Text/Body" @@ -128,9 +129,9 @@ export default function DatePickerForm({ name = "date" }: DatePickerFormProps) { const selectedFromDate = dt(selectedDate.fromDate) .locale(lang) - .format("ddd D MMM") + .format(longDateFormat[lang]) const selectedToDate = !!selectedDate.toDate - ? dt(selectedDate.toDate).locale(lang).format("ddd D MMM") + ? dt(selectedDate.toDate).locale(lang).format(longDateFormat[lang]) : "" return ( diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/index.tsx index 29ef63257..95bcd6140 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/index.tsx @@ -6,6 +6,7 @@ import { Divider } from "@scandic-hotels/design-system/Divider" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" +import { longDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import { useBookingConfirmationStore } from "@/stores/booking-confirmation" @@ -50,10 +51,10 @@ export default function Receipt() {

- {dt(fromDate).locale(lang).format("ddd, D MMM")} + {dt(fromDate).locale(lang).format(longDateFormat[lang])} {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} - {dt(toDate).locale(lang).format("ddd, D MMM")} ({nights}) + {dt(toDate).locale(lang).format(longDateFormat[lang])} ({nights})

diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/index.tsx index d7dff11dc..d73fc9cca 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/index.tsx @@ -6,6 +6,10 @@ import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" import { CancellationRuleEnum } from "@/constants/booking" +import { + changeOrCancelDateFormat, + longDateFormat, +} from "@/constants/dateFormats" import { dt } from "@/lib/dt" import Image from "@/components/Image" @@ -128,7 +132,7 @@ export default function Room({ defaultMessage: "{checkInDate} from {checkInTime}", }, { - checkInDate: fromDate.format("ddd, D MMM"), + checkInDate: fromDate.format(longDateFormat[lang]), checkInTime: checkInTime, } )} @@ -146,7 +150,7 @@ export default function Room({ defaultMessage: "{checkOutDate} from {checkOutTime}", }, { - checkOutDate: toDate.format("ddd, D MMM"), + checkOutDate: toDate.format(longDateFormat[lang]), checkOutTime: checkOutTime, } )} @@ -172,7 +176,10 @@ export default function Room({ { defaultMessage: "Until {time}, {date}", }, - { time: "18:00", date: fromDate.format("dddd D MMM") } + { + time: "18:00", + date: fromDate.format(changeOrCancelDateFormat[lang]), + } )}

diff --git a/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx b/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx index 24788bfe2..bc214435a 100644 --- a/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx +++ b/apps/scandic-web/components/HotelReservation/EnterDetails/Summary/UI/index.tsx @@ -8,6 +8,7 @@ import { Divider } from "@scandic-hotels/design-system/Divider" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" +import { longDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import BookingCodeChip from "@/components/BookingCodeChip" @@ -96,14 +97,15 @@ export default function SummaryUI({ })} - {dt(booking.fromDate).locale(lang).format("ddd, D MMM")} + {dt(booking.fromDate).locale(lang).format(longDateFormat[lang])} - {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} - {dt(booking.toDate).locale(lang).format("ddd, D MMM")} ({nightsMsg}) + {/* eslint-disable formatjs/no-literal-string-in-jsx */} + {dt(booking.toDate).locale(lang).format(longDateFormat[lang])} ( + {nightsMsg}){/* eslint-enable formatjs/no-literal-string-in-jsx */}
- {dt(booking.checkInDate).locale(lang).format("ddd, D MMM YYYY")} + {dt(booking.checkInDate) + .locale(lang) + .format(longDateWithYearFormat[lang])}
@@ -86,7 +89,9 @@ export default async function Footer({ booking, room }: FooterProps) {
- {dt(booking.checkOutDate).locale(lang).format("ddd, D MMM YYYY")} + {dt(booking.checkOutDate) + .locale(lang) + .format(longDateWithYearFormat[lang])}
diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/CancelStay/Steps/Confirmation/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/CancelStay/Steps/Confirmation/index.tsx index d5ae7a9c3..484fd172b 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/CancelStay/Steps/Confirmation/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/CancelStay/Steps/Confirmation/index.tsx @@ -4,6 +4,7 @@ import { useIntl } from "react-intl" import { Typography } from "@scandic-hotels/design-system/Typography" +import { longDateWithYearFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import { useMyStayStore } from "@/stores/my-stay" @@ -41,8 +42,12 @@ export default function CancelStayConfirmation({ }) ) - const checkInDate = dt(fromDate).locale(lang).format("dddd D MMM YYYY") - const checkOutDate = dt(toDate).locale(lang).format("dddd D MMM YYYY") + const checkInDate = dt(fromDate) + .locale(lang) + .format(longDateWithYearFormat[lang]) + const checkOutDate = dt(toDate) + .locale(lang) + .format(longDateWithYearFormat[lang]) const title = intl.formatMessage({ defaultMessage: "Cancel booking" }) const primaryLabel = intl.formatMessage({ diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Confirmation/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Confirmation/index.tsx index 57d3fcce2..7c2872d2e 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Confirmation/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Confirmation/index.tsx @@ -3,6 +3,7 @@ import { useIntl } from "react-intl" import { Divider } from "@scandic-hotels/design-system/Divider" +import { longDateWithYearFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import { trpc } from "@/lib/trpc/client" import { useMyStayStore } from "@/stores/my-stay" @@ -26,7 +27,7 @@ interface ConfirmationProps { } function formatDate(date: Date | string, lang: Lang) { - return dt(date).locale(lang).format("dddd, DD MMM, YYYY") + return dt(date).locale(lang).format(longDateWithYearFormat[lang]) } export default function Confirmation({ diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/NewDates/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/NewDates/index.tsx index 635af552b..b8f6ca74a 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/NewDates/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Actions/NotCancelled/ManageStay/Actions/ChangeDates/Steps/Form/NewDates/index.tsx @@ -10,6 +10,7 @@ import { useIntl } from "react-intl" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" +import { longDateWithYearFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import DatePickerSingleDesktop from "@/components/DatePicker/Single/Desktop" @@ -65,8 +66,12 @@ export default function NewDates({ checkInDate, checkOutDate }: NewDatesProps) { const checkInLabel = intl.formatMessage({ defaultMessage: "Check-in" }) const checkOutLabel = intl.formatMessage({ defaultMessage: "Check-out" }) - const checkInText = dt(fromDate).locale(lang).format("dddd, DD MMM, YYYY") - const checkOutText = dt(toDate).locale(lang).format("dddd, DD MMM, YYYY") + const checkInText = dt(fromDate) + .locale(lang) + .format(longDateWithYearFormat[lang]) + const checkOutText = dt(toDate) + .locale(lang) + .format(longDateWithYearFormat[lang]) return ( <>
diff --git a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Dates/index.tsx b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Dates/index.tsx index 5b436d4aa..32afd39b4 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Dates/index.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/ReferenceCard/Dates/index.tsx @@ -4,6 +4,7 @@ import { useIntl } from "react-intl" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" +import { shortDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import { useMyStayStore } from "@/stores/my-stay" @@ -19,9 +20,9 @@ export default function Dates() { checkOutDate: state.bookedRoom.checkOutDate, })) - const from = dt(checkInDate).locale(lang).format("D MMM") + const from = dt(checkInDate).locale(lang).format(shortDateFormat[lang]) const fromYear = dt(checkInDate).year() - const to = dt(checkOutDate).locale(lang).format("D MMM") + const to = dt(checkOutDate).locale(lang).format(shortDateFormat[lang]) const toYear = dt(checkOutDate).year() const isSameYear = fromYear === toYear diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Rooms/MultiRoom/Room.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Rooms/MultiRoom/Room.tsx index 2054b255f..15350f390 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Rooms/MultiRoom/Room.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Rooms/MultiRoom/Room.tsx @@ -7,6 +7,7 @@ import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" import { CancellationRuleEnum } from "@/constants/booking" +import { changeOrCancelDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import { IconForFeatureCode } from "@/components/HotelReservation/utils" @@ -296,7 +297,7 @@ export default function Room({ booking, roomNr, user }: RoomProps) { {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} -

18:00, {fromDate.format("dddd D MMM")}

+

18:00, {fromDate.format(changeOrCancelDateFormat[lang])}

)} diff --git a/apps/scandic-web/components/HotelReservation/MyStay/Rooms/SingleRoom/Details/ModifyBy.tsx b/apps/scandic-web/components/HotelReservation/MyStay/Rooms/SingleRoom/Details/ModifyBy.tsx index 0e67d817f..aa4bdfcee 100644 --- a/apps/scandic-web/components/HotelReservation/MyStay/Rooms/SingleRoom/Details/ModifyBy.tsx +++ b/apps/scandic-web/components/HotelReservation/MyStay/Rooms/SingleRoom/Details/ModifyBy.tsx @@ -1,5 +1,6 @@ import { useIntl } from "react-intl" +import { changeOrCancelDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import { useMyStayStore } from "@/stores/my-stay" @@ -31,7 +32,7 @@ export default function ModifyBy() { }, { time: "18:00", - date: fromDate.format("dddd D MMM"), + date: fromDate.format(changeOrCancelDateFormat[lang]), } ) diff --git a/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/index.tsx b/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/index.tsx index 9a4cb9ad5..4e7da9800 100644 --- a/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/index.tsx +++ b/apps/scandic-web/components/HotelReservation/PriceDetailsModal/PriceDetailsTable/index.tsx @@ -4,6 +4,7 @@ import { useIntl } from "react-intl" import { Typography } from "@scandic-hotels/design-system/Typography" +import { longDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import useLang from "@/hooks/useLang" @@ -82,8 +83,8 @@ export default function PriceDetailsTable({ { totalNights: nights } ) - const arrival = dt(fromDate).locale(lang).format("ddd, D MMM") - const departue = dt(toDate).locale(lang).format("ddd, D MMM") + const arrival = dt(fromDate).locale(lang).format(longDateFormat[lang]) + const departue = dt(toDate).locale(lang).format(longDateFormat[lang]) const duration = ` ${arrival} - ${departue} (${nightsMsg})` const isAllBreakfastIncluded = rooms.every((room) => room.breakfastIncluded) diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/Content/index.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/Content/index.tsx index b94e2963a..ce44b979c 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/Content/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/Content/index.tsx @@ -7,6 +7,7 @@ import { IconButton } from "@scandic-hotels/design-system/IconButton" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" +import { longDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import { useRatesStore } from "@/stores/select-rate" @@ -84,10 +85,11 @@ export default function SummaryContent({

- {dt(booking.fromDate).locale(lang).format("ddd, D MMM")} + {dt(booking.fromDate).locale(lang).format(longDateFormat[lang])} - {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} - {dt(booking.toDate).locale(lang).format("ddd, D MMM")} ({nights}) + {/* eslint-disable formatjs/no-literal-string-in-jsx */} + {dt(booking.toDate).locale(lang).format(longDateFormat[lang])} ( + {nights}){/* eslint-enable formatjs/no-literal-string-in-jsx */}

diff --git a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/Summary.tsx b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/Summary.tsx index 64a8cd579..184e09bba 100644 --- a/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/Summary.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectRate/RoomsContainer/RateSummary/MobileSummary/Summary.tsx @@ -7,6 +7,7 @@ import { Button } from "@scandic-hotels/design-system/Button" import { Divider } from "@scandic-hotels/design-system/Divider" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" +import { longDateFormat } from "@/constants/dateFormats" import { dt } from "@/lib/dt" import { useRatesStore } from "@/stores/select-rate" @@ -84,14 +85,15 @@ export default function Summary({ })} - {dt(booking.fromDate).locale(lang).format("ddd, D MMM")} + {dt(booking.fromDate).locale(lang).format(longDateFormat[lang])} - {/* eslint-disable-next-line formatjs/no-literal-string-in-jsx */} - {dt(booking.toDate).locale(lang).format("ddd, D MMM")} ({nights}) + {/* eslint-disable formatjs/no-literal-string-in-jsx */} + {dt(booking.toDate).locale(lang).format(longDateFormat[lang])} ( + {nights}){/* eslint-enable formatjs/no-literal-string-in-jsx */} diff --git a/apps/scandic-web/constants/dateFormats.ts b/apps/scandic-web/constants/dateFormats.ts new file mode 100644 index 000000000..24a454296 --- /dev/null +++ b/apps/scandic-web/constants/dateFormats.ts @@ -0,0 +1,37 @@ +import { Lang } from "@scandic-hotels/common/constants/language" + +export const longDateFormat = { + [Lang.en]: "ddd, D MMM", + [Lang.sv]: "ddd D MMM", + [Lang.no]: "ddd D. MMM", + [Lang.da]: "ddd D. MMM", + [Lang.de]: "ddd D. MMM", + [Lang.fi]: "ddd D.M", +} as const + +export const longDateWithYearFormat = { + [Lang.en]: "ddd, D MMM YYYY", + [Lang.sv]: "ddd D MMM YYYY", + [Lang.no]: "ddd D. MMM YYYY", + [Lang.da]: "ddd D. MMM YYYY", + [Lang.de]: "ddd D. MMM YYYY", + [Lang.fi]: "ddd D.M. YYYY", +} as const + +export const shortDateFormat = { + [Lang.en]: "D MMM", + [Lang.sv]: "D MMM", + [Lang.no]: "D. MMM", + [Lang.da]: "D. MMM", + [Lang.de]: "D. MMM", + [Lang.fi]: "D.MM.", +} as const + +export const changeOrCancelDateFormat = { + [Lang.sv]: "dddd D MMM", + [Lang.en]: "dddd D MMM", + [Lang.no]: "dddd D. MMM", + [Lang.da]: "dddd D. MMM", + [Lang.de]: "dddd D. MMM", + [Lang.fi]: "dd D MMMM", +} as const