melon_frontend/src/components/inputSelect.tsx
Ruidy a9bf6936b5
refactoring (#18)
* chore: update deps to fix CVEs

* cleanup

* use variable for app routes

* refactor

* ⬆️ react router

* ⬆️ react

* delete pem files
2022-09-10 14:33:51 +02:00

34 lines
831 B
TypeScript

import { Form, Select } from 'antd';
import { Controller } from 'react-hook-form';
type InputSelectProps = {
control: any;
name: string;
label: string;
placeholder: string;
options: string[];
};
export const InputSelect = ({ control, name, label, placeholder, options }: InputSelectProps) => (
<Controller
control={control}
name={name}
render={({ field }) => (
<Form.Item label={label}>
<Select
showSearch
placeholder={placeholder}
optionFilterProp="children"
filterOption={(input, option) =>
option?.label!.toLowerCase().indexOf(input.toLowerCase())! >= 0
}
options={options.map((label, value) => ({
value,
label
}))}
{...field}
/>
</Form.Item>
)}
/>
);