-
Notifications
You must be signed in to change notification settings - Fork 0
/
select.tsx
51 lines (46 loc) · 1.14 KB
/
select.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Option, Select as MTSelect } from '@material-tailwind/react';
import styles from './select.module.css';
export interface OptionType {
label: string;
value: string;
}
interface SelectProps {
options: OptionType[];
id: string;
value: string;
onChange: React.Dispatch<React.SetStateAction<string>>;
}
export const Select = ({ options, id, value, onChange }: SelectProps) => {
const handleChange = (val: string | undefined) => {
if (val) {
onChange(val);
}
};
return (
<MTSelect
id={id}
data-testid={`select-dropdown-${id}`}
value={value}
onChange={handleChange}
className={`${styles['selectContainer']} text-gray-900 font-normal `}
labelProps={{
className: 'before:mr-0 after:ml-0',
}}
menuProps={{
className: 'font-medium text-gray-900 border-none shadow-md',
}}
>
{options.map((option, index) => {
return (
<Option
key={`${id}-dropdown-${index}`}
value={option.value}
>
{option.label}
</Option>
);
})}
</MTSelect>
);
};
export default Select;