fix(menu-app): crash when tagline/hours fields are null
The API now always sends restaurant.tagline/blurb as {en, gr} objects,
including when a site hasn't set them yet (both null). The old
`?? r.tagline` fallback rendered the whole object as a React child in
that case (React error #31) instead of falling back to a display
string. Fall back to the localized fallback string instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
eur, discountedPrice, discountPct,
|
||||
} from '../components/primitives'
|
||||
|
||||
// TODO: Replace with real data from API once backend includes restaurant info
|
||||
// Used when a site hasn't configured a field yet (API sends nulls until set in sysadmin)
|
||||
const RESTAURANT_FALLBACK = {
|
||||
name: 'Our Menu',
|
||||
tagline: { en: 'Kitchen & Bar', gr: 'Κουζίνα & Μπαρ' },
|
||||
@@ -160,7 +160,7 @@ function Hero({ lang, setLang, restaurant }) {
|
||||
</h1>
|
||||
)}
|
||||
<div className="mt-1.5 font-sans text-[14px] font-medium uppercase tracking-[0.18em] text-[#9caf88]">
|
||||
{r.tagline?.[lang] ?? r.tagline ?? ''}
|
||||
{r.tagline?.[lang] || RESTAURANT_FALLBACK.tagline[lang] || ''}
|
||||
</div>
|
||||
|
||||
{/* Ornament */}
|
||||
@@ -171,7 +171,7 @@ function Hero({ lang, setLang, restaurant }) {
|
||||
</div>
|
||||
|
||||
<p className="mx-auto max-w-[300px] text-[13px] leading-relaxed text-[#7d7660]">
|
||||
{r.blurb?.[lang] ?? r.blurb ?? ''}
|
||||
{r.blurb?.[lang] || RESTAURANT_FALLBACK.blurb[lang] || ''}
|
||||
</p>
|
||||
|
||||
{r.hours?.[lang] && (
|
||||
|
||||
Reference in New Issue
Block a user