Skip to content

Commit

Permalink
fix(password, phoneInput):countryCode issue hasanharman#31 & make Pas…
Browse files Browse the repository at this point in the history
…swordInput typable.
  • Loading branch information
hcw0915 committed Nov 17, 2024
1 parent 046d450 commit 0f18367
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions screens/render-form-field/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useRef, useState } from 'react'
import { ChangeEvent, useRef, useState } from 'react'

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

const dropZoneConfig = {
Expand Down Expand Up @@ -557,7 +558,17 @@ export const renderFormField = (field: FormFieldType, form: any) => {
<FormItem>
<FormLabel>{field.label}</FormLabel>
<FormControl>
<PasswordInput value="password" />
<PasswordInput
value={password}
placeholder='password'
onChange={(e:ChangeEvent<HTMLInputElement>)=>{
setPassword(e.target.value)
form.setValue(field.name, e.target.value, {
shouldValidate: true,
shouldDirty: true,
})
}}
/>
</FormControl>
<FormDescription>{field.description}</FormDescription>
<FormMessage />
Expand All @@ -568,7 +579,15 @@ export const renderFormField = (field: FormFieldType, form: any) => {
<FormItem>
<FormLabel>{field.label}</FormLabel>
<FormControl>
<PhoneInput defaultCountry="TR" />

<PhoneInput
defaultCountry="TR"
onChange={(phoneNumber)=>{
form.setValue(field.name, phoneNumber, {
shouldValidate: true,
shouldDirty: true,
})
}}/>
</FormControl>
<FormDescription>{field.description}</FormDescription>
<FormMessage />
Expand Down

0 comments on commit 0f18367

Please sign in to comment.