@@ -110,7 +110,7 @@ interface ConfigFormProps {
110
110
}
111
111
112
112
function ConfigForm ( { config, onSubmit } : ConfigFormProps ) {
113
- const [ prompts , setPrompts ] = useState < any > ( null ) ;
113
+ const [ prompts , setPrompts ] = useState < any [ ] > ( [ ] ) ;
114
114
const [ videoDevices , setVideoDevices ] = useState < VideoDevice [ ] > ( [ ] ) ;
115
115
const [ audioDevices , setAudioDevices ] = useState < VideoDevice [ ] > ( [ ] ) ;
116
116
const [ selectedDevice , setSelectedDevice ] = useState < string > ( "" ) ;
@@ -191,15 +191,20 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
191
191
} ) ;
192
192
} ;
193
193
194
- const handlePromptsChange = async ( e : any ) => {
195
- const file = e . target . files [ 0 ] ;
196
- if ( ! file ) return ;
194
+ const handlePromptsChange = async ( e : React . ChangeEvent < HTMLInputElement > ) => {
195
+ if ( ! e . target . files ?. length ) return ;
197
196
198
197
try {
199
- const text = await file . text ( ) ;
200
- setPrompts ( JSON . parse ( text ) ) ;
198
+ const files = Array . from ( e . target . files ) ;
199
+ const fileReads = files . map ( async ( file ) => {
200
+ const text = await file . text ( ) ;
201
+ return JSON . parse ( text ) ;
202
+ } ) ;
203
+
204
+ const allPrompts = await Promise . all ( fileReads ) ;
205
+ setPrompts ( allPrompts ) ;
201
206
} catch ( err ) {
202
- console . error ( err ) ;
207
+ console . error ( "Failed to parse one or more JSON files." , err ) ;
203
208
}
204
209
} ;
205
210
@@ -274,8 +279,9 @@ function ConfigForm({ config, onSubmit }: ConfigFormProps) {
274
279
id = "video-workflow"
275
280
type = "file"
276
281
accept = ".json"
282
+ multiple
277
283
onChange = { handlePromptsChange }
278
- > </ Input >
284
+ / >
279
285
</ div >
280
286
281
287
< Button type = "submit" className = "w-full mt-4 mb-4" >
0 commit comments