|
|
@@ -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})`
|