import { AppContextProvider } from '@/context.ts'
import { initI18n } from '@/i18n.ts'
import { appAtom, appStore, changeLanguage } from '@/store/system.ts'
import { IAppData } from '@/global'
import { ConfigProvider } from '@/components/config-provider'
import { Provider, useAtom } from 'jotai'
import './App.css'
import { useEffect } from 'react'
import { RootProvider } from './routes.tsx'


function App() {

    const [ appData, ] = useAtom(appAtom)

    useEffect(() => {
        initI18n()
    }, [])


    return (
            <ConfigProvider>
                <AppContextProvider value={{
                    get appData() {
                        return appData as IAppData
                    },
                    changeLanguage
                }}>
                    <Provider store={appStore}>
                        <RootProvider context={{}}/>
                    </Provider>
                </AppContextProvider>
            </ConfigProvider>
    )
}

export default App
