-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDropdownField.tsx
54 lines (50 loc) · 1.2 KB
/
DropdownField.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
52
53
54
import React from 'react'
import { type Control, Controller } from 'react-hook-form'
import Select from 'react-select'
interface Option {
value: string
label: string
}
interface DropdownFieldProps {
label: string
name: string
control: Control<any>
options: Option[]
}
const DropdownField: React.FC<DropdownFieldProps> = ({
label,
name,
control,
options,
}) => {
return (
<div>
<label>{label}</label>
{/* figma 내에서는 존재하지 않는 요소, 확인용으로 첨부 */}
<Controller
name={name}
control={control}
render={({ field: { onChange, value, ref } }) => (
<Select
options={options}
ref={ref}
onChange={onChange}
value={options.find((option) => option.value === value)}
placeholder=""
theme={(theme) => ({
...theme,
borderRadius: 0,
colors: {
...theme.colors,
primary25: '#ebe4d9',
primary: '#665a48',
},
})}
className="border border-beige text-dark-brown "
/>
)}
/>
</div>
)
}
export default DropdownField