import { Group, Text, useMantineTheme } from '@mantine/core'; import { IconX as X, IconCheck as Check, IconX, IconPhoto, IconUpload } from '@tabler/icons'; import { showNotification } from '@mantine/notifications'; import { setCookie } from 'cookies-next'; import { Dropzone } from '@mantine/dropzone'; import { useConfig } from '../../tools/state'; import { Config } from '../../tools/types'; import { migrateToIdConfig } from '../../tools/migrate'; export default function LoadConfigComponent(props: any) { const { setConfig } = useConfig(); const theme = useMantineTheme(); return ( { files[0].text().then((e) => { try { JSON.parse(e) as Config; } catch (e) { showNotification({ autoClose: 5000, title: Error, color: 'red', icon: , message: 'could not load your config. Invalid JSON format.', }); return; } const newConfig: Config = JSON.parse(e); showNotification({ autoClose: 5000, radius: 'md', title: ( Config {newConfig.name} loaded successfully ), color: 'green', icon: , message: undefined, }); setCookie('config-name', newConfig.name, { maxAge: 60 * 60 * 24 * 30, sameSite: 'strict', }); const migratedConfig = migrateToIdConfig(newConfig); setConfig(migratedConfig); }); }} accept={['application/json']} > Drag files here to upload a config. Support for JSON only. This file format is not supported. Please only upload JSON. ); }