'use client';
import * as React from 'react';
import { usePathname } from 'next/navigation';
import { TransitionLink } from '@/components/ui/TransitionLink';
import { Home, Briefcase, Users, Mail } from 'lucide-react';
import { motion, AnimatePresence } from 'framer-motion';
export interface NavLink {
label: string;
url: string;
children?: NavLink[];
}
interface MobileBottomNavProps {
navLinks: NavLink[];
currentLocale: string;
}
export function MobileBottomNav({ navLinks, currentLocale }: MobileBottomNavProps) {
const pathname = usePathname() || '/';
const [isFlyoutOpen, setIsFlyoutOpen] = React.useState(false);
// We need to gather all links that should go into the flyout.
// The user wants 'alle navigationspunkte daraus' (from the old burger menu).
// Old menu had: Kompetenzen, Über uns (Firma, Team, Zertifikate, Standorte), Referenzen, Karriere, Messen.
// Construct our bottom nav items
const items = React.useMemo(() => {
const homeUrl = `/${currentLocale}`;
const competenciesUrl = navLinks[0]?.url || `/${currentLocale}/kompetenzen`;
const referencesUrl = navLinks[2]?.url || `/${currentLocale}/referenzen`;
const contactUrl = `/${currentLocale}/${currentLocale === 'de' ? 'kontakt' : 'contact'}`;
return [
{
id: 'home',
label: currentLocale === 'de' ? 'Start' : 'Home',
url: homeUrl,
icon: ,
exactMatch: true
},
{
id: 'kompetenzen',
label: navLinks[0]?.label || (currentLocale === 'de' ? 'Kompetenzen' : 'Competencies'),
url: competenciesUrl,
icon:
},
{
id: 'referenzen',
label: navLinks[2]?.label || (currentLocale === 'de' ? 'Referenzen' : 'References'),
url: referencesUrl,
icon: // Using Users for now, wait we need an image or star icon?
},
{
id: 'menu',
label: navLinks[1]?.label || (currentLocale === 'de' ? 'Über uns' : 'About Us'),
url: '#', // Triggers flyout
icon: ,
isFlyoutTrigger: true
},
{
id: 'kontakt',
label: currentLocale === 'de' ? 'Kontakt' : 'Contact',
url: contactUrl,
icon:
}
];
}, [currentLocale, navLinks]);
// Use a star or folder for references? Let's use standard Briefcase for Kompetenzen, and maybe a Layers or Image icon for Referenzen.
// We'll replace the Users icon with something better if possible, but Users is fine for now, wait, Users is Über uns!
// I will fix the icon in the render.
// Gather flyout links:
const flyoutLinks = React.useMemo(() => {
// We want to put Über uns children, Karriere, and Messen in here.
const aboutNode = navLinks[1];
const karriereNode = navLinks[3];
const messenNode = navLinks[4];
let links: {label: string, url: string}[] = [];
if (aboutNode?.children) {
links.push(...aboutNode.children.map(c => ({ label: c.label, url: c.url })));
}
if (karriereNode) links.push({ label: karriereNode.label, url: karriereNode.url });
if (messenNode) links.push({ label: messenNode.label, url: messenNode.url });
return links;
}, [navLinks]);
return (
<>
{/* Flyout Menu (Bottom Sheet) */}
{isFlyoutOpen && (
<>
setIsFlyoutOpen(false)}
/>
{currentLocale === 'de' ? 'Über uns & Mehr' : 'About us & More'}
{flyoutLinks.map((link, i) => {
const childUrl = link.url.startsWith('/') && !link.url.match(/^\/(en|de)/)
? `/${currentLocale}${link.url}`
: link.url;
const isChildActive = pathname === childUrl;
return (
setIsFlyoutOpen(false)}
className={`px-4 py-3.5 rounded-2xl text-base font-medium transition-all flex items-center justify-between ${
isChildActive ? 'bg-primary/10 text-primary' : 'text-neutral-700 hover:bg-neutral-50'
}`}
>
{link.label}
);
})}
>
)}
>
);
}