"use client"; import React from "react"; import Link from "next/link"; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/components/ui/breadcrumb"; import { yearPath, monthPath } from "@/lib/frontend/routes"; import { formatMonthLabel } from "@/lib/frontend/explorer/formatters"; import { buildExplorerDropdownItems, buildBranchCrumbHref, } from "@/lib/frontend/explorer/breadcrumbDropdowns"; import SegmentDropdown from "@/components/explorer/breadcrumbs/SegmentDropdown"; /** * ExplorerBreadcrumbs * * Breadcrumb navigation for the Explorer drill-down using shadcn/ui Breadcrumb. * Optional dropdowns allow switching between existing years/months/days. * * UX rules: * - All user-facing strings must be German. * - Dropdowns are only rendered when options are available (non-empty lists). * * @param {{ * branch: string, * year?: string|null, * month?: string|null, * day?: string|null, * yearOptions?: string[]|null, * monthOptions?: string[]|null, * dayOptions?: string[]|null * }} props */ export default function ExplorerBreadcrumbs({ branch, year = null, month = null, day = null, yearOptions = null, monthOptions = null, dayOptions = null, }) { const { yearItems, monthItems, dayItems } = buildExplorerDropdownItems({ branch, year, month, day, yearOptions, monthOptions, dayOptions, }); const showYear = Boolean(year); const showMonth = Boolean(year && month); const showDay = Boolean(year && month && day); const isBranchCurrent = !year; const isYearCurrent = Boolean(year && !month); const isMonthCurrent = Boolean(year && month && !day); return ( {/* Branch */} {isBranchCurrent ? ( {branch} ) : ( {branch} )} {/* Year */} {showYear ? ( <>
{isYearCurrent ? ( {year} ) : ( {year} )} {yearItems ? ( ) : null}
) : null} {/* Month */} {showMonth ? ( <>
{isMonthCurrent ? ( {formatMonthLabel(month)} ) : ( {formatMonthLabel(month)} )} {monthItems ? ( ) : null}
) : null} {/* Day */} {showDay ? ( <>
{/* Day is always current on the leaf route */} {day} {dayItems ? ( ) : null}
) : null}
); }