import clsx from 'clsx' import React from 'react' import { toast } from 'react-hot-toast' interface WhitelistUploadProps { onChange: (data: string[]) => void } export const WhitelistUpload = ({ onChange }: WhitelistUploadProps) => { const onFileChange = (event: React.ChangeEvent) => { if (!event.target.files) return toast.error('Error opening file') if (event.target.files[0].type !== 'text/plain') return toast.error('Invalid file type') const reader = new FileReader() reader.onload = (e: ProgressEvent) => { const text = e.target?.result?.toString() let newline = '\n' if (text?.includes('\r')) newline = '\r' if (text?.includes('\r\n')) newline = '\r\n' const data = text?.split(newline) return onChange([...new Set(data?.filter((address) => address !== '') || [])]) } reader.readAsText(event.target.files[0]) } return (
) }