import Link from 'next/link'
import { useState } from 'react'
import { Button, Input } from 'ui'
import { Eye, EyeOff, HelpCircle, Loader } from 'lucide-react'
import type { ServerOption } from './Wrappers.types'
interface InputFieldProps {
option: ServerOption
loading: boolean
error: any
}
const InputField = ({ option, loading, error }: InputFieldProps) => {
const [showHidden, setShowHidden] = useState(!option.secureEntry)
if (option.isTextArea) {
return (
{option.label}
{option.urlHelper !== undefined && (
)}
}
value={loading ? 'Fetching value from Vault...' : undefined}
defaultValue={option.defaultValue ?? ''}
required={option.required ?? false}
/>
)
} else {
return (
{option.label}
{option.urlHelper !== undefined && (
)}
}
labelOptional={option.required ? undefined : 'Optional'}
defaultValue={option.defaultValue ?? ''}
error={error}
value={loading ? 'Fetching value from Vault...' : undefined}
type={!option.secureEntry || loading ? 'text' : showHidden ? 'text' : 'password'}
disabled={loading || option.readOnly}
actions={
loading ? (
} />
) : option.secureEntry ? (
: }
onClick={() => setShowHidden(!showHidden)}
/>
) : null
}
/>
)
}
}
export default InputField