From 0e1419cc9ac16087ad7d4cab13a0f0b791faefab Mon Sep 17 00:00:00 2001 From: ajnart Date: Mon, 1 Aug 2022 17:28:27 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20configLoader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Config/LoadConfig.tsx | 73 +++++++++++----------------- 1 file changed, 28 insertions(+), 45 deletions(-) diff --git a/src/components/Config/LoadConfig.tsx b/src/components/Config/LoadConfig.tsx index f29d65a75..09fc1a09f 100644 --- a/src/components/Config/LoadConfig.tsx +++ b/src/components/Config/LoadConfig.tsx @@ -5,61 +5,20 @@ import { IconX as X, IconCheck as Check, TablerIcon, + IconX, + IconPhoto, + IconUpload, } from '@tabler/icons'; import { showNotification } from '@mantine/notifications'; -import { useRef } from 'react'; -import { useRouter } from 'next/router'; 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'; -function getIconColor(status: DropzoneStatus, theme: MantineTheme) { - return status.accepted - ? theme.colors[theme.primaryColor][theme.colorScheme === 'dark' ? 4 : 6] - : status.rejected - ? theme.colors.red[theme.colorScheme === 'dark' ? 4 : 6] - : theme.colorScheme === 'dark' - ? theme.colors.dark[0] - : theme.colors.gray[7]; -} - -function ImageUploadIcon({ - status, - ...props -}: React.ComponentProps & { status: DropzoneStatus }) { - if (status.accepted) { - return ; - } - - if (status.rejected) { - return ; - } - - return ; -} - -export const dropzoneChildren = (status: DropzoneStatus, theme: MantineTheme) => ( - - - -
- - Drag images here or click to select files - - - Attach as many files as you like, each file should not exceed 5mb - -
-
-); - export default function LoadConfigComponent(props: any) { const { setConfig } = useConfig(); const theme = useMantineTheme(); - const router = useRouter(); - const openRef = useRef<() => void>(); return ( - {(status: any) => dropzoneChildren(status, theme)} + + + + + Drag files here to upload a config. Support for JSON only. + + + + + + This file format is not supported. Please only upload JSON. + + + + + + ); }