sendou.ink/app/form/fields/TournamentSearchFormField.tsx
Kalle 6e987d506f
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run
Tournament layout refresh, improve admin experience (#3152)
2026-06-11 18:31:10 +03:00

43 lines
1.1 KiB
TypeScript

import { TournamentSearch } from "~/components/elements/TournamentSearch";
import type { FormFieldProps } from "../types";
import { FormFieldMessages, useTranslatedTexts } from "./FormFieldWrapper";
import styles from "./UserSearchFormField.module.css";
type TournamentSearchFormFieldProps = FormFieldProps<"tournament-search"> & {
value: number | null;
onChange: (value: number | null) => void;
pastOnly?: boolean;
};
export function TournamentSearchFormField({
name,
label,
bottomText,
error,
required,
value,
onChange,
onBlur,
pastOnly,
}: TournamentSearchFormFieldProps) {
const { translatedLabel } = useTranslatedTexts({
label,
});
return (
<div className={styles.root}>
<div className="stack xs">
<TournamentSearch
initialTournamentId={value ?? undefined}
pastOnly={pastOnly}
onChange={(tournament) => onChange(tournament?.id ?? null)}
onBlur={() => onBlur?.()}
label={translatedLabel}
isRequired={required}
/>
<FormFieldMessages name={name} error={error} bottomText={bottomText} />
</div>
</div>
);
}