|
|
@@ -0,0 +1,199 @@
|
|
|
+
|
|
|
+// GA
|
|
|
+import ReactGA from 'react-ga4';
|
|
|
+
|
|
|
+// utils
|
|
|
+import {lazy, Suspense} from 'react';
|
|
|
+
|
|
|
+// styles
|
|
|
+import ThemeStyles from '@styles/theme';
|
|
|
+import './style.scss';
|
|
|
+
|
|
|
+// libs styles
|
|
|
+import 'react-toastify/dist/ReactToastify.min.css';
|
|
|
+import 'react-grid-layout/css/styles.css';
|
|
|
+import 'swiper/css';
|
|
|
+import 'swiper/css/effect-fade';
|
|
|
+import 'swiper/css/pagination';
|
|
|
+
|
|
|
+// fonts
|
|
|
+import '@fonts/icomoon/icomoon.woff';
|
|
|
+
|
|
|
+// contexts
|
|
|
+import {SidebarProvider, useSidebar} from '@contexts/sidebarContext';
|
|
|
+import {ThemeProvider} from 'styled-components';
|
|
|
+
|
|
|
+// hooks
|
|
|
+import {useThemeProvider} from '@contexts/themeContext';
|
|
|
+import {useEffect, useRef} from 'react';
|
|
|
+import {useWindowSize} from 'react-use';
|
|
|
+import useAuthRoute from '@hooks/useAuthRoute';
|
|
|
+
|
|
|
+// utils
|
|
|
+import {StyleSheetManager} from 'styled-components';
|
|
|
+import {ThemeProvider as MuiThemeProvider, createTheme} from '@mui/material/styles';
|
|
|
+import {preventDefault} from '@utils/helpers';
|
|
|
+import rtlPlugin from 'stylis-plugin-rtl';
|
|
|
+import {CacheProvider} from '@emotion/react';
|
|
|
+import createCache from '@emotion/cache';
|
|
|
+
|
|
|
+// components
|
|
|
+import {BrowserRouter, HashRouter, Route, Routes, useLocation} from 'react-router-dom';
|
|
|
+import {ToastContainer} from 'react-toastify';
|
|
|
+import LoadingScreen from '@components/LoadingScreen';
|
|
|
+import Sidebar from '@layout/Sidebar';
|
|
|
+import BottomNav from '@layout/BottomNav';
|
|
|
+import Navbar from '@layout/Navbar';
|
|
|
+import ShoppingCart from '@widgets/ShoppingCart';
|
|
|
+import ScrollToTop from '@components/ScrollToTop';
|
|
|
+import AppContainer from "@layout/AppContainer";
|
|
|
+import {APP_ROUTES} from "@api/config";
|
|
|
+import Http from "@api/request";
|
|
|
+import Layout from "@layout/Layout";
|
|
|
+
|
|
|
+// pages
|
|
|
+const ClubSummary = lazy(() => import('@pages/ClubSummary'));
|
|
|
+const GameSummary = lazy(() => import('@pages/GameSummary'));
|
|
|
+const Championships = lazy(() => import('@pages/Championships'));
|
|
|
+const LeagueOverview = lazy(() => import('@pages/LeagueOverview'));
|
|
|
+const FansCommunity = lazy(() => import('@pages/FansCommunity'));
|
|
|
+const Statistics = lazy(() => import('@pages/Statistics'));
|
|
|
+const PageNotFound = lazy(() => import('@pages/PageNotFound'));
|
|
|
+const MatchSummary = lazy(() => import('@pages/MatchSummary'));
|
|
|
+const MatchOverview = lazy(() => import('@pages/MatchOverview'));
|
|
|
+const PlayerProfile = lazy(() => import('@pages/PlayerProfile'));
|
|
|
+const Schedule = lazy(() => import('@pages/Schedule'));
|
|
|
+const Tickets = lazy(() => import('@pages/Tickets'));
|
|
|
+const FootballStore = lazy(() => import('@pages/FootballStore'));
|
|
|
+const BrandStore = lazy(() => import('@pages/BrandStore'));
|
|
|
+const Product = lazy(() => import('@pages/Product'));
|
|
|
+const Login = lazy(() => import('@pages/Login'));
|
|
|
+const SignUp = lazy(() => import('@pages/SignUp'));
|
|
|
+const Settings = lazy(() => import('@pages/Settings'));
|
|
|
+
|
|
|
+const App = () => {
|
|
|
+ const appRef = useRef(null);
|
|
|
+ const {theme, direction} = useThemeProvider();
|
|
|
+ const {width} = useWindowSize();
|
|
|
+ // const isAuthRoute = useAuthRoute();
|
|
|
+ const isAuthRoute = false;
|
|
|
+ const {pathname, search, hash} = useLocation();
|
|
|
+ // Google Analytics init
|
|
|
+ const gaKey = process.env.REACT_APP_PUBLIC_GA;
|
|
|
+ gaKey && ReactGA.initialize(gaKey);
|
|
|
+
|
|
|
+ // auto RTL support for Material-UI components and styled-components
|
|
|
+
|
|
|
+ const plugins = direction === 'rtl' ? [rtlPlugin] : [];
|
|
|
+
|
|
|
+ const muiTheme = createTheme({
|
|
|
+ direction: direction,
|
|
|
+ });
|
|
|
+
|
|
|
+ const cacheRtl = createCache({
|
|
|
+ key: 'css-rtl',
|
|
|
+ stylisPlugins: plugins,
|
|
|
+ });
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ // scroll to top on route change
|
|
|
+ appRef.current && appRef.current.scrollTo(0, 0);
|
|
|
+ preventDefault();
|
|
|
+ }, []);
|
|
|
+ // return (
|
|
|
+ // <CacheProvider value={cacheRtl}>
|
|
|
+ // <MuiThemeProvider theme={muiTheme}>
|
|
|
+ // <SidebarProvider>
|
|
|
+ // <ThemeProvider theme={{theme: theme}}>
|
|
|
+ // <ThemeStyles/>
|
|
|
+ // <ToastContainer theme={theme} autoClose={2500}
|
|
|
+ // position={direction === 'ltr' ? 'top-right' : 'top-left'}/>
|
|
|
+ // <StyleSheetManager stylisPlugins={plugins}>
|
|
|
+ // <div className={`app ${isAuthRoute ? 'fluid' : ''}`} ref={appRef}>
|
|
|
+ // <ScrollToTop/>
|
|
|
+ // {
|
|
|
+ // !isAuthRoute && (
|
|
|
+ // <>
|
|
|
+ // <Sidebar/>
|
|
|
+ // <Navbar/>
|
|
|
+ // {
|
|
|
+ // // width < 768 && <Navbar/>
|
|
|
+ // }
|
|
|
+ // {
|
|
|
+ // width < 768 && <BottomNav/>
|
|
|
+ // }
|
|
|
+ // </>
|
|
|
+ // )
|
|
|
+ // }
|
|
|
+ // {/*<div className={`app_container ${true?'sidebar-open':'sidebar-close'}`}>*/}
|
|
|
+ // <AppContainer>
|
|
|
+ // <div className="app_container-content d-flex flex-column flex-1">
|
|
|
+ // <Suspense fallback={<LoadingScreen/>}>
|
|
|
+ // <Routes>
|
|
|
+ // <Route path="*" element={<PageNotFound/>}/>
|
|
|
+ // <Route path="/" element={<ClubSummary/>}/>
|
|
|
+ // <Route path="/game-summary" element={<GameSummary/>}/>
|
|
|
+ // <Route path="/championships" element={<Championships/>}/>
|
|
|
+ // <Route path="/league-overview" element={<LeagueOverview/>}/>
|
|
|
+ // <Route path="/fans-community" element={<FansCommunity/>}/>
|
|
|
+ // <Route path="/statistics" element={<Statistics/>}/>
|
|
|
+ // <Route path="/match-summary" element={<MatchSummary/>}/>
|
|
|
+ // <Route path="/match-overview" element={<MatchOverview/>}/>
|
|
|
+ // <Route path="/player-profile" element={<PlayerProfile/>}/>
|
|
|
+ // <Route path="/schedule" element={<Schedule/>}/>
|
|
|
+ // <Route path="/tickets" element={<Tickets/>}/>
|
|
|
+ // <Route path="/football-store" element={<FootballStore/>}/>
|
|
|
+ // <Route path="/brand-store" element={<BrandStore/>}/>
|
|
|
+ // <Route path="/product" element={<Product/>}/>
|
|
|
+ // </Routes>
|
|
|
+ // {
|
|
|
+ // hash != '' ? (
|
|
|
+ // <Routes location={{
|
|
|
+ // pathname: (pathname + hash),
|
|
|
+ // search: search,
|
|
|
+ // hash: hash
|
|
|
+ // }}>
|
|
|
+ // <Route path={`${pathname}#/settings`} element={<div style={{
|
|
|
+ // backgroundColor: '#fff',
|
|
|
+ // zIndex: 2000,
|
|
|
+ // position: "fixed",
|
|
|
+ // width: '100px',
|
|
|
+ // height: '100px'
|
|
|
+ // }}/>}/>
|
|
|
+ // <Route path={`${pathname}#/sign-up`} element={<MatchSummary/>}/>
|
|
|
+ // </Routes>
|
|
|
+ // ) : (<></>)
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // </Suspense>
|
|
|
+ //
|
|
|
+ // </div>
|
|
|
+ // {/*</div>*/}
|
|
|
+ // </AppContainer>
|
|
|
+ // <ShoppingCart isPopup/>
|
|
|
+ // </div>
|
|
|
+ // </StyleSheetManager>
|
|
|
+ // </ThemeProvider>
|
|
|
+ // </SidebarProvider>
|
|
|
+ // </MuiThemeProvider>
|
|
|
+ // </CacheProvider>
|
|
|
+ // );
|
|
|
+ return (
|
|
|
+ <CacheProvider value={cacheRtl}>
|
|
|
+ <MuiThemeProvider theme={muiTheme}>
|
|
|
+ <SidebarProvider>
|
|
|
+ <ThemeProvider theme={{theme: theme}}>
|
|
|
+ <ThemeStyles/>
|
|
|
+ <ToastContainer theme={theme} autoClose={2500}
|
|
|
+ position={direction === 'ltr' ? 'top-right' : 'top-left'}/>
|
|
|
+ <StyleSheetManager stylisPlugins={plugins}>
|
|
|
+ <Layout />
|
|
|
+ </StyleSheetManager>
|
|
|
+ </ThemeProvider>
|
|
|
+ </SidebarProvider>
|
|
|
+ </MuiThemeProvider>
|
|
|
+ </CacheProvider>
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+export default App
|