Merged in fix/3697-prettier-configs (pull request #3396)
fix(SW-3691): Setup one prettier config for whole repo * Setup prettierrc in root and remove other configs Approved-by: Joakim Jäderberg Approved-by: Linus Flood
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
'use client'
|
||||
"use client"
|
||||
|
||||
import { useIntl } from 'react-intl'
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { Divider } from '../../Divider'
|
||||
import { Typography } from '../../Typography'
|
||||
import { Divider } from "../../Divider"
|
||||
import { Typography } from "../../Typography"
|
||||
|
||||
import { getGroupedOpeningHours } from '../utils'
|
||||
import { getGroupedOpeningHours } from "../utils"
|
||||
|
||||
import styles from '../openingHours.module.css'
|
||||
import type { AlternateOpeningHours } from '../openingHoursTypes'
|
||||
import styles from "../openingHours.module.css"
|
||||
import type { AlternateOpeningHours } from "../openingHoursTypes"
|
||||
|
||||
interface AlternateOpeningHoursProps {
|
||||
alternateOpeningHours: AlternateOpeningHours
|
||||
@@ -38,8 +38,8 @@ export default function AlternateOpeningHours({
|
||||
<h5 className={styles.heading}>
|
||||
{intl.formatMessage(
|
||||
{
|
||||
id: 'openingHours.alternateOpeningHours',
|
||||
defaultMessage: 'Alternate opening hours ({name})',
|
||||
id: "openingHours.alternateOpeningHours",
|
||||
defaultMessage: "Alternate opening hours ({name})",
|
||||
},
|
||||
{ name: alternateOpeningHours.name }
|
||||
)}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
'use client'
|
||||
"use client"
|
||||
|
||||
import { useIntl } from 'react-intl'
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { Divider } from '../Divider'
|
||||
import { Typography } from '../Typography'
|
||||
import { Divider } from "../Divider"
|
||||
import { Typography } from "../Typography"
|
||||
|
||||
import AlternateOpeningHours from './AlternateOpeningHours'
|
||||
import { getGroupedOpeningHours, getTranslatedName } from './utils'
|
||||
import AlternateOpeningHours from "./AlternateOpeningHours"
|
||||
import { getGroupedOpeningHours, getTranslatedName } from "./utils"
|
||||
|
||||
import styles from './openingHours.module.css'
|
||||
import styles from "./openingHours.module.css"
|
||||
import type {
|
||||
OpeningHours,
|
||||
AlternateOpeningHours as AlternateOpeningHoursType,
|
||||
} from './openingHoursTypes'
|
||||
} from "./openingHoursTypes"
|
||||
|
||||
interface OpeningHoursProps {
|
||||
openingHours: OpeningHours
|
||||
|
||||
@@ -1,187 +1,187 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
||||
import { getGroupedOpeningHours } from './utils'
|
||||
import { getGroupedOpeningHours } from "./utils"
|
||||
|
||||
import type { IntlShape } from 'react-intl'
|
||||
import { OpeningHours } from './openingHoursTypes'
|
||||
import type { IntlShape } from "react-intl"
|
||||
import { OpeningHours } from "./openingHoursTypes"
|
||||
|
||||
// Mock IntlShape for testing
|
||||
const mockIntl = {
|
||||
formatMessage: ({ defaultMessage }: { defaultMessage: string }) => {
|
||||
const messages: Record<string, string> = {
|
||||
Monday: 'Monday',
|
||||
Tuesday: 'Tuesday',
|
||||
Wednesday: 'Wednesday',
|
||||
Thursday: 'Thursday',
|
||||
Friday: 'Friday',
|
||||
Saturday: 'Saturday',
|
||||
Sunday: 'Sunday',
|
||||
Closed: 'Closed',
|
||||
'Always open': 'Always open',
|
||||
Monday: "Monday",
|
||||
Tuesday: "Tuesday",
|
||||
Wednesday: "Wednesday",
|
||||
Thursday: "Thursday",
|
||||
Friday: "Friday",
|
||||
Saturday: "Saturday",
|
||||
Sunday: "Sunday",
|
||||
Closed: "Closed",
|
||||
"Always open": "Always open",
|
||||
}
|
||||
return messages[defaultMessage] || defaultMessage
|
||||
},
|
||||
} as IntlShape
|
||||
|
||||
describe('getGroupedOpeningHours', () => {
|
||||
it('should group all days as closed', () => {
|
||||
describe("getGroupedOpeningHours", () => {
|
||||
it("should group all days as closed", () => {
|
||||
const allDaysClosed: OpeningHours = {
|
||||
isActive: true,
|
||||
nameEnglish: 'Opening hours',
|
||||
nameEnglish: "Opening hours",
|
||||
monday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 1,
|
||||
},
|
||||
tuesday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 2,
|
||||
},
|
||||
wednesday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 3,
|
||||
},
|
||||
thursday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 4,
|
||||
},
|
||||
friday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 5,
|
||||
},
|
||||
saturday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 6,
|
||||
},
|
||||
sunday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 7,
|
||||
},
|
||||
}
|
||||
const result = getGroupedOpeningHours(allDaysClosed, mockIntl)
|
||||
expect(result).toEqual(['Monday-Sunday: Closed'])
|
||||
expect(result).toEqual(["Monday-Sunday: Closed"])
|
||||
})
|
||||
|
||||
it('should group all days with same opening hours', () => {
|
||||
it("should group all days with same opening hours", () => {
|
||||
const allDaysSameHours: OpeningHours = {
|
||||
isActive: true,
|
||||
nameEnglish: 'Opening hours',
|
||||
nameEnglish: "Opening hours",
|
||||
monday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 1,
|
||||
},
|
||||
tuesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 2,
|
||||
},
|
||||
wednesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 3,
|
||||
},
|
||||
thursday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 4,
|
||||
},
|
||||
friday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 5,
|
||||
},
|
||||
saturday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 6,
|
||||
},
|
||||
sunday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 7,
|
||||
},
|
||||
}
|
||||
const result = getGroupedOpeningHours(allDaysSameHours, mockIntl)
|
||||
expect(result).toEqual(['Monday-Sunday: 09:00-17:00'])
|
||||
expect(result).toEqual(["Monday-Sunday: 09:00-17:00"])
|
||||
})
|
||||
|
||||
it('should handle mixed opening hours', () => {
|
||||
it("should handle mixed opening hours", () => {
|
||||
const mixedOpeningHours: OpeningHours = {
|
||||
isActive: true,
|
||||
nameEnglish: 'Opening hours',
|
||||
nameEnglish: "Opening hours",
|
||||
monday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 1,
|
||||
},
|
||||
tuesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 2,
|
||||
},
|
||||
wednesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 3,
|
||||
},
|
||||
thursday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 4,
|
||||
},
|
||||
friday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 5,
|
||||
},
|
||||
saturday: {
|
||||
openingTime: '10:00',
|
||||
closingTime: '15:00',
|
||||
openingTime: "10:00",
|
||||
closingTime: "15:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 6,
|
||||
@@ -189,54 +189,54 @@ describe('getGroupedOpeningHours', () => {
|
||||
sunday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 7,
|
||||
},
|
||||
}
|
||||
const result = getGroupedOpeningHours(mixedOpeningHours, mockIntl)
|
||||
expect(result).toEqual([
|
||||
'Monday-Friday: 09:00-17:00',
|
||||
'Saturday: 10:00-15:00',
|
||||
'Sunday: Closed',
|
||||
"Monday-Friday: 09:00-17:00",
|
||||
"Saturday: 10:00-15:00",
|
||||
"Sunday: Closed",
|
||||
])
|
||||
})
|
||||
|
||||
it('should handle always open days', () => {
|
||||
it("should handle always open days", () => {
|
||||
const someAlwaysOpen: OpeningHours = {
|
||||
isActive: true,
|
||||
nameEnglish: 'Opening hours',
|
||||
nameEnglish: "Opening hours",
|
||||
monday: {
|
||||
alwaysOpen: true,
|
||||
isClosed: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 1,
|
||||
},
|
||||
tuesday: {
|
||||
alwaysOpen: true,
|
||||
isClosed: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 2,
|
||||
},
|
||||
wednesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 3,
|
||||
},
|
||||
thursday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 4,
|
||||
},
|
||||
friday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 5,
|
||||
@@ -244,47 +244,47 @@ describe('getGroupedOpeningHours', () => {
|
||||
saturday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 6,
|
||||
},
|
||||
sunday: {
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
sortOrder: 7,
|
||||
},
|
||||
}
|
||||
const result = getGroupedOpeningHours(someAlwaysOpen, mockIntl)
|
||||
expect(result).toEqual([
|
||||
'Monday-Tuesday: Always open',
|
||||
'Wednesday-Friday: 09:00-17:00',
|
||||
'Saturday-Sunday: Closed',
|
||||
"Monday-Tuesday: Always open",
|
||||
"Wednesday-Friday: 09:00-17:00",
|
||||
"Saturday-Sunday: Closed",
|
||||
])
|
||||
})
|
||||
|
||||
it('should handle missing days', () => {
|
||||
it("should handle missing days", () => {
|
||||
const missingDays: OpeningHours = {
|
||||
isActive: true,
|
||||
nameEnglish: 'Opening hours',
|
||||
nameEnglish: "Opening hours",
|
||||
monday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 1,
|
||||
},
|
||||
wednesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 3,
|
||||
},
|
||||
friday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 5,
|
||||
@@ -292,33 +292,33 @@ describe('getGroupedOpeningHours', () => {
|
||||
}
|
||||
const result = getGroupedOpeningHours(missingDays, mockIntl)
|
||||
expect(result).toEqual([
|
||||
'Monday: 09:00-17:00',
|
||||
'Wednesday: 09:00-17:00',
|
||||
'Friday: 09:00-17:00',
|
||||
"Monday: 09:00-17:00",
|
||||
"Wednesday: 09:00-17:00",
|
||||
"Friday: 09:00-17:00",
|
||||
])
|
||||
})
|
||||
|
||||
it('should not group non-consecutive days with same hours', () => {
|
||||
it("should not group non-consecutive days with same hours", () => {
|
||||
const nonConsecutiveSameHours: OpeningHours = {
|
||||
isActive: true,
|
||||
nameEnglish: 'Opening hours',
|
||||
nameEnglish: "Opening hours",
|
||||
monday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 1,
|
||||
},
|
||||
tuesday: {
|
||||
openingTime: '10:00',
|
||||
closingTime: '18:00',
|
||||
openingTime: "10:00",
|
||||
closingTime: "18:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 2,
|
||||
},
|
||||
wednesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 3,
|
||||
@@ -326,33 +326,33 @@ describe('getGroupedOpeningHours', () => {
|
||||
}
|
||||
const result = getGroupedOpeningHours(nonConsecutiveSameHours, mockIntl)
|
||||
expect(result).toEqual([
|
||||
'Monday: 09:00-17:00',
|
||||
'Tuesday: 10:00-18:00',
|
||||
'Wednesday: 09:00-17:00',
|
||||
"Monday: 09:00-17:00",
|
||||
"Tuesday: 10:00-18:00",
|
||||
"Wednesday: 09:00-17:00",
|
||||
])
|
||||
})
|
||||
|
||||
it('should handle nullable opening/closing times', () => {
|
||||
it("should handle nullable opening/closing times", () => {
|
||||
const nullableHours: OpeningHours = {
|
||||
isActive: true,
|
||||
nameEnglish: 'Opening hours',
|
||||
nameEnglish: "Opening hours",
|
||||
monday: {
|
||||
openingTime: '',
|
||||
closingTime: '',
|
||||
openingTime: "",
|
||||
closingTime: "",
|
||||
isClosed: true,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 1,
|
||||
},
|
||||
tuesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '',
|
||||
openingTime: "09:00",
|
||||
closingTime: "",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 2,
|
||||
},
|
||||
wednesday: {
|
||||
openingTime: '',
|
||||
closingTime: '17:00',
|
||||
openingTime: "",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 3,
|
||||
@@ -360,26 +360,26 @@ describe('getGroupedOpeningHours', () => {
|
||||
}
|
||||
const result = getGroupedOpeningHours(nullableHours, mockIntl)
|
||||
expect(result).toEqual([
|
||||
'Monday: Closed',
|
||||
"Monday: Closed",
|
||||
// Tuesday and Wednesday won't appear in the result because they have empty string values
|
||||
// that don't match any of the conditions in the getGroupedOpeningHours function
|
||||
])
|
||||
})
|
||||
|
||||
it('should handle inactive restaurant hours', () => {
|
||||
it("should handle inactive restaurant hours", () => {
|
||||
const inactiveHours: OpeningHours = {
|
||||
isActive: false,
|
||||
nameEnglish: 'Opening hours',
|
||||
nameEnglish: "Opening hours",
|
||||
monday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 1,
|
||||
},
|
||||
tuesday: {
|
||||
openingTime: '09:00',
|
||||
closingTime: '17:00',
|
||||
openingTime: "09:00",
|
||||
closingTime: "17:00",
|
||||
isClosed: false,
|
||||
alwaysOpen: false,
|
||||
sortOrder: 2,
|
||||
@@ -388,6 +388,6 @@ describe('getGroupedOpeningHours', () => {
|
||||
// Even though isActive is false, the function should still process the hours
|
||||
// as it doesn't check for the isActive flag
|
||||
const result = getGroupedOpeningHours(inactiveHours, mockIntl)
|
||||
expect(result).toEqual(['Monday-Tuesday: 09:00-17:00'])
|
||||
expect(result).toEqual(["Monday-Tuesday: 09:00-17:00"])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,70 +1,70 @@
|
||||
import { logger } from '@scandic-hotels/common/logger'
|
||||
import { logger } from "@scandic-hotels/common/logger"
|
||||
|
||||
import type { IntlShape } from 'react-intl'
|
||||
import type { AlternateOpeningHours, OpeningHours } from './openingHoursTypes'
|
||||
import type { IntlShape } from "react-intl"
|
||||
import type { AlternateOpeningHours, OpeningHours } from "./openingHoursTypes"
|
||||
|
||||
export function getGroupedOpeningHours(
|
||||
openingHours: OpeningHours | AlternateOpeningHours,
|
||||
intl: IntlShape
|
||||
): string[] {
|
||||
const closedMsg = intl.formatMessage({
|
||||
id: 'openingHours.closed',
|
||||
defaultMessage: 'Closed',
|
||||
id: "openingHours.closed",
|
||||
defaultMessage: "Closed",
|
||||
})
|
||||
const alwaysOpenMsg = intl.formatMessage({
|
||||
id: 'openingHours.alwaysOpen',
|
||||
defaultMessage: 'Always open',
|
||||
id: "openingHours.alwaysOpen",
|
||||
defaultMessage: "Always open",
|
||||
})
|
||||
|
||||
// In order
|
||||
const weekdayDefinitions = [
|
||||
{
|
||||
key: 'monday',
|
||||
key: "monday",
|
||||
label: intl.formatMessage({
|
||||
id: 'common.monday',
|
||||
defaultMessage: 'Monday',
|
||||
id: "common.monday",
|
||||
defaultMessage: "Monday",
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'tuesday',
|
||||
key: "tuesday",
|
||||
label: intl.formatMessage({
|
||||
id: 'common.tuesday',
|
||||
defaultMessage: 'Tuesday',
|
||||
id: "common.tuesday",
|
||||
defaultMessage: "Tuesday",
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'wednesday',
|
||||
key: "wednesday",
|
||||
label: intl.formatMessage({
|
||||
id: 'common.wednesday',
|
||||
defaultMessage: 'Wednesday',
|
||||
id: "common.wednesday",
|
||||
defaultMessage: "Wednesday",
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'thursday',
|
||||
key: "thursday",
|
||||
label: intl.formatMessage({
|
||||
id: 'common.thursday',
|
||||
defaultMessage: 'Thursday',
|
||||
id: "common.thursday",
|
||||
defaultMessage: "Thursday",
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'friday',
|
||||
key: "friday",
|
||||
label: intl.formatMessage({
|
||||
id: 'common.friday',
|
||||
defaultMessage: 'Friday',
|
||||
id: "common.friday",
|
||||
defaultMessage: "Friday",
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'saturday',
|
||||
key: "saturday",
|
||||
label: intl.formatMessage({
|
||||
id: 'common.saturday',
|
||||
defaultMessage: 'Saturday',
|
||||
id: "common.saturday",
|
||||
defaultMessage: "Saturday",
|
||||
}),
|
||||
},
|
||||
{
|
||||
key: 'sunday',
|
||||
key: "sunday",
|
||||
label: intl.formatMessage({
|
||||
id: 'common.sunday',
|
||||
defaultMessage: 'Sunday',
|
||||
id: "common.sunday",
|
||||
defaultMessage: "Sunday",
|
||||
}),
|
||||
},
|
||||
] as const
|
||||
@@ -72,7 +72,7 @@ export function getGroupedOpeningHours(
|
||||
const groupedOpeningHours: string[] = []
|
||||
|
||||
let rangeWeekdays: string[] = []
|
||||
let rangeValue = ''
|
||||
let rangeValue = ""
|
||||
|
||||
for (let i = 0, n = weekdayDefinitions.length; i < n; ++i) {
|
||||
const weekdayDefinition = weekdayDefinitions[i]
|
||||
@@ -100,7 +100,7 @@ export function getGroupedOpeningHours(
|
||||
} else {
|
||||
if (rangeValue) {
|
||||
groupedOpeningHours.push(
|
||||
`${rangeWeekdays.join('-')}: ${rangeValue}`
|
||||
`${rangeWeekdays.join("-")}: ${rangeValue}`
|
||||
)
|
||||
}
|
||||
rangeValue = newValue
|
||||
@@ -109,11 +109,11 @@ export function getGroupedOpeningHours(
|
||||
}
|
||||
if (rangeValue && i === n - 1) {
|
||||
// Flush everything at the end
|
||||
groupedOpeningHours.push(`${rangeWeekdays.join('-')}: ${rangeValue}`)
|
||||
groupedOpeningHours.push(`${rangeWeekdays.join("-")}: ${rangeValue}`)
|
||||
}
|
||||
} else if (rangeValue) {
|
||||
groupedOpeningHours.push(`${rangeWeekdays.join('-')}: ${rangeValue}`)
|
||||
rangeValue = ''
|
||||
groupedOpeningHours.push(`${rangeWeekdays.join("-")}: ${rangeValue}`)
|
||||
rangeValue = ""
|
||||
rangeWeekdays = []
|
||||
}
|
||||
}
|
||||
@@ -123,72 +123,72 @@ export function getGroupedOpeningHours(
|
||||
export function getTranslatedName(name: string, intl: IntlShape) {
|
||||
const lowercaseName = name.toLowerCase()
|
||||
switch (lowercaseName) {
|
||||
case 'breakfast':
|
||||
case "breakfast":
|
||||
return intl.formatMessage({
|
||||
id: 'common.breakfast',
|
||||
defaultMessage: 'Breakfast',
|
||||
id: "common.breakfast",
|
||||
defaultMessage: "Breakfast",
|
||||
})
|
||||
case 'brunch':
|
||||
case "brunch":
|
||||
return intl.formatMessage({
|
||||
id: 'common.brunch',
|
||||
defaultMessage: 'Brunch',
|
||||
id: "common.brunch",
|
||||
defaultMessage: "Brunch",
|
||||
})
|
||||
case 'after work':
|
||||
case "after work":
|
||||
return intl.formatMessage({
|
||||
id: 'common.afterwork',
|
||||
defaultMessage: 'After Work',
|
||||
id: "common.afterwork",
|
||||
defaultMessage: "After Work",
|
||||
})
|
||||
case 'cafe':
|
||||
case "cafe":
|
||||
return intl.formatMessage({
|
||||
id: 'common.cafe',
|
||||
defaultMessage: 'Café',
|
||||
id: "common.cafe",
|
||||
defaultMessage: "Café",
|
||||
})
|
||||
case 'lunch':
|
||||
case "lunch":
|
||||
return intl.formatMessage({
|
||||
id: 'common.lunch',
|
||||
defaultMessage: 'Lunch',
|
||||
id: "common.lunch",
|
||||
defaultMessage: "Lunch",
|
||||
})
|
||||
case 'dinner':
|
||||
case "dinner":
|
||||
return intl.formatMessage({
|
||||
id: 'common.dinner',
|
||||
defaultMessage: 'Dinner',
|
||||
id: "common.dinner",
|
||||
defaultMessage: "Dinner",
|
||||
})
|
||||
case 'bar':
|
||||
case "bar":
|
||||
return intl.formatMessage({
|
||||
id: 'common.bar',
|
||||
defaultMessage: 'Bar',
|
||||
id: "common.bar",
|
||||
defaultMessage: "Bar",
|
||||
})
|
||||
case 'snacks & drinks':
|
||||
case "snacks & drinks":
|
||||
return intl.formatMessage({
|
||||
id: 'common.snacks&drinks',
|
||||
defaultMessage: 'Snacks & drinks',
|
||||
id: "common.snacks&drinks",
|
||||
defaultMessage: "Snacks & drinks",
|
||||
})
|
||||
case 'takeaway':
|
||||
case "takeaway":
|
||||
return intl.formatMessage({
|
||||
id: 'common.takeaway',
|
||||
defaultMessage: 'Takeaway',
|
||||
id: "common.takeaway",
|
||||
defaultMessage: "Takeaway",
|
||||
})
|
||||
case 'changes':
|
||||
case "changes":
|
||||
return intl.formatMessage({
|
||||
id: 'common.changes',
|
||||
defaultMessage: 'Changes',
|
||||
id: "common.changes",
|
||||
defaultMessage: "Changes",
|
||||
})
|
||||
case 'live events':
|
||||
case "live events":
|
||||
return intl.formatMessage({
|
||||
id: 'common.liveEvents',
|
||||
defaultMessage: 'Live events',
|
||||
id: "common.liveEvents",
|
||||
defaultMessage: "Live events",
|
||||
})
|
||||
case 'terrace':
|
||||
case "terrace":
|
||||
return intl.formatMessage({
|
||||
id: 'common.terrace',
|
||||
defaultMessage: 'Terrace',
|
||||
id: "common.terrace",
|
||||
defaultMessage: "Terrace",
|
||||
})
|
||||
default:
|
||||
logger.warn(`Unsupported name given: ${name}`)
|
||||
|
||||
return intl.formatMessage({
|
||||
id: 'common.NA',
|
||||
defaultMessage: 'N/A',
|
||||
id: "common.NA",
|
||||
defaultMessage: "N/A",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user