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"; const MainPageLayout = () => { const location = useLocation(); const currentPath = location.pathname; // Determine which page we're on const isHome = currentPath === "/"; const isAktionen = currentPath === "/aktionen"; const isFiliale = currentPath === "/filiale"; // Get navigation config based on current page const getNavigationConfig = () => { if (isHome) { return { leftNav: { text: "Aktionen", link: "/aktionen" }, rightNav: { text: "Filiale", link: "/filiale" } }; } else if (isAktionen) { return { leftNav: { text: "Filiale", link: "/filiale" }, rightNav: { text: "Home", link: "/" } }; } else if (isFiliale) { return { leftNav: { text: "Home", link: "/" }, rightNav: { text: "Aktionen", link: "/aktionen" } }; } return { leftNav: null, rightNav: null }; }; // Define all titles for layered rendering const allTitles = { home: "ine annabis eeds & uttings", aktionen: "Aktionen", filiale: "Filiale" }; // Define all content boxes for layered rendering const allContentBoxes = { home: [ { title: "Samen", image: "/assets/images/seeds.jpg", bgcolor: "#e1f0d3", link: "/Kategorie/Samen" }, { title: "Stecklinge", image: "/assets/images/cutlings.jpg", bgcolor: "#e8f5d6", link: "/Kategorie/Stecklinge" } ], aktionen: [ { title: "Ölpresse ausleihen", image: "/assets/images/presse.jpg", bgcolor: "#e1f0d3", link: "/presseverleih" }, { title: "THC Test", image: "/assets/images/purpl.jpg", bgcolor: "#e8f5d6", link: "/thc-test" } ], filiale: [ { title: "Trachenberger Straße 14", image: "/assets/images/filiale1.jpg", bgcolor: "#e1f0d3", link: "/filiale" }, { title: "01129 Dresden", image: "/assets/images/filiale2.jpg", bgcolor: "#e8f5d6", link: "/filiale" } ] }; // Get opacity for each page layer 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(); return ( {/* Main Navigation Header */} {/* Left Navigation - Layered rendering */} {["Aktionen", "Filiale", "Home"].map((text, index) => { const isActive = navConfig.leftNav && navConfig.leftNav.text === text; const link = text === "Aktionen" ? "/aktionen" : text === "Filiale" ? "/filiale" : "/"; return ( {text} ); })} {/* Center Title - Layered rendering - This defines the height for centering */} {Object.entries(allTitles).map(([pageType, title]) => ( {title} ))} {/* Right Navigation - Layered rendering */} {["Aktionen", "Filiale", "Home"].map((text, index) => { const isActive = navConfig.rightNav && navConfig.rightNav.text === text; const link = text === "Aktionen" ? "/aktionen" : text === "Filiale" ? "/filiale" : "/"; return ( {text} ); })} {/* Content Boxes - Layered rendering */} {Object.entries(allContentBoxes).map(([pageType, contentBoxes]) => ( {contentBoxes.map((box, index) => (
{box.title}
))}
))}
{/* Shared Carousel */}
); }; export default MainPageLayout;