feat(SW-1012): rename function
This commit is contained in:
@@ -25,11 +25,7 @@ export default async function OpeningHours({
|
|||||||
Days.Sunday,
|
Days.Sunday,
|
||||||
]
|
]
|
||||||
|
|
||||||
function dayInterval(days: string[]) {
|
const groupedOpeningHours: { [key: string]: string[] } = {}
|
||||||
if (days.length === 1) return days[0]
|
|
||||||
return `${days[0]}-${days[days.length - 1]}`
|
|
||||||
}
|
|
||||||
const groups: { [key: string]: string[] } = {}
|
|
||||||
|
|
||||||
days.forEach((day) => {
|
days.forEach((day) => {
|
||||||
const today = openingHours[day] as RestaurantOpeningHoursDay
|
const today = openingHours[day] as RestaurantOpeningHoursDay
|
||||||
@@ -43,22 +39,25 @@ export default async function OpeningHours({
|
|||||||
key = `${today.openingTime}-${today.closingTime}`
|
key = `${today.openingTime}-${today.closingTime}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!groups[key]) {
|
if (!groupedOpeningHours[key]) {
|
||||||
groups[key] = []
|
groupedOpeningHours[key] = []
|
||||||
}
|
}
|
||||||
const formattedDay = day.charAt(0).toUpperCase() + day.slice(1)
|
const formattedDay = day.charAt(0).toUpperCase() + day.slice(1)
|
||||||
groups[key].push(intl.formatMessage({ id: formattedDay }))
|
groupedOpeningHours[key].push(intl.formatMessage({ id: formattedDay }))
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log("Loooooop", groups)
|
function formatDayInterval(days: string[]) {
|
||||||
|
if (days.length === 1) return days[0]
|
||||||
|
return `${days[0]}-${days[days.length - 1]}`
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Body textTransform="bold">{openingHours.name}</Body>
|
<Body textTransform="bold">{openingHours.name}</Body>
|
||||||
{Object.entries(groups).map(([time, days]) => {
|
{Object.entries(groupedOpeningHours).map(([time, days]) => {
|
||||||
return (
|
return (
|
||||||
<Body color="uiTextHighContrast" key={time}>
|
<Body color="uiTextHighContrast" key={time}>
|
||||||
{`${dayInterval(days)}: ${time}`}
|
{`${formatDayInterval(days)}: ${time}`}
|
||||||
</Body>
|
</Body>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ export default async function RestaurantBarItem({
|
|||||||
{ctaUrl ? (
|
{ctaUrl ? (
|
||||||
<Button fullWidth theme="base" intent="secondary" asChild>
|
<Button fullWidth theme="base" intent="secondary" asChild>
|
||||||
<Link href={ctaUrl} color="burgundy" weight="bold">
|
<Link href={ctaUrl} color="burgundy" weight="bold">
|
||||||
{`${intl.formatMessage({ id: "Discover" })} ${name}`} {name}
|
{`${intl.formatMessage({ id: "Discover" })} ${name}`}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user