Skip to content

Commit 0f18367

Browse files
committed
fix(password, phoneInput):countryCode issue hasanharman#31 & make PasswordInput typable.
1 parent 046d450 commit 0f18367

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

screens/render-form-field/index.tsx

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useRef, useState } from 'react'
3+
import { ChangeEvent, useRef, useState } from 'react'
44

55
import { FormFieldType } from '@/types'
66
import { cn } from '@/lib/utils'
@@ -122,6 +122,7 @@ export const renderFormField = (field: FormFieldType, form: any) => {
122122
const [smartDatetime, setSmartDatetime] = useState<Date | null>()
123123
const [countryName, setCountryName] = useState<string>('')
124124
const [stateName, setStateName] = useState<string>('')
125+
const [password, setPassword] = useState<string>('')
125126
const canvasRef = useRef<HTMLCanvasElement>(null)
126127

127128
const dropZoneConfig = {
@@ -557,7 +558,17 @@ export const renderFormField = (field: FormFieldType, form: any) => {
557558
<FormItem>
558559
<FormLabel>{field.label}</FormLabel>
559560
<FormControl>
560-
<PasswordInput value="password" />
561+
<PasswordInput
562+
value={password}
563+
placeholder='password'
564+
onChange={(e:ChangeEvent<HTMLInputElement>)=>{
565+
setPassword(e.target.value)
566+
form.setValue(field.name, e.target.value, {
567+
shouldValidate: true,
568+
shouldDirty: true,
569+
})
570+
}}
571+
/>
561572
</FormControl>
562573
<FormDescription>{field.description}</FormDescription>
563574
<FormMessage />
@@ -568,7 +579,15 @@ export const renderFormField = (field: FormFieldType, form: any) => {
568579
<FormItem>
569580
<FormLabel>{field.label}</FormLabel>
570581
<FormControl>
571-
<PhoneInput defaultCountry="TR" />
582+
583+
<PhoneInput
584+
defaultCountry="TR"
585+
onChange={(phoneNumber)=>{
586+
form.setValue(field.name, phoneNumber, {
587+
shouldValidate: true,
588+
shouldDirty: true,
589+
})
590+
}}/>
572591
</FormControl>
573592
<FormDescription>{field.description}</FormDescription>
574593
<FormMessage />

0 commit comments

Comments
 (0)