mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-06-23 21:22:04 -05:00
43 lines
1.1 KiB
TypeScript
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>
|
|
);
|
|
}
|