Skip to content
Snippets Groups Projects
App.tsx 1.63 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { ThemeProvider } from '@material-ui/core'
    
    import Navbar from 'components/Navbar/Navbar'
    
    import AppRoutes from 'components/Routes/Routes'
    
    Yoan VALLET's avatar
    Yoan VALLET committed
    import SplashRoot from 'components/Splash/SplashRoot'
    
    import WelcomeModal from 'components/WelcomeModal/WelcomeModal'
    
    import { useWebviewIntent } from 'cozy-intent'
    
    import { Layout } from 'cozy-ui/transpiled/react/Layout'
    
    import React, { useEffect } from 'react'
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
    import { useLocation } from 'react-router-dom'
    
    import { useAppSelector } from 'store/hooks'
    
    import MatomoTracker from 'utils/matomoTracker'
    
    import { theme } from './theme'
    
    interface AppProps {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      tracker: undefined | MatomoTracker
    
    export const App = ({ tracker }: AppProps) => {
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      const location = useLocation()
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
      const {
        global: { termsStatus },
        profile: { onboarding },
    
      } = useAppSelector(state => state.ecolyo)
    
      const webviewIntent = useWebviewIntent()
    
    Bastien DUMONT's avatar
    Bastien DUMONT committed
        tracker?.track(location)
      }, [tracker, location])
    
      useEffect(() => {
        webviewIntent?.call('setFlagshipUI', {
          bottomBackground: '#32343d',
          bottomTheme: 'light',
          topBackground: '#1b1c22',
          topTheme: 'light',
        })
      }, [webviewIntent])
    
    
          <ThemeProvider theme={theme}>
            <SplashRoot>
              {termsStatus.accepted && (
                <>
                  <WelcomeModal open={!onboarding.isWelcomeSeen} />
                  <Navbar />
                </>
              )}
              <main className="app-content">
                <AppRoutes termsStatus={termsStatus} />
              </main>
            </SplashRoot>
          </ThemeProvider>