(inputId: string, file: File)
| 59 | }, [initialValues, open]); |
| 60 | |
| 61 | const handleFileUpload = async (inputId: string, file: File) => { |
| 62 | setUploading((prev) => ({ ...prev, [inputId]: true })); |
| 63 | setErrors((prev) => ({ ...prev, [inputId]: '' })); |
| 64 | |
| 65 | try { |
| 66 | const formData = new FormData(); |
| 67 | formData.append('file', file); |
| 68 | |
| 69 | const fileData = await api.files.upload(file); |
| 70 | setInputs((prev) => ({ ...prev, [inputId]: fileData.id })); |
| 71 | } catch (error) { |
| 72 | console.error('File upload failed:', error); |
| 73 | setErrors((prev) => ({ |
| 74 | ...prev, |
| 75 | [inputId]: error instanceof Error ? error.message : 'Upload failed', |
| 76 | })); |
| 77 | } finally { |
| 78 | setUploading((prev) => ({ ...prev, [inputId]: false })); |
| 79 | } |
| 80 | }; |
| 81 | |
| 82 | const handleInputChange = (inputId: string, value: unknown, type: RuntimeInputType) => { |
| 83 | setErrors((prev) => ({ ...prev, [inputId]: '' })); |
no test coverage detected