"use client"; import React from "react"; import { AlertCircleIcon } from "lucide-react"; import { SEARCH_SCOPE } from "@/lib/frontend/search/urlState"; import SearchQueryBox from "@/components/search/form/SearchQueryBox"; import SearchScopeSelect from "@/components/search/form/SearchScopeSelect"; import SearchLimitSelect from "@/components/search/form/SearchLimitSelect"; import SearchSingleBranchCombobox from "@/components/search/form/SearchSingleBranchCombobox"; import SearchMultiBranchPicker from "@/components/search/form/SearchMultiBranchPicker"; import SearchDateRangePicker from "@/components/search/form/SearchDateRangePicker"; import SearchDateFilterChip from "@/components/search/form/SearchDateFilterChip"; import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert"; export default function SearchForm({ branch, qDraft, onQDraftChange, onSubmit, currentQuery, isSubmitting, isAdminDev, scope, onScopeChange, onSingleBranchChange, availableBranches, branchesStatus, selectedBranches, onToggleBranch, onClearAllBranches, limit, onLimitChange, from, to, onDateRangeChange, validationError, }) { const canSearch = typeof qDraft === "string" && qDraft.trim().length > 0; // SINGLE scope (admin/dev only) shows an extra branch combobox. const showSingleBranchCombobox = Boolean( isAdminDev && scope === SEARCH_SCOPE.SINGLE ); const hasDateFilter = Boolean(from || to); return (
{ e.preventDefault(); if (!canSearch) return; onSubmit(); }} className="space-y-4" > {/* Row 1: query full-width */}
{/* Row 2: left controls + spacer + limit on the right */}
{/* Left group: scope (+ optional single branch combobox) + date range */}
{isAdminDev ? (
{/* Animated presence (kept for smoothness when SINGLE shows the extra combobox) */}
) : null}
{/* Active date filter chip (quick clear) */} {hasDateFilter ? (
Aktive Filter: { if (typeof onDateRangeChange !== "function") return; onDateRangeChange({ from: null, to: null }); }} />
) : null}
{/* Right group: limit aligned right */}
{/* Validation feedback belongs near the inputs (not in results). */} {validationError ? ( {validationError.title} {validationError.description} ) : null} {/* Multi scope branch picker remains below */} {isAdminDev && scope === SEARCH_SCOPE.MULTI ? ( ) : null}
); }