Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

check the file type and reject non-JSON file

CodeMaker-Zhao9b70222ff993
diff --git a/src/containers/Modals/ImportModal/index.tsx b/src/containers/Modals/ImportModal/index.tsx
index 6f2e0e09..3cab186e 100644
--- a/src/containers/Modals/ImportModal/index.tsx
+++ b/src/containers/Modals/ImportModal/index.tsx
@@ -54,7 +54,11 @@ export const ImportModal: React.FC<ModalProps> = ({ visible, setVisible }) => {
e.preventDefault();
if (e.type === 'drop' && e.dataTransfer.files.length) {
- setJsonFile(e.dataTransfer.files[0])
+ if (e.dataTransfer.files[0].type === 'application/json') {
+ setJsonFile(e.dataTransfer.files[0])
+ } else {
+ toast.error('Please upload JSON file!')
+ }
}
}