From 5f1d4e1092bc43a7d0a2c420d90533aabc564f6b Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Wed, 9 Sep 2026 02:03:59 +0200 Subject: [PATCH] Add CMS v1: editable business identity and legal pages Phase 5 of the dashboard roadmap. Business-facing data that was previously hard-coded (and, for address/hours, duplicated three independent ways across Footer.jsx, ContactPage.jsx, and the i18n strings) is now stored in app_settings and editable under Website settings: logo (light/dark variants, falling back to the bundled defaults until set), street/zip/city, and a day-by-day business_hours editor. Footer.jsx and ContactPage.jsx now share one open/closed and hours-formatting implementation (new utils/businessHours.js) instead of three separate hard-coded representations of the same thing. New legal_pages table (impressum/datenschutz/agb) + PageContentController replaces the three fully hard-coded React pages with fetched, admin- editable HTML - built-in defaults matching the original page content kick in until an admin saves anything, so a fresh install isn't blank. Reuses the Phase 4 RichTextEditor (extended with a heading toggle and inline-code toggle, since the legal text needs both) via a new "Rechtstexte" tab in Settings. Legal content lives only in DB and is authored exclusively by logged-in admins, so dangerouslySetInnerHTML here doesn't take untrusted input. IMAGE_COLUMNS in SettingsController (export/import) is now table => array of columns instead of table => one column, since app_settings has three image columns (hero/logo/logo_dark) - this also retroactively fixes hero_image_path never having been wired into export/import at all. app_settings and legal_pages both got TABLE_COLUMNS/IMPORT_SECTIONS entries so they round-trip through a hoster-migration export like everything else. Co-Authored-By: Claude Sonnet 5 --- hifi-src/src/App.jsx | 2 + hifi-src/src/components/Footer.jsx | 40 ++- hifi-src/src/components/Navbar.jsx | 6 +- hifi-src/src/components/PublicLayout.jsx | 16 ++ hifi-src/src/components/RichTextEditor.jsx | 15 ++ hifi-src/src/context/SiteSettingsContext.jsx | 6 + hifi-src/src/index.css | 49 ++++ .../admin/settings/ExportImportSettings.jsx | 9 +- .../pages/admin/settings/LegalSettings.jsx | 114 +++++++++ .../pages/admin/settings/SettingsLayout.jsx | 1 + .../pages/admin/settings/WebsiteSettings.jsx | 127 ++++++++++ hifi-src/src/pages/public/AGB.jsx | 127 ++-------- hifi-src/src/pages/public/ContactPage.jsx | 40 ++- hifi-src/src/pages/public/Datenschutz.jsx | 220 ++--------------- hifi-src/src/pages/public/Impressum.jsx | 111 ++------- hifi-src/src/utils/businessHours.js | 42 ++++ .../migration_business_stammdaten.sql | 27 ++ hifi/api/database/schema.sql | 14 ++ hifi/api/public/index.php | 5 + .../src/Controllers/PageContentController.php | 176 +++++++++++++ .../src/Controllers/SettingsController.php | 40 +-- .../Controllers/SiteSettingsController.php | 66 ++++- hifi/api/src/Support/Schema.php | 31 +++ hifi/assets/index-1SLMfitC.js | 231 ------------------ hifi/assets/index-C8YANYNU.js | 231 ++++++++++++++++++ hifi/assets/index-CKCuneM9.css | 1 - hifi/assets/index-DHi-eHhm.css | 1 + hifi/index.html | 4 +- 28 files changed, 1050 insertions(+), 702 deletions(-) create mode 100644 hifi-src/src/pages/admin/settings/LegalSettings.jsx create mode 100644 hifi-src/src/utils/businessHours.js create mode 100644 hifi/api/database/migration_business_stammdaten.sql create mode 100644 hifi/api/src/Controllers/PageContentController.php delete mode 100644 hifi/assets/index-1SLMfitC.js create mode 100644 hifi/assets/index-C8YANYNU.js delete mode 100644 hifi/assets/index-CKCuneM9.css create mode 100644 hifi/assets/index-DHi-eHhm.css diff --git a/hifi-src/src/App.jsx b/hifi-src/src/App.jsx index df81db0..f580a70 100644 --- a/hifi-src/src/App.jsx +++ b/hifi-src/src/App.jsx @@ -39,6 +39,7 @@ import AdminUsers from './pages/admin/AdminUsers.jsx'; import PermissionGroups from './pages/admin/PermissionGroups.jsx'; import SettingsLayout from './pages/admin/settings/SettingsLayout.jsx'; import WebsiteSettings from './pages/admin/settings/WebsiteSettings.jsx'; +import LegalSettings from './pages/admin/settings/LegalSettings.jsx'; import EmailSettings from './pages/admin/settings/EmailSettings.jsx'; import DatabaseSettings from './pages/admin/settings/DatabaseSettings.jsx'; import ExportImportSettings from './pages/admin/settings/ExportImportSettings.jsx'; @@ -94,6 +95,7 @@ export default function App() { > } /> } /> + } /> } /> } /> } /> diff --git a/hifi-src/src/components/Footer.jsx b/hifi-src/src/components/Footer.jsx index 88f6eca..d9abe74 100644 --- a/hifi-src/src/components/Footer.jsx +++ b/hifi-src/src/components/Footer.jsx @@ -3,37 +3,33 @@ import DynamicIcon from './DynamicIcon.jsx'; 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, ''); -const SHOP_ADDRESS_ENCODED = encodeURIComponent('Boxbrunner Str. 20a, 63916 Amorbach'); -const DIRECTIONS_URL = `https://www.google.com/maps/dir/?api=1&destination=${SHOP_ADDRESS_ENCODED}`; - -function isOpenNow() { - const now = new Date(); - const minutes = now.getHours() * 60 + now.getMinutes(); - const day = now.getDay(); // 0 = Sonntag, 1-5 = Mo-Fr, 6 = Sa - if (day === 0) return false; - if (day === 6) return minutes >= 10 * 60 && minutes < 13 * 60; - return minutes >= 9 * 60 && minutes < 18 * 60; -} - export default function Footer() { - const open = isOpenNow(); + const { + phone, + contact_email: contactEmail, + address_street: addressStreet, + address_zip: addressZip, + address_city: addressCity, + business_hours: businessHours, + } = 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 { phone, contact_email: contactEmail } = useSiteSettings(); const { t } = useLanguage(); - const HOURS = [ - { key: 'monFri', days: t('footer.days.monFri'), label: t('contactPage.hoursWeek') }, - { key: 'sat', days: t('footer.days.sat'), label: t('contactPage.hoursSat') }, - { key: 'sun', days: t('footer.days.sun'), label: t('footer.closed') }, - ]; + 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 (