Skip to content

Commit

Permalink
Merge pull request #1017 from nk-coding/bugfix/csv_import
Browse files Browse the repository at this point in the history
fix csv upload: accept correct content type
  • Loading branch information
nk-coding authored Oct 23, 2022
2 parents f313021 + 531c264 commit 8bfe403
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 2 additions & 6 deletions client/src/components/UploadFileButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,14 @@ function UploadFileButton({
async (file: File) => {
setLoading(true);

if (!supportedFileTypes.includes(file.type)) {
return;
}

const content: string = await file.text();
const cb = onFileSelect(content, file);

await Promise.resolve(cb);

setLoading(false);
},
[supportedFileTypes, onFileSelect]
[onFileSelect]
);

const handleFileUpload = useCallback(
Expand All @@ -77,7 +73,7 @@ function UploadFileButton({
>
<Box display='flex'>
<input
accept='.csv'
accept={supportedFileTypes.join(',')}
style={{ display: 'none' }}
id='icon-button-file'
type='file'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Box, Grow, Typography } from '@material-ui/core';
import { FileCheckOutline as FileSelectedIcon } from 'mdi-material-ui';
import React from 'react';
import OutlinedBox from '../../OutlinedBox';
import UploadFileButton from '../../UploadFileButton';

Expand All @@ -18,7 +17,7 @@ function ImportCSVFromFile({ fileInfo, onFileInfoChanged }: ImportCSVFromFilePro
return (
<>
<UploadFileButton
supportedFileTypes={['application/vnd.ms-excel']}
supportedFileTypes={['text/csv']}
onFileSelect={(content: string, file: File) =>
onFileInfoChanged({ content, fileName: file.name })
}
Expand Down

0 comments on commit 8bfe403

Please sign in to comment.