From 5ed26ef49c1a5132cf9141a36e9ec7eccac87d1a Mon Sep 17 00:00:00 2001 From: "Ghislain B." Date: Fri, 10 Jan 2025 17:38:11 -0500 Subject: [PATCH] chore: only accept CSV files --- src/examples/slickgrid/Example43.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/examples/slickgrid/Example43.tsx b/src/examples/slickgrid/Example43.tsx index f2d6e3f..ae776f0 100644 --- a/src/examples/slickgrid/Example43.tsx +++ b/src/examples/slickgrid/Example43.tsx @@ -16,14 +16,16 @@ export default function Example43() { } function handleFileImport(event: any) { - const file = event.target.files[0]; - if (file) { + const file: File = event.target.files[0]; + if (file.name.endsWith('.csv')) { const reader = new FileReader(); reader.onload = (e: any) => { const content = e.target.result; dynamicallyCreateGrid(content); }; reader.readAsText(file); + } else { + alert('File must be a CSV file'); } }