diff --git a/frontend/src/components/scripts/ScriptParameterField.tsx b/frontend/src/components/scripts/ScriptParameterField.tsx new file mode 100644 index 00000000..5e2bf98a --- /dev/null +++ b/frontend/src/components/scripts/ScriptParameterField.tsx @@ -0,0 +1,151 @@ +import { useState } from 'react' +import { Eye, EyeOff } from 'lucide-react' +import { Input } from '@/components/ui/Input' +import { Textarea } from '@/components/ui/Textarea' +import { useScriptGeneratorStore } from '@/store/scriptGeneratorStore' +import type { ScriptParameter } from '@/types' + +interface Props { + param: ScriptParameter + value: string + error: string | undefined + disabled: boolean +} + +export function ScriptParameterField({ param, value, error, disabled }: Props) { + const setParamValue = useScriptGeneratorStore(s => s.setParamValue) + const [showPassword, setShowPassword] = useState(false) + + const id = `param-${param.key}` + + const handleChange = (e: React.ChangeEvent) => { + setParamValue(param.key, e.target.value) + } + + const handleCheckbox = (e: React.ChangeEvent) => { + setParamValue(param.key, e.target.checked ? 'true' : 'false') + } + + let input: React.ReactNode + + if (param.type === 'text' || param.type === 'multi_text' || param.type === 'number') { + input = ( + + ) + } else if (param.type === 'password') { + input = ( +
+ + +
+ ) + } else if (param.type === 'textarea') { + input = ( +