import type { FormEvent } from "react"; import { AlertCircle, Search } from "lucide-react"; import { getFieldError, getFormError } from "@/client/lib/forms"; import type { DomainOverviewControlsForm } from "@/client/features/domain/DomainOverviewPage"; import { toSortMode } from "@/client/features/domain/utils"; import type { DomainSortMode } from "@/client/features/domain/types"; import { LABS_LOCATION_OPTIONS } from "@/client/features/keywords/locations"; import { LocationSelect } from "@/client/components/LocationSelect"; import { ResearchScopeSelect } from "@/client/components/ResearchScopeSelect"; import type { ResearchScope } from "@/shared/researchScope"; type Props = { controlsForm: DomainOverviewControlsForm; isLoading: boolean; onSubmit: (event: FormEvent) => void; onDomainChange: (domain: string) => void; onScopeChange: (scope: ResearchScope) => void; onSortChange: (sort: DomainSortMode) => void; onLocationChange: (locationCode: number) => void; }; export function DomainSearchCard({ controlsForm, isLoading, onSubmit, onDomainChange, onScopeChange, onSortChange, onLocationChange, }: Props) { return (
{(field) => { const domainError = getFieldError(field.state.meta.errors); return ( ); }} {(field) => ( { field.handleChange(scope); onScopeChange(scope); }} /> )} {(field) => ( { field.handleChange(code); onLocationChange(code); }} /> )} {(field) => ( )} state.isSubmitting}> {(isSubmitting) => ( )}
{(field) => { const domainError = getFieldError(field.state.meta.errors); return domainError ? (

{domainError}

) : null; }}
state.errorMap.onSubmit}> {(submitError) => { const errorMessage = getFormError(submitError); return errorMessage ? (
{errorMessage}
) : null; }}
); }