import React from "react"; import { useLocation } from "react-router-dom"; import Container from "@mui/material/Container"; import Box from "@mui/material/Box"; import Typography from "@mui/material/Typography"; import Paper from "@mui/material/Paper"; import Grid from "@mui/material/Grid"; import ChevronLeft from "@mui/icons-material/ChevronLeft"; import ChevronRight from "@mui/icons-material/ChevronRight"; import { Link } from "react-router-dom"; import SharedCarousel from "./SharedCarousel.js"; import { getCombinedAnimatedBorderStyles } from "../utils/animatedBorderStyles.js"; import { useTranslation } from 'react-i18next'; const ContentBox = ({ box, index, pageType, starHovered, setStarHovered, opacity, translatedContent }) => ( {index === 0 && pageType === "filiale" && (
{translatedContent.showUsPhoto}
{translatedContent.selectSeedRate}
)} {index === 1 && pageType === "filiale" && (
{translatedContent.indoorSeason}
)}
setStarHovered(true) : undefined} onMouseLeave={index === 0 && pageType === "filiale" ? () => setStarHovered(false) : undefined} > {opacity === 1 && ( {box.title} )} {box.title}
); const MainPageLayout = () => { const location = useLocation(); const currentPath = location.pathname; const { t } = useTranslation(); const [starHovered, setStarHovered] = React.useState(false); const translatedContent = { showUsPhoto: t('sections.showUsPhoto'), selectSeedRate: t('sections.selectSeedRate'), indoorSeason: t('sections.indoorSeason') }; const isHome = currentPath === "/"; const isAktionen = currentPath === "/aktionen"; const isFiliale = currentPath === "/filiale"; React.useEffect(() => { const style = document.createElement('style'); style.textContent = ` @keyframes rotateClockwise { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes rotateCounterClockwise { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } } .star-rotate-slow-cw { animation: rotateClockwise 60s linear infinite; } .star-rotate-slow-ccw { animation: rotateCounterClockwise 45s linear infinite; } .star-rotate-medium-cw { animation: rotateClockwise 30s linear infinite; } `; document.head.appendChild(style); return () => document.head.removeChild(style); }, []); const getNavigationConfig = () => { if (isHome) return { leftNav: { text: t('navigation.aktionen'), link: "/aktionen" }, rightNav: { text: t('navigation.filiale'), link: "/filiale" } }; if (isAktionen) return { leftNav: { text: t('navigation.filiale'), link: "/filiale" }, rightNav: { text: t('navigation.home'), link: "/" } }; if (isFiliale) return { leftNav: { text: t('navigation.home'), link: "/" }, rightNav: { text: t('navigation.aktionen'), link: "/aktionen" } }; return { leftNav: null, rightNav: null }; }; const allTitles = { home: t('titles.home') , aktionen: t('titles.aktionen'), filiale: t('titles.filiale') }; const allContentBoxes = { home: [ { title: t('sections.seeds'), image: "/assets/images/seeds.jpg", bgcolor: "#e1f0d3", link: "/Kategorie/Seeds" }, { title: t('sections.stecklinge'), image: "/assets/images/cutlings.jpg", bgcolor: "#e8f5d6", link: "/Kategorie/Stecklinge" } ], aktionen: [ { title: t('sections.oilPress'), image: "/assets/images/presse.jpg", bgcolor: "#e1f0d3", link: "/presseverleih" }, { title: t('sections.thcTest'), image: "/assets/images/purpl.jpg", bgcolor: "#e8f5d6", link: "/thc-test" } ], filiale: [ { title: t('sections.address1'), image: "/assets/images/filiale1.jpg", bgcolor: "#e1f0d3", link: "/filiale" }, { title: t('sections.address2'), image: "/assets/images/filiale2.jpg", bgcolor: "#e8f5d6", link: "/filiale" } ] }; const getOpacity = (pageType) => { if (pageType === "home" && isHome) return 1; if (pageType === "aktionen" && isAktionen) return 1; if (pageType === "filiale" && isFiliale) return 1; return 0; }; const navConfig = getNavigationConfig(); const navTexts = [ { key: 'aktionen', text: t('navigation.aktionen'), link: '/aktionen' }, { key: 'filiale', text: t('navigation.filiale'), link: '/filiale' }, { key: 'home', text: t('navigation.home'), link: '/' } ]; return ( {Object.entries(allTitles).map(([pageType, title]) => ( {title} ))} {navTexts.map((navItem, index) => { const isActive = navConfig.leftNav && navConfig.leftNav.text === navItem.text; return ( {navItem.text} ); })} {Object.entries(allTitles).map(([pageType, title]) => ( {title} ))} {navTexts.map((navItem, index) => { const isActive = navConfig.rightNav && navConfig.rightNav.text === navItem.text; return ( {navItem.text} ); })} {Object.entries(allContentBoxes).map(([pageType, contentBoxes]) => ( {contentBoxes.map((box, index) => ( ))} ))} ); }; export default MainPageLayout;