-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCustomInput.tsx
59 lines (55 loc) · 1.33 KB
/
CustomInput.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
55
56
57
58
59
import React from 'react'
import { DatePicker, Input, Select } from 'antd'
import styles from '../styles/Components/CustomInput.module.css'
const { Option } = Select
const { TextArea } = Input
interface IProps {
placeholder: string | undefined
type: string
data: any
label: string
onChange: any
}
const CustomInput = ({ placeholder, type, data, label, onChange }: IProps) => {
return (
<div className={styles.input__wrapper}>
<label className={styles.input__label}>{label}</label>
<div className={styles.input__element}>
{type === 'text' ? (
<Input
placeholder={placeholder}
className={styles.input__element__comp}
onChange={onChange}
/>
) : null}
{type === 'date' ? (
<DatePicker
className={styles.input__element__comp}
onChange={onChange}
/>
) : null}
{type === 'drop-down' ? (
<Select
defaultValue="Select"
className={styles.input__element__dropdown}
onChange={onChange}
>
{data.map((item: any) => (
<Option key={item.value} value={item.value}>
{item.name}
</Option>
))}
</Select>
) : null}
{type === 'textarea' ? (
<TextArea
rows={4}
className={styles.input__element__comp}
onChange={onChange}
/>
) : null}
</div>
</div>
)
}
export default CustomInput