Просмотр исходного кода

RHL-043 fix(search): show concrete branch IDs in recent multi entries

Code_Uwe 1 месяц назад
Родитель
Сommit
2233381041
1 измененных файлов с 21 добавлено и 0 удалено
  1. 21 0
      components/search/form/SearchQueryBox.jsx

+ 21 - 0
components/search/form/SearchQueryBox.jsx

@@ -18,10 +18,31 @@ import {
 	CommandList,
 } from "@/components/ui/command";
 
+function toBranchShort(value) {
+	const normalized = String(value || "").trim().toUpperCase();
+	const match = /^NL(\d+)$/i.exec(normalized);
+	if (!match) return null;
+
+	const digits = match[1];
+	return digits.length === 1 ? `0${digits}` : digits;
+}
+
+function getMultiBranchSummary(branches) {
+	const compact = (Array.isArray(branches) ? branches : [])
+		.map((branch) => toBranchShort(branch))
+		.filter(Boolean);
+
+	if (compact.length === 0) return null;
+	return `NL: ${compact.join(",")}`;
+}
+
 function getScopeSummary(entry) {
 	if (entry?.scope === "all") return "Alle Niederlassungen";
 
 	if (entry?.scope === "multi") {
+		const compactBranches = getMultiBranchSummary(entry?.branches);
+		if (compactBranches) return compactBranches;
+
 		const count = Array.isArray(entry?.branches) ? entry.branches.length : 0;
 		return count > 0
 			? `Mehrere Niederlassungen (${count})`