mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-12 05:35:16 -05:00
37 lines
697 B
TypeScript
37 lines
697 B
TypeScript
import { Select } from "@chakra-ui/react";
|
|
|
|
interface Props {
|
|
value: string;
|
|
setValue: (value?: string) => void;
|
|
options: {
|
|
label: string;
|
|
value: string;
|
|
}[];
|
|
placeholder?: string;
|
|
}
|
|
|
|
const MySelect: React.FC<Props> = ({
|
|
value,
|
|
setValue,
|
|
options,
|
|
placeholder,
|
|
}) => {
|
|
return (
|
|
<Select
|
|
value={value}
|
|
onChange={(e) =>
|
|
setValue(e.target.value !== "" ? undefined : e.target.value)
|
|
}
|
|
>
|
|
{placeholder && <option value="">{placeholder}</option>}
|
|
{options.map((option) => (
|
|
<option key={option.value} value={option.value}>
|
|
{option.label}
|
|
</option>
|
|
))}
|
|
</Select>
|
|
);
|
|
};
|
|
|
|
export default MySelect;
|