Merged in feat/SW-1468 (pull request #2529)
feat(SW-1468): add restaurant name mapping * feat(SW-1468): add restaurant name mapping Approved-by: Bianca Widstam Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
@@ -40,7 +40,6 @@ export default async function RestaurantSidebar({
|
|||||||
key={details.openingHours.name}
|
key={details.openingHours.name}
|
||||||
openingHours={details.openingHours}
|
openingHours={details.openingHours}
|
||||||
alternateOpeningHours={details.alternateOpeningHours}
|
alternateOpeningHours={details.alternateOpeningHours}
|
||||||
heading={details.openingHours.name}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { Divider } from "@scandic-hotels/design-system/Divider"
|
|||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import AlternateOpeningHours from "./AlternateOpeningHours"
|
import AlternateOpeningHours from "./AlternateOpeningHours"
|
||||||
import { getGroupedOpeningHours } from "./utils"
|
import { getGroupedOpeningHours, getTranslatedName } from "./utils"
|
||||||
|
|
||||||
import styles from "./openingHours.module.css"
|
import styles from "./openingHours.module.css"
|
||||||
|
|
||||||
@@ -25,11 +25,12 @@ export default function OpeningHours({
|
|||||||
}: OpeningHoursProps) {
|
}: OpeningHoursProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
const groupedOpeningHours = getGroupedOpeningHours(openingHours, intl)
|
const groupedOpeningHours = getGroupedOpeningHours(openingHours, intl)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrapper}>
|
<div className={styles.wrapper}>
|
||||||
<Typography variant="Title/Overline/sm">
|
<Typography variant="Title/Overline/sm">
|
||||||
<h5 className={styles.heading}>{heading ?? openingHours.name}</h5>
|
<h5 className={styles.heading}>
|
||||||
|
{heading ?? getTranslatedName(openingHours.nameEnglish, intl)}
|
||||||
|
</h5>
|
||||||
</Typography>
|
</Typography>
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ describe("getGroupedOpeningHours", () => {
|
|||||||
const allDaysClosed: RestaurantOpeningHours = {
|
const allDaysClosed: RestaurantOpeningHours = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Opening hours",
|
name: "Opening hours",
|
||||||
|
nameEnglish: "Opening hours",
|
||||||
monday: {
|
monday: {
|
||||||
isClosed: true,
|
isClosed: true,
|
||||||
alwaysOpen: false,
|
alwaysOpen: false,
|
||||||
@@ -86,6 +87,7 @@ describe("getGroupedOpeningHours", () => {
|
|||||||
const allDaysSameHours: RestaurantOpeningHours = {
|
const allDaysSameHours: RestaurantOpeningHours = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Opening hours",
|
name: "Opening hours",
|
||||||
|
nameEnglish: "Opening hours",
|
||||||
monday: {
|
monday: {
|
||||||
openingTime: "09:00",
|
openingTime: "09:00",
|
||||||
closingTime: "17:00",
|
closingTime: "17:00",
|
||||||
@@ -144,6 +146,7 @@ describe("getGroupedOpeningHours", () => {
|
|||||||
const mixedOpeningHours: RestaurantOpeningHours = {
|
const mixedOpeningHours: RestaurantOpeningHours = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Opening hours",
|
name: "Opening hours",
|
||||||
|
nameEnglish: "Opening hours",
|
||||||
monday: {
|
monday: {
|
||||||
openingTime: "09:00",
|
openingTime: "09:00",
|
||||||
closingTime: "17:00",
|
closingTime: "17:00",
|
||||||
@@ -206,6 +209,7 @@ describe("getGroupedOpeningHours", () => {
|
|||||||
const someAlwaysOpen: RestaurantOpeningHours = {
|
const someAlwaysOpen: RestaurantOpeningHours = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Opening hours",
|
name: "Opening hours",
|
||||||
|
nameEnglish: "Opening hours",
|
||||||
monday: {
|
monday: {
|
||||||
alwaysOpen: true,
|
alwaysOpen: true,
|
||||||
isClosed: false,
|
isClosed: false,
|
||||||
@@ -268,6 +272,7 @@ describe("getGroupedOpeningHours", () => {
|
|||||||
const missingDays: RestaurantOpeningHours = {
|
const missingDays: RestaurantOpeningHours = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Opening hours",
|
name: "Opening hours",
|
||||||
|
nameEnglish: "Opening hours",
|
||||||
monday: {
|
monday: {
|
||||||
openingTime: "09:00",
|
openingTime: "09:00",
|
||||||
closingTime: "17:00",
|
closingTime: "17:00",
|
||||||
@@ -302,6 +307,7 @@ describe("getGroupedOpeningHours", () => {
|
|||||||
const nonConsecutiveSameHours: RestaurantOpeningHours = {
|
const nonConsecutiveSameHours: RestaurantOpeningHours = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Opening hours",
|
name: "Opening hours",
|
||||||
|
nameEnglish: "Opening hours",
|
||||||
monday: {
|
monday: {
|
||||||
openingTime: "09:00",
|
openingTime: "09:00",
|
||||||
closingTime: "17:00",
|
closingTime: "17:00",
|
||||||
@@ -336,6 +342,7 @@ describe("getGroupedOpeningHours", () => {
|
|||||||
const nullableHours: RestaurantOpeningHours = {
|
const nullableHours: RestaurantOpeningHours = {
|
||||||
isActive: true,
|
isActive: true,
|
||||||
name: "Opening hours",
|
name: "Opening hours",
|
||||||
|
nameEnglish: "Opening hours",
|
||||||
monday: {
|
monday: {
|
||||||
openingTime: "",
|
openingTime: "",
|
||||||
closingTime: "",
|
closingTime: "",
|
||||||
@@ -370,6 +377,7 @@ describe("getGroupedOpeningHours", () => {
|
|||||||
const inactiveHours: RestaurantOpeningHours = {
|
const inactiveHours: RestaurantOpeningHours = {
|
||||||
isActive: false,
|
isActive: false,
|
||||||
name: "Opening hours",
|
name: "Opening hours",
|
||||||
|
nameEnglish: "Opening hours",
|
||||||
monday: {
|
monday: {
|
||||||
openingTime: "09:00",
|
openingTime: "09:00",
|
||||||
closingTime: "17:00",
|
closingTime: "17:00",
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { logger } from "@scandic-hotels/common/logger"
|
||||||
|
|
||||||
import type { RestaurantOpeningHours } from "@scandic-hotels/trpc/types/hotel"
|
import type { RestaurantOpeningHours } from "@scandic-hotels/trpc/types/hotel"
|
||||||
import type { IntlShape } from "react-intl"
|
import type { IntlShape } from "react-intl"
|
||||||
|
|
||||||
@@ -108,3 +110,62 @@ export function getGroupedOpeningHours(
|
|||||||
}
|
}
|
||||||
return groupedOpeningHours
|
return groupedOpeningHours
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTranslatedName(name: string, intl: IntlShape) {
|
||||||
|
switch (name) {
|
||||||
|
case "Breakfast":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Breakfast",
|
||||||
|
})
|
||||||
|
case "Brunch":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Brunch",
|
||||||
|
})
|
||||||
|
case "After Work":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "After Work",
|
||||||
|
})
|
||||||
|
case "Cafe":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Cafe",
|
||||||
|
})
|
||||||
|
case "Lunch":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Lunch",
|
||||||
|
})
|
||||||
|
case "Dinner":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Dinner",
|
||||||
|
})
|
||||||
|
case "Bar":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Bar",
|
||||||
|
})
|
||||||
|
case "Snacks & drinks":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Snacks & drinks",
|
||||||
|
})
|
||||||
|
case "Takeaway":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Takeaway",
|
||||||
|
})
|
||||||
|
case "Changes":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Changes",
|
||||||
|
})
|
||||||
|
case "Live events":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Live events",
|
||||||
|
})
|
||||||
|
case "Terrace":
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "Terrace",
|
||||||
|
})
|
||||||
|
default:
|
||||||
|
logger.warn(`Unsupported name given: ${name}`)
|
||||||
|
|
||||||
|
return intl.formatMessage({
|
||||||
|
defaultMessage: "N/A",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ export const openingHoursSchema = z.object({
|
|||||||
isActive: z.boolean().default(false),
|
isActive: z.boolean().default(false),
|
||||||
monday: openingHoursDetailsSchema.optional(),
|
monday: openingHoursDetailsSchema.optional(),
|
||||||
name: nullableStringValidator,
|
name: nullableStringValidator,
|
||||||
|
nameEnglish: nullableStringValidator,
|
||||||
saturday: openingHoursDetailsSchema.optional(),
|
saturday: openingHoursDetailsSchema.optional(),
|
||||||
sunday: openingHoursDetailsSchema.optional(),
|
sunday: openingHoursDetailsSchema.optional(),
|
||||||
thursday: openingHoursDetailsSchema.optional(),
|
thursday: openingHoursDetailsSchema.optional(),
|
||||||
|
|||||||
Reference in New Issue
Block a user