HifiPlanet-Website/hifi-src/src/components/Footer.jsx
Maaxxs 54928d1411 Add package badges/visibility and a download area, speed up the site
Customer feedback round (4 items):

- Packages: one-click "Sichtbar/Ausgeblendet" toggle per package (saved
  immediately). Hidden packages disappear from the model page; the tier
  look of the remaining cards is ranked across all packages so it stays
  stable.
- Packages: badge per card (Empfohlen, Am beliebtesten, Tipp, Coming soon
  or custom text) plus an optional video link shown as "Zum Video". Legacy
  is_featured maps to "Empfohlen".
- New download area (/downloads + Admin -> Downloads): upload with
  progress, inline audio player, allow-listed file types, optional access
  password, new permission downloads.manage. Files live in
  api/uploads/downloads/ (gitignored, created at runtime).
- Performance:
  - SetupGate no longer refetches and remounts the whole app on every
    navigation.
  - Page loader waits only for pending API calls and above-the-fold images
    (fixes an 8 s hang on /leistungen caused by lazy images inside the
    hidden container).
  - Admin pages lazy-loaded; icon library moved out of the main bundle
    (initial JS 2.2 MB -> 0.48 MB).
  - Background video loads only near the viewport and was re-encoded to
    720p (32 MB -> 8.5 MB).
  - Visitors without a session cookie get no PHP session, so their parallel
    API requests no longer queue on the session lock.
  - index.html is served with Cache-Control: no-cache so browsers don't
    keep a stale build after deploys.
- Fonts (Barlow, Barlow Condensed, Michroma) are self-hosted instead of
  loaded from Google Fonts; the default privacy policy mentions this, lists
  all local storage uses and uses the new TDDDG name.
- A code update that adds a table no longer sends the site into the setup
  wizard while an admin exists.

Run "Datenbankstruktur aktualisieren" after deploying (new package
columns, downloads table, app_settings.downloads_password).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 23:15:48 +02:00

129 lines
6.1 KiB
JavaScript

import { Link, useLocation } from 'react-router-dom';
import { Clock, MapPin, Navigation, Phone } from 'lucide-react';
import { useCookieConsent } from '../context/CookieConsentContext.jsx';
import { useSiteSettings } from '../context/SiteSettingsContext.jsx';
import { useLanguage } from '../context/LanguageContext.jsx';
import { isOpenNow, formatBusinessHours } from '../utils/businessHours.js';
const digitsOnly = (value) => (value || '').replace(/[^\d+]/g, '');
export default function Footer() {
const {
phone,
contact_email: contactEmail,
address_street: addressStreet,
address_zip: addressZip,
address_city: addressCity,
business_hours: businessHours,
has_downloads: hasDownloads,
} = useSiteSettings();
const open = isOpenNow(businessHours);
const { openSettings } = useCookieConsent();
// Auf der Startseite blendet sich unten eine fixierte CTA-Leiste ein, die
// sonst die letzte Footer-Zeile (Impressum-Links) verdeckt - deshalb dort
// zusätzlichen Platz für sie freihalten.
const { pathname } = useLocation();
const isHome = pathname === '/';
const { t } = useLanguage();
const shopAddress = [addressStreet, [addressZip, addressCity].filter(Boolean).join(' ')]
.filter(Boolean)
.join(', ');
const directionsUrl = `https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(shopAddress)}`;
const HOURS = formatBusinessHours(businessHours, t('footer.closed'));
return (
<footer
className={`border-t border-neutral-200 bg-neutral-50 py-10 text-sm text-neutral-600 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-300 ${
isHome ? 'pb-24' : ''
}`}
>
<div className="mx-auto grid max-w-6xl gap-4 px-4 sm:grid-cols-3 sm:px-6">
<div className="rounded-xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900">
<div className="mb-3 flex items-center gap-2">
<MapPin className="h-4 w-4 text-brand-500" />
<p className="font-semibold text-neutral-900 dark:text-white">HifiPlanet</p>
</div>
{addressStreet && <p>{addressStreet}</p>}
{(addressZip || addressCity) && <p>{[addressZip, addressCity].filter(Boolean).join(' ')}</p>}
<a
href={directionsUrl}
target="_blank"
rel="noopener noreferrer"
className="mt-4 flex items-center justify-center gap-1.5 rounded-md bg-brand-500 px-3 py-2 text-xs font-semibold text-white hover:bg-brand-600"
>
<Navigation className="h-3.5 w-3.5" />
{t('footer.routePlan')}
</a>
</div>
<div className="rounded-xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900">
<div className="mb-3 flex items-center gap-2">
<Phone className="h-4 w-4 text-brand-500" />
<p className="font-semibold text-neutral-900 dark:text-white">{t('footer.contactHeading')}</p>
</div>
<p>
<a href={`tel:${digitsOnly(phone)}`} className="inline-block py-1 hover:text-brand-500">{phone}</a>
</p>
<p>
<a href={`mailto:${contactEmail}`} className="inline-block py-1 hover:text-brand-500">{contactEmail}</a>
</p>
<Link
to="/kontakt"
className="mt-4 flex items-center justify-center gap-1.5 rounded-md border border-neutral-300 px-3 py-2 text-xs font-semibold text-neutral-700 hover:border-brand-500 hover:text-brand-600 dark:border-neutral-700 dark:text-neutral-200"
>
{t('footer.contactForm')}
</Link>
</div>
<div className="rounded-xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900">
<div className="mb-3 flex items-center justify-between gap-2">
<div className="flex items-center gap-2">
<Clock className="h-4 w-4 text-brand-500" />
<p className="font-semibold text-neutral-900 dark:text-white">{t('footer.hoursHeading')}</p>
</div>
<span
className={`flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11px] font-semibold ${
open
? 'bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300'
: 'bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400'
}`}
>
<span className={`h-1.5 w-1.5 rounded-full ${open ? 'bg-green-500' : 'bg-neutral-400'}`} />
{open ? t('footer.open') : t('footer.closed')}
</span>
</div>
<dl className="space-y-1.5">
{HOURS.map((row) => (
<div key={row.key} className="flex items-center justify-between gap-3">
<dt className="text-neutral-500 dark:text-neutral-400">{row.days}</dt>
<dd className="font-medium text-neutral-700 dark:text-neutral-200">{row.label}</dd>
</div>
))}
</dl>
</div>
</div>
<div className="mx-auto mt-8 max-w-6xl border-t border-neutral-200 px-4 pt-6 text-center text-xs text-neutral-500 dark:border-neutral-800 dark:text-neutral-400 sm:px-6">
<p className="flex flex-wrap items-center justify-center gap-x-2 gap-y-1">
<span>{t('footer.copyright')(new Date().getFullYear())}</span>
<span>·</span>
<Link to="/impressum" className="hover:text-brand-500">{t('footer.imprint')}</Link>
<span>·</span>
<Link to="/datenschutz" className="hover:text-brand-500">{t('footer.privacy')}</Link>
<span>·</span>
<Link to="/agb" className="hover:text-brand-500">{t('footer.terms')}</Link>
<span>·</span>
{hasDownloads && (
<>
<Link to="/downloads" className="hover:text-brand-500">{t('footer.downloads')}</Link>
<span>·</span>
</>
)}
<button type="button" onClick={openSettings} className="hover:text-brand-500">
{t('footer.cookieSettings')}
</button>
</p>
</div>
</footer>
);
}