"use client";
import React from "react";
import Link from "next/link";
import { Eye, FolderOpen } from "lucide-react";
import { dayPath } from "@/lib/frontend/routes";
import { buildPdfUrl } from "@/lib/frontend/explorer/pdfUrl";
import { formatSearchItemDateDe } from "@/lib/frontend/search/resultsSorting";
import { SEARCH_SCOPE } from "@/lib/frontend/search/urlState";
import { Button } from "@/components/ui/button";
import {
Table,
TableBody,
TableCaption,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
export default function SearchResultsTable({ routeBranch, scope, items }) {
const showBranchColumn =
scope === SEARCH_SCOPE.ALL || scope === SEARCH_SCOPE.MULTI;
const list = Array.isArray(items) ? items : [];
return (
Hinweis: PDFs werden in einem neuen Tab geöffnet.
{showBranchColumn ? Niederlassung : null}
Datum
Datei
Pfad
Aktion
{list.map((it) => {
const itemBranch = String(it?.branch || routeBranch);
const year = String(it?.year || "");
const month = String(it?.month || "");
const day = String(it?.day || "");
const filename = String(it?.filename || "");
const relativePath = String(it?.relativePath || "");
const snippet =
typeof it?.snippet === "string" && it.snippet.trim()
? it.snippet.trim()
: null;
const pdfUrl = buildPdfUrl({
branch: itemBranch,
year,
month,
day,
filename,
});
const dayHref = dayPath(itemBranch, year, month, day);
const key =
relativePath || `${itemBranch}/${year}/${month}/${day}/${filename}`;
return (
{showBranchColumn ? (
{itemBranch}
) : null}
{formatSearchItemDateDe(it)}
{filename}
{snippet ? (
{snippet}
) : null}
{relativePath}
{relativePath}
);
})}
);
}