(input: RuntimeInputDefinition)
| 152 | }; |
| 153 | |
| 154 | const renderInput = (input: RuntimeInputDefinition) => { |
| 155 | const hasError = !!errors[input.id]; |
| 156 | const isUploading = uploading[input.id]; |
| 157 | const inputType = normalizeRuntimeInputType(input.type); |
| 158 | |
| 159 | switch (inputType) { |
| 160 | case 'file': |
| 161 | return ( |
| 162 | <div className="space-y-2"> |
| 163 | <Label htmlFor={input.id}> |
| 164 | {input.label} |
| 165 | {input.required && <span className="text-red-500 ml-1">*</span>} |
| 166 | </Label> |
| 167 | <div className="flex gap-2 items-center"> |
| 168 | <Input |
| 169 | id={input.id} |
| 170 | type="file" |
| 171 | onChange={(e) => { |
| 172 | const file = e.target.files?.[0]; |
| 173 | if (file) { |
| 174 | handleFileUpload(input.id, file); |
| 175 | } |
| 176 | }} |
| 177 | disabled={isUploading} |
| 178 | className={hasError ? 'border-red-500' : ''} |
| 179 | /> |
| 180 | {isUploading && <Loader2 className="h-4 w-4 animate-spin" />} |
| 181 | </div> |
| 182 | {inputs[input.id] != null && ( |
| 183 | <p className="text-xs text-green-600"> |
| 184 | ✓ File uploaded:{' '} |
| 185 | { |
| 186 | (typeof inputs[input.id] === 'string' |
| 187 | ? inputs[input.id] |
| 188 | : String(inputs[input.id])) as React.ReactNode |
| 189 | } |
| 190 | </p> |
| 191 | )} |
| 192 | {input.description && ( |
| 193 | <p className="text-xs text-muted-foreground">{input.description}</p> |
| 194 | )} |
| 195 | {hasError && <p className="text-xs text-red-500">{errors[input.id]}</p>} |
| 196 | </div> |
| 197 | ); |
| 198 | |
| 199 | case 'json': |
| 200 | return ( |
| 201 | <div className="space-y-2"> |
| 202 | <Label htmlFor={input.id}> |
| 203 | {input.label} |
| 204 | {input.required && <span className="text-red-500 ml-1">*</span>} |
| 205 | </Label> |
| 206 | <Textarea |
| 207 | id={input.id} |
| 208 | placeholder='{"key": "value"}' |
| 209 | onChange={(e) => handleInputChange(input.id, e.target.value, inputType)} |
| 210 | className={hasError ? 'border-red-500' : ''} |
| 211 | rows={4} |
no test coverage detected