Selection reset logic update
This commit is contained in:
parent
2579e449be
commit
68e6b80d2d
@ -11,15 +11,15 @@ interface WhitelistUploadProps {
|
|||||||
export const WhitelistUpload = ({ onChange }: WhitelistUploadProps) => {
|
export const WhitelistUpload = ({ onChange }: WhitelistUploadProps) => {
|
||||||
const onFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const onFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (!event.target.files) return toast.error('Error opening file')
|
if (!event.target.files) return toast.error('Error opening file')
|
||||||
|
if (event.target.files.length !== 1) {
|
||||||
|
toast.error('No file selected')
|
||||||
|
return onChange([])
|
||||||
|
}
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
if (event.target.files[0]?.type !== 'text/plain') {
|
if (event.target.files[0]?.type !== 'text/plain') {
|
||||||
toast.error('Invalid file type')
|
toast.error('Invalid file type')
|
||||||
return onChange([])
|
return onChange([])
|
||||||
}
|
}
|
||||||
if (event.target.files.length === 0) {
|
|
||||||
toast.error('No file selected')
|
|
||||||
return onChange([])
|
|
||||||
}
|
|
||||||
const reader = new FileReader()
|
const reader = new FileReader()
|
||||||
reader.onload = (e: ProgressEvent<FileReader>) => {
|
reader.onload = (e: ProgressEvent<FileReader>) => {
|
||||||
const text = e.target?.result?.toString()
|
const text = e.target?.result?.toString()
|
||||||
|
Loading…
Reference in New Issue
Block a user