mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-19 13:40:41 -05:00
44 lines
872 B
TypeScript
44 lines
872 B
TypeScript
import * as React from "react";
|
|
import { BadgesSelector } from "~/features/badges/components/BadgesSelector";
|
|
import type { BadgeOption, FormFieldProps } from "../types";
|
|
import { FormFieldWrapper } from "./FormFieldWrapper";
|
|
|
|
type BadgesFormFieldProps = Omit<FormFieldProps<"badges">, "onBlur"> & {
|
|
value: number[];
|
|
onChange: (value: number[]) => void;
|
|
onBlur?: () => void;
|
|
options: BadgeOption[];
|
|
};
|
|
|
|
export function BadgesFormField({
|
|
name,
|
|
label,
|
|
bottomText,
|
|
error,
|
|
maxCount,
|
|
value,
|
|
onChange,
|
|
onBlur,
|
|
options,
|
|
}: BadgesFormFieldProps) {
|
|
const id = React.useId();
|
|
|
|
return (
|
|
<FormFieldWrapper
|
|
id={id}
|
|
name={name}
|
|
label={label}
|
|
error={error}
|
|
bottomText={bottomText}
|
|
>
|
|
<BadgesSelector
|
|
options={options}
|
|
selectedBadges={value}
|
|
onChange={onChange}
|
|
onBlur={onBlur}
|
|
maxCount={maxCount}
|
|
/>
|
|
</FormFieldWrapper>
|
|
);
|
|
}
|