"use client"; import React from "react"; import { X } from "lucide-react"; import { isValidBranchParam } from "@/lib/frontend/params"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { DebouncedSkeleton } from "@/components/ui/debounced-skeleton"; function normalizeTypedBranch(value) { if (typeof value !== "string") return null; const s = value.trim().toUpperCase(); return s ? s : null; } export default function SearchMultiBranchPicker({ branchesStatus, availableBranches, selectedBranches, onToggleBranch, onClearAllBranches, isSubmitting, }) { const listReady = branchesStatus === "ready"; const listLoading = branchesStatus === "loading"; const listError = branchesStatus === "error"; const branchOptions = Array.isArray(availableBranches) ? availableBranches : []; const selected = Array.isArray(selectedBranches) ? selectedBranches : []; const selectedSet = React.useMemo( () => new Set(selected.map(String)), [selected], ); const canClearAll = typeof onClearAllBranches === "function" && selected.length > 0 && !isSubmitting; // Fail-open manual add (only relevant if branch list failed) const [manual, setManual] = React.useState(""); const typed = normalizeTypedBranch(manual); const canAddTyped = Boolean(typed && isValidBranchParam(typed)) && !selectedSet.has(typed); return (
Niederlassungen auswählen
Wählen Sie eine oder mehrere Niederlassungen. Die Suche wird nach jeder Änderung aktualisiert.
Niederlassungen konnten nicht geladen werden. Sie können NLxx manuell hinzufügen.
Keine Niederlassungen ausgewählt.
) : (