refactor: update setFiles prop type to accept File[] and simplify file handling

This commit is contained in:
dayuan.jiang
2025-03-27 08:02:03 +00:00
parent 34cc437523
commit 7e0790d60f
6 changed files with 199 additions and 67 deletions

View File

@@ -3,13 +3,8 @@ export default function ExamplePanel({
setFiles,
}: {
setInput: (input: string) => void;
setFiles: (files: FileList | undefined) => void;
setFiles: (files: File[]) => void;
}) {
const createFileList = (file: File): FileList => {
const dt = new DataTransfer();
dt.items.add(file);
return dt.files;
};
// New handler for the "Replicate this flowchart" button
const handleReplicateFlowchart = async () => {
setInput("Replicate this flowchart.");
@@ -21,7 +16,7 @@ export default function ExamplePanel({
const file = new File([blob], "example.png", { type: "image/png" });
// Set the file to the files state
setFiles(createFileList(file));
setFiles([file]);
} catch (error) {
console.error("Error loading example image:", error);
}