forked from adrianhajdin/banking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomInput.tsx
45 lines (40 loc) · 1.19 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
import React from 'react'
import { FormControl, FormField, FormLabel, FormMessage } from './ui/form'
import { Input } from './ui/input'
import { Control, FieldPath } from 'react-hook-form'
import { z } from 'zod'
import { authFormSchema } from '@/lib/utils'
const formSchema = authFormSchema('sign-up')
interface CustomInput {
control: Control<z.infer<typeof formSchema>>,
name: FieldPath<z.infer<typeof formSchema>>,
label: string,
placeholder: string
}
const CustomInput = ({ control, name, label, placeholder }: CustomInput) => {
return (
<FormField
control={control}
name={name}
render={({ field }) => (
<div className="form-item">
<FormLabel className="form-label">
{label}
</FormLabel>
<div className="flex w-full flex-col">
<FormControl>
<Input
placeholder={placeholder}
className="input-class"
type={name === 'password' ? 'password' : 'text'}
{...field}
/>
</FormControl>
<FormMessage className="form-message mt-2" />
</div>
</div>
)}
/>
)
}
export default CustomInput