@@ -3,6 +3,7 @@ import axios from 'axios';
33import { useCallback , useState } from 'react' ;
44import { useDropzone } from 'react-dropzone' ;
55import { useTranslation } from 'react-i18next' ;
6+ import { toast } from 'react-toastify' ;
67import { SettingsForm } from '../../../../components/forms/SettingsForm' ;
78import { useAppActions , useAppStore } from '../../../../hooks/app' ;
89import type { MapConfig } from '../../../../types' ;
@@ -46,31 +47,36 @@ function RouteComponent() {
4647 // TODO: set configurations in a safer way!
4748 useAppStore . setState ( ( ) => config ) ;
4849 setConfigUrl ( '' ) ;
50+ toast . success ( t ( 'config-loaded-success' ) ) ;
4951 } catch ( error ) {
5052 console . error ( 'Failed to load config from URL:' , error ) ;
51- alert ( 'Failed to load configuration from URL. Please check the URL and try again.' ) ;
53+ toast . error ( t ( 'config- load-error' ) ) ;
5254 } finally {
5355 setIsLoading ( false ) ;
5456 }
55- } , [ configUrl ] ) ;
57+ } , [ configUrl , t ] ) ;
5658
57- const onDrop = useCallback ( ( acceptedFiles : File [ ] ) => {
58- acceptedFiles . forEach ( file => {
59- const reader = new FileReader ( ) ;
59+ const onDrop = useCallback (
60+ ( acceptedFiles : File [ ] ) => {
61+ acceptedFiles . forEach ( file => {
62+ const reader = new FileReader ( ) ;
6063
61- // TODO: improve logging and error management
62- reader . onabort = ( ) => console . warn ( 'file reading was aborted' ) ;
63- reader . onerror = ( ) => console . error ( 'file reading has failed' ) ;
64- reader . onload = ( ) => {
65- const config = JSON . parse ( reader . result as string ) as MapConfig ;
66- console . debug ( config ) ;
64+ // TODO: improve logging and error management
65+ reader . onabort = ( ) => console . warn ( 'file reading was aborted' ) ;
66+ reader . onerror = ( ) => console . error ( 'file reading has failed' ) ;
67+ reader . onload = ( ) => {
68+ const config = JSON . parse ( reader . result as string ) as MapConfig ;
69+ console . debug ( config ) ;
6770
68- // TODO: set configurations in a safer way!
69- useAppStore . setState ( ( ) => config ) ;
70- } ;
71- reader . readAsText ( file ) ;
72- } ) ;
73- } , [ ] ) ;
71+ // TODO: set configurations in a safer way!
72+ useAppStore . setState ( ( ) => config ) ;
73+ toast . success ( t ( 'config-loaded-success' ) ) ;
74+ } ;
75+ reader . readAsText ( file ) ;
76+ } ) ;
77+ } ,
78+ [ t ] ,
79+ ) ;
7480
7581 const settings = useAppStore ( store => store . config ) ;
7682
0 commit comments