feat(SW-1012): format opening hours

This commit is contained in:
Fredrik Thorsson
2024-12-11 13:35:31 +01:00
parent c47523df96
commit abebfb1feb
8 changed files with 109 additions and 22 deletions

View File

@@ -1,37 +1,66 @@
import Body from "@/components/TempDesignSystem/Text/Body"
import { getIntl } from "@/i18n"
import { RestaurantBarOpeningHoursProps } from "@/types/components/hotelPage/sidepeek/restaurantBar"
import { RestaurantOpeningHoursDay } from "@/types/hotel"
import {
Days,
type RestaurantBarOpeningHoursProps,
} from "@/types/components/hotelPage/sidepeek/restaurantBar"
import type { RestaurantOpeningHoursDay } from "@/types/hotel"
export default function OpeningHours({
export default async function OpeningHours({
openingHours,
alternateOpeningHours,
}: RestaurantBarOpeningHoursProps) {
const intl = await getIntl()
const closed = intl.formatMessage({ id: "Closed" })
const alwaysOpen = intl.formatMessage({ id: "Always open" })
const days: (keyof typeof openingHours)[] = [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
Days.Monday,
Days.Tuesday,
Days.Wednesday,
Days.Thursday,
Days.Friday,
Days.Saturday,
Days.Sunday,
]
function dayInterval(days: string[]) {
if (days.length === 1) return days[0]
return `${days[0]}-${days[days.length - 1]}`
}
const groups: { [key: string]: string[] } = {}
days.forEach((day) => {
const today = openingHours[day] as RestaurantOpeningHoursDay
let key: string
if (today.isClosed) {
key = closed
} else if (today.alwaysOpen) {
key = alwaysOpen
} else {
key = `${today.openingTime}-${today.closingTime}`
}
if (!groups[key]) {
groups[key] = []
}
const formattedDay = day.charAt(0).toUpperCase() + day.slice(1)
groups[key].push(intl.formatMessage({ id: formattedDay }))
})
console.log("Loooooop", groups)
return (
<div>
<Body textTransform="bold">{openingHours.name}</Body>
{days.map((day) => {
const today = openingHours[day] as RestaurantOpeningHoursDay
return today ? (
<Body color="uiTextHighContrast">
{day}:{" "}
{today.isClosed
? "Closed"
: today.alwaysOpen
? "Always open"
: `${today.openingTime}-${today.closingTime}`}
{Object.entries(groups).map(([time, days]) => {
return (
<Body color="uiTextHighContrast" key={time}>
{`${dayInterval(days)}: ${time}`}
</Body>
) : null
)
})}
</div>
)

View File

@@ -87,6 +87,7 @@
"Close menu": "Luk menu",
"Close my pages menu": "Luk mine sider menu",
"Close the map": "Luk kortet",
"Closed": "Lukket",
"Code / Voucher": "Bookingkoder / voucher",
"Coming up": "Er lige om hjørnet",
"Compare all levels": "Sammenlign alle niveauer",
@@ -161,6 +162,7 @@
"Free cancellation": "Gratis afbestilling",
"Free parking": "Gratis parkering",
"Free rebooking": "Gratis ombooking",
"Friday": "Fredag",
"From": "Fra",
"Garage": "Garage",
"Get inspired": "Bliv inspireret",
@@ -249,6 +251,7 @@
"Menus": "Menukort",
"Modify": "Ændre",
"Mon-Fri": "Man-Fre",
"Monday": "Mandag",
"Month": "Måned",
"Museum": "Museum",
"My communication preferences": "Mine kommunikationspræferencer",
@@ -351,6 +354,7 @@
"Rooms": "Værelser",
"Rooms & Guests": "Værelser & gæster",
"Sat-Sun": "Lør-Søn",
"Saturday": "Lørdag",
"Sauna": "Sauna",
"Sauna and gym": "Sauna and gym",
"Save": "Gemme",
@@ -402,6 +406,7 @@
"Street": "Gade",
"Successfully updated profile!": "Profilen er opdateret med succes!",
"Summary": "Opsummering",
"Sunday": "Søndag",
"Surprise!": "Overraskelse!",
"TUI Points": "TUI Points",
"Tell us what information and updates you'd like to receive, and how, by clicking the link below.": "Fortæl os, hvilke oplysninger og opdateringer du gerne vil modtage, og hvordan, ved at klikke på linket nedenfor.",
@@ -416,6 +421,7 @@
"There are no transactions to display": "Der er ingen transaktioner at vise",
"Things nearby HOTEL_NAME": "Ting i nærheden af {hotelName}",
"This room is not available": "Dette værelse er ikke tilgængeligt",
"Thursday": "Torsdag",
"Times": "Tider",
"To get the member price <span>{price}</span>, log in or join when completing the booking.": "For at få medlemsprisen <span>{price}</span>, log ind eller tilmeld dig, når du udfylder bookingen.",
"To secure your reservation, we kindly ask you to provide your payment card details. Rest assured, no charges will be made at this time.": "For at sikre din reservation, beder vi om at du giver os dine betalingsoplysninger. Du kan så være sikker på, at ingen gebyrer vil blive opkrævet på dette tidspunkt.",
@@ -429,6 +435,7 @@
"Transportations": "Transport",
"TripAdvisor rating": "TripAdvisor vurdering",
"Tripadvisor reviews": "{rating} ({count} anmeldelser på Tripadvisor)",
"Tuesday": "Tirsdag",
"Type of bed": "Sengtype",
"Type of room": "Værelsestype",
"Use bonus cheque": "Brug Bonus Cheque",
@@ -443,6 +450,7 @@
"We have a special gift waiting for you!": "Vi har en speciel gave, der venter på dig!",
"We have sent a detailed confirmation of your booking to your email:": "Vi har sendt en detaljeret bekræftelse af din booking til din email:",
"We look forward to your visit!": "Vi ser frem til dit besøg!",
"Wednesday": "Onsdag",
"Weekday": "Ugedag",
"Weekday prices": "Ugedagspriser",
"Weekdays": "Hverdage",

View File

@@ -87,6 +87,7 @@
"Close menu": "Menü schließen",
"Close my pages menu": "Meine Seiten Menü schließen",
"Close the map": "Karte schließen",
"Closed": "Geschlossen",
"Code / Voucher": "Buchungscodes / Gutscheine",
"Coming up": "Demnächst",
"Compare all levels": "Vergleichen Sie alle Levels",
@@ -161,6 +162,7 @@
"Free cancellation": "Kostenlose Stornierung",
"Free parking": "Kostenloses Parken",
"Free rebooking": "Kostenlose Umbuchung",
"Friday": "Freitag",
"From": "Fromm",
"Garage": "Garage",
"Get inspired": "Lassen Sie sich inspieren",
@@ -248,6 +250,7 @@
"Menus": "Menüs",
"Modify": "Ändern",
"Mon-Fri": "Mo-Fr",
"Monday": "Montag",
"Month": "Monat",
"Museum": "Museum",
"My communication preferences": "Meine Kommunikationseinstellungen",
@@ -351,6 +354,7 @@
"Rooms": "Räume",
"Rooms & Guests": "Zimmer & Gäste",
"Sat-Sun": "Sa-So",
"Saturday": "Samstag",
"Sauna": "Sauna",
"Sauna and gym": "Sauna and gym",
"Save": "Speichern",
@@ -402,6 +406,7 @@
"Street": "Straße",
"Successfully updated profile!": "Profil erfolgreich aktualisiert!",
"Summary": "Zusammenfassung",
"Sunday": "Sonntag",
"Surprise!": "Überraschung!",
"TUI Points": "TUI Points",
"Tell us what information and updates you'd like to receive, and how, by clicking the link below.": "Teilen Sie uns mit, welche Informationen und Updates Sie wie erhalten möchten, indem Sie auf den unten stehenden Link klicken.",
@@ -415,6 +420,7 @@
"There are no transactions to display": "Es sind keine Transaktionen zum Anzeigen vorhanden",
"Things nearby HOTEL_NAME": "Dinge in der Nähe von {hotelName}",
"This room is not available": "Dieses Zimmer ist nicht verfügbar",
"Thursday": "Donnerstag",
"Times": "Zeiten",
"To get the member price <span>{price}</span>, log in or join when completing the booking.": "Um den Mitgliederpreis von <span>{price}</span> zu erhalten, loggen Sie sich ein oder treten Sie Scandic Friends bei, wenn Sie die Buchung abschließen.",
"To secure your reservation, we kindly ask you to provide your payment card details. Rest assured, no charges will be made at this time.": "Um Ihre Reservierung zu sichern, bitten wir Sie, Ihre Zahlungskarteninformationen zu geben. Sie können sicher sein, dass keine Gebühren zu diesem Zeitpunkt erhoben werden.",
@@ -428,6 +434,7 @@
"Transportations": "Transportmittel",
"TripAdvisor rating": "TripAdvisor-Bewertung",
"Tripadvisor reviews": "{rating} ({count} Bewertungen auf Tripadvisor)",
"Tuesday": "Dienstag",
"Type of bed": "Bettentyp",
"Type of room": "Zimmerart",
"Use bonus cheque": "Bonusscheck nutzen",
@@ -442,6 +449,7 @@
"We have a special gift waiting for you!": "Wir haben ein besonderes Geschenk für Sie!",
"We have sent a detailed confirmation of your booking to your email:": "Wir haben eine detaillierte Bestätigung Ihrer Buchung an Ihre E-Mail gesendet:",
"We look forward to your visit!": "Wir freuen uns auf Ihren Besuch!",
"Wednesday": "Mittwoch",
"Weekday": "Wochentag",
"Weekday prices": "Wochentagspreise",
"Weekdays": "Wochentage",

View File

@@ -94,6 +94,7 @@
"Close menu": "Close menu",
"Close my pages menu": "Close my pages menu",
"Close the map": "Close the map",
"Closed": "Closed",
"Code / Voucher": "Code / Voucher",
"Coming up": "Coming up",
"Compare all levels": "Compare all levels",
@@ -170,6 +171,7 @@
"Free parking": "Free parking",
"Free rebooking": "Free rebooking",
"Free until": "Free until",
"Friday": "Friday",
"Friend no.": "Friend no.",
"From": "From",
"Garage": "Garage",
@@ -269,6 +271,7 @@
"Menus": "Menus",
"Modify": "Modify",
"Mon-Fri": "Mon-Fri",
"Monday": "Monday",
"Month": "Month",
"Museum": "Museum",
"My communication preferences": "My communication preferences",
@@ -386,6 +389,7 @@
"Rooms": "Rooms",
"Rooms & Guests": "Rooms & Guests",
"Sat-Sun": "Sat-Sun",
"Saturday": "Saturday",
"Sauna": "Sauna",
"Sauna and gym": "Sauna and gym",
"Save": "Save",
@@ -439,6 +443,7 @@
"Street": "Street",
"Successfully updated profile!": "Successfully updated profile!",
"Summary": "Summary",
"Sunday": "Sunday",
"Surprise!": "Surprise!",
"TUI Points": "TUI Points",
"Tell us what information and updates you'd like to receive, and how, by clicking the link below.": "Tell us what information and updates you'd like to receive, and how, by clicking the link below.",
@@ -452,6 +457,7 @@
"There are no transactions to display": "There are no transactions to display",
"Things nearby HOTEL_NAME": "Things nearby {hotelName}",
"This room is not available": "This room is not available",
"Thursday": "Thursday",
"Times": "Times",
"To get the member price <span>{price}</span>, log in or join when completing the booking.": "To get the member price <span>{price}</span>, log in or join when completing the booking.",
"To secure your reservation, we kindly ask you to provide your payment card details. Rest assured, no charges will be made at this time.": "To secure your reservation, we kindly ask you to provide your payment card details. Rest assured, no charges will be made at this time.",
@@ -465,6 +471,7 @@
"Transportations": "Transportations",
"TripAdvisor rating": "TripAdvisor rating",
"Tripadvisor reviews": "{rating} ({count} reviews on Tripadvisor)",
"Tuesday": "Tuesday",
"Type of bed": "Type of bed",
"Type of room": "Type of room",
"Use bonus cheque": "Use bonus cheque",
@@ -484,6 +491,7 @@
"We have a special gift waiting for you!": "We have a special gift waiting for you!",
"We have sent a detailed confirmation of your booking to your email:": "We have sent a detailed confirmation of your booking to your email: ",
"We look forward to your visit!": "We look forward to your visit!",
"Wednesday": "Wednesday",
"Weekday": "Weekday",
"Weekday prices": "Weekday prices",
"Weekdays": "Weekdays",

View File

@@ -87,6 +87,7 @@
"Close menu": "Sulje valikko",
"Close my pages menu": "Sulje omat sivut -valikko",
"Close the map": "Sulje kartta",
"Closed": "Suljettu",
"Code / Voucher": "Varauskoodit / kupongit",
"Coming up": "Tulossa",
"Compare all levels": "Vertaa kaikkia tasoja",
@@ -161,6 +162,7 @@
"Free cancellation": "Ilmainen peruutus",
"Free parking": "Ilmainen pysäköinti",
"Free rebooking": "Ilmainen uudelleenvaraus",
"Friday": "Perjantai",
"From": "From",
"Garage": "Autotalli",
"Get inspired": "Inspiroidu",
@@ -249,6 +251,7 @@
"Menus": "Valikot",
"Modify": "Muokkaa",
"Mon-Fri": "Ma-Pe",
"Monday": "Maanantai",
"Month": "Kuukausi",
"Museum": "Museo",
"My communication preferences": "Viestintämieltymykseni",
@@ -352,6 +355,7 @@
"Rooms & Guests": "Huoneet & Vieraat",
"Rooms & Guestss": "Huoneet & Vieraat",
"Sat-Sun": "La-Su",
"Saturday": "Lauantai",
"Sauna": "Sauna",
"Sauna and gym": "Sauna and gym",
"Save": "Tallenna",
@@ -403,6 +407,7 @@
"Street": "Katu",
"Successfully updated profile!": "Profiilin päivitys onnistui!",
"Summary": "Yhteenveto",
"Sunday": "Sunnuntai",
"Surprise!": "Yllätys!",
"TUI Points": "TUI Points",
"Tell us what information and updates you'd like to receive, and how, by clicking the link below.": "Kerro meille, mitä tietoja ja päivityksiä haluat saada ja miten, napsauttamalla alla olevaa linkkiä.",
@@ -416,6 +421,7 @@
"There are no transactions to display": "Näytettäviä tapahtumia ei ole",
"Things nearby HOTEL_NAME": "Lähellä olevia asioita {hotelName}",
"This room is not available": "Tämä huone ei ole käytettävissä",
"Thursday": "Torstai",
"Times": "Ajat",
"To get the member price <span>{price}</span>, log in or join when completing the booking.": "Jäsenhintaan saavat sisäänkirjautuneet tai liittyneet jäsenet.",
"To secure your reservation, we kindly ask you to provide your payment card details. Rest assured, no charges will be made at this time.": "Varmistaaksesi varauksen, pyydämme sinua antamaan meille maksukortin tiedot. Varmista, että ei veloiteta maksusi tällä hetkellä.",
@@ -429,6 +435,7 @@
"Transportations": "Kuljetukset",
"TripAdvisor rating": "TripAdvisor-luokitus",
"Tripadvisor reviews": "{rating} ({count} arvostelua TripAdvisorissa)",
"Tuesday": "Tiistai",
"Type of bed": "Vuodetyyppi",
"Type of room": "Huonetyyppi",
"Use bonus cheque": "Käytä bonussekkiä",
@@ -443,6 +450,7 @@
"We have a special gift waiting for you!": "Meillä on erityinen lahja odottamassa sinua!",
"We have sent a detailed confirmation of your booking to your email:": "Olemme lähettäneet yksityiskohtaisen varausvahvistuksen sähköpostiisi:",
"We look forward to your visit!": "Odotamme innolla vierailuasi!",
"Wednesday": "Keskiviikko",
"Weekday": "Arkipäivä",
"Weekday prices": "Arkisin hinnat",
"Weekdays": "Arkisin",

View File

@@ -87,6 +87,7 @@
"Close menu": "Lukk meny",
"Close my pages menu": "Lukk mine sidermenyn",
"Close the map": "Lukk kartet",
"Closed": "Stengt",
"Code / Voucher": "Bestillingskoder / kuponger",
"Coming up": "Kommer opp",
"Compare all levels": "Sammenlign alle nivåer",
@@ -160,6 +161,7 @@
"Free cancellation": "Gratis avbestilling",
"Free parking": "Gratis parkering",
"Free rebooking": "Gratis ombooking",
"Friday": "Fredag",
"From": "Fra",
"Garage": "Garasje",
"Get inspired": "Bli inspirert",
@@ -248,6 +250,7 @@
"Menus": "Menyer",
"Modify": "Endre",
"Mon-Fri": "Man-Fre",
"Monday": "Mandag",
"Month": "Måned",
"Museum": "Museum",
"My communication preferences": "Mine kommunikasjonspreferanser",
@@ -350,6 +353,7 @@
"Rooms": "Rom",
"Rooms & Guests": "Rom og gjester",
"Sat-Sun": "Lør-Søn",
"Saturday": "Lørdag",
"Sauna": "Badstue",
"Sauna and gym": "Sauna and gym",
"Save": "Lagre",
@@ -401,6 +405,7 @@
"Street": "Gate",
"Successfully updated profile!": "Vellykket oppdatert profil!",
"Summary": "Sammendrag",
"Sunday": "Søndag",
"Surprise!": "Overraskelse!",
"TUI Points": "TUI Points",
"Tell us what information and updates you'd like to receive, and how, by clicking the link below.": "Fortell oss hvilken informasjon og hvilke oppdateringer du ønsker å motta, og hvordan, ved å klikke på lenken nedenfor.",
@@ -414,6 +419,7 @@
"There are no transactions to display": "Det er ingen transaksjoner å vise",
"Things nearby HOTEL_NAME": "Ting i nærheten av {hotelName}",
"This room is not available": "Dette rommet er ikke tilgjengelig",
"Thursday": "Torsdag",
"Times": "Tider",
"To get the member price <span>{price}</span>, log in or join when completing the booking.": "For å få medlemsprisen <span>{price}</span>, logg inn eller bli med når du fullfører bestillingen.",
"To secure your reservation, we kindly ask you to provide your payment card details. Rest assured, no charges will be made at this time.": "For å sikre din reservasjon, ber vi om at du gir oss dine betalingskortdetaljer. Vær sikker på at ingen gebyrer vil bli belastet på dette tidspunktet.",
@@ -427,6 +433,7 @@
"Transportations": "Transport",
"TripAdvisor rating": "TripAdvisor vurdering",
"Tripadvisor reviews": "{rating} ({count} anmeldelser på Tripadvisor)",
"Tuesday": "Tirsdag",
"Type of bed": "Sengtype",
"Type of room": "Romtype",
"Use bonus cheque": "Bruk bonussjekk",
@@ -441,6 +448,7 @@
"We have a special gift waiting for you!": "Vi har en spesiell gave som venter på deg!",
"We have sent a detailed confirmation of your booking to your email:": "Vi har sendt en detaljert bekreftelse av din bestilling til din e-post:",
"We look forward to your visit!": "Vi ser frem til ditt besøk!",
"Wednesday": "Onsdag",
"Weekday": "Ukedag",
"Weekday prices": "Ukedagspriser",
"Weekdays": "Hverdager",

View File

@@ -87,6 +87,7 @@
"Close menu": "Stäng menyn",
"Close my pages menu": "Stäng mina sidor menyn",
"Close the map": "Stäng kartan",
"Closed": "Stängt",
"Code / Voucher": "Bokningskoder / kuponger",
"Coming up": "Kommer härnäst",
"Compare all levels": "Jämför alla nivåer",
@@ -160,6 +161,7 @@
"Free cancellation": "Fri avbokning",
"Free parking": "Gratis parkering",
"Free rebooking": "Fri ombokning",
"Friday": "Fredag",
"From": "Från",
"Garage": "Garage",
"Get inspired": "Bli inspirerad",
@@ -248,6 +250,7 @@
"Menus": "Menyer",
"Modify": "Ändra",
"Mon-Fri": "Mån-Fre",
"Monday": "Måndag",
"Month": "Månad",
"Museum": "Museum",
"My communication preferences": "Mina kommunikationspreferenser",
@@ -350,6 +353,7 @@
"Rooms": "Rum",
"Rooms & Guests": "Rum och gäster",
"Sat-Sun": "Lör-Sön",
"Saturday": "Lördag",
"Sauna": "Bastu",
"Sauna and gym": "Sauna and gym",
"Save": "Spara",
@@ -401,6 +405,7 @@
"Street": "Gata",
"Successfully updated profile!": "Profilen har uppdaterats framgångsrikt!",
"Summary": "Sammanfattning",
"Sunday": "Söndag",
"Surprise!": "Överraskning!",
"TUI Points": "TUI Points",
"Tell us what information and updates you'd like to receive, and how, by clicking the link below.": "Berätta för oss vilken information och vilka uppdateringar du vill få och hur genom att klicka på länken nedan.",
@@ -414,6 +419,7 @@
"There are no transactions to display": "Det finns inga transaktioner att visa",
"Things nearby HOTEL_NAME": "Saker i närheten av {hotelName}",
"This room is not available": "Detta rum är inte tillgängligt",
"Thursday": "Torsdag",
"Times": "Tider",
"To get the member price <span>{price}</span>, log in or join when completing the booking.": "För att få medlemsprisen <span>{price}</span>, logga in eller bli medlem när du slutför bokningen.",
"To secure your reservation, we kindly ask you to provide your payment card details. Rest assured, no charges will be made at this time.": "För att säkra din bokning ber vi om att du ger oss dina betalkortdetaljer. Välj säker på att ingen avgifter kommer att debiteras just nu.",
@@ -427,6 +433,7 @@
"Transportations": "Transport",
"TripAdvisor rating": "TripAdvisor-betyg",
"Tripadvisor reviews": "{rating} ({count} recensioner på Tripadvisor)",
"Tuesday": "Tisdag",
"Type of bed": "Sängtyp",
"Type of room": "Rumstyp",
"Use bonus cheque": "Använd bonuscheck",
@@ -441,6 +448,7 @@
"We have a special gift waiting for you!": "Vi har en speciell present som väntar på dig!",
"We have sent a detailed confirmation of your booking to your email:": "Vi har skickat en detaljerad bekräftelse av din bokning till din e-post:",
"We look forward to your visit!": "Vi ser fram emot ditt besök!",
"Wednesday": "Onsdag",
"Weekday": "Vardag",
"Weekday prices": "Vardagspriser",
"Weekdays": "Vardagar",

View File

@@ -1,5 +1,15 @@
import type { RestaurantData, RestaurantOpeningHours } from "@/types/hotel"
export enum Days {
Monday = "monday",
Tuesday = "tuesday",
Wednesday = "wednesday",
Thursday = "thursday",
Friday = "friday",
Saturday = "saturday",
Sunday = "sunday",
}
export interface RestaurantBarSidePeekProps {
restaurants: RestaurantData[]
}