import { useRef, useState } from 'react'; import { IconCloudUpload, IconDownload, IconX } from '@tabler/icons-react'; import { Button, Group, Text, useMantineTheme } from '@mantine/core'; import { Dropzone } from '@mantine/dropzone'; import classes from './AirportDrop.module.css'; import { importAirports } from '@lib/airport.ts'; export function AirportDrop() { const theme = useMantineTheme(); const openRef = useRef<() => void>(null); const [loading, setLoading] = useState(false); return (
{ if (files.length === 0) return; setLoading(true); try { const formData = new FormData(); files.forEach((file) => { formData.append('files', file, file.name); }); await importAirports(formData); } catch (error) { console.error('Upload error:', error); } finally { setLoading(false); } }} className={classes.dropzone} radius='md' accept={['application/JSON']} maxSize={30 * 1024 ** 2} >
Drop files here Json file less than 30mb Upload JSON Drag'n'drop files here to upload. We can accept only .json files that are less than 30mb in size.
); }