Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

83 řádky
2.5 KiB

  1. import { StrictMode, useEffect, useContext } from 'react';
  2. import { createRoot } from 'react-dom/client';
  3. import { BrowserRouter } from 'react-router-dom';
  4. import './assets/fonts.css';
  5. import './assets/style/styles.css';
  6. // scroll bar
  7. import 'simplebar/src/simplebar.css';
  8. // third-party
  9. import { Provider as ReduxProvider } from 'react-redux';
  10. // apex-chart
  11. import 'assets/third-party/apex-chart.css';
  12. // project import
  13. import App from './App';
  14. import { store } from 'store';
  15. import reportWebVitals from './reportWebVitals';
  16. import { I18nProvider } from "components/I18nProvider";
  17. import { AutoLogoutProvider } from "components/AutoLogoutProvider";
  18. import { RefreshTokenProvider } from "components/RefreshTokenProvider";
  19. import { SysSettingProvider, SysContext } from 'components/SysSettingProvider';
  20. import { useLocation } from 'react-router-dom';
  21. function GreyWrapper({ children }) {
  22. const location = useLocation();
  23. const { sysSetting } = useContext(SysContext);
  24. useEffect(() => {
  25. const isLoginPage = location.pathname === '/login';
  26. const enableGrey = sysSetting?.greyLogin === true;
  27. if (isLoginPage && enableGrey) {
  28. document.body.classList.add('page-grey');
  29. } else {
  30. document.body.classList.remove('page-grey');
  31. }
  32. return () => {
  33. document.body.classList.remove('page-grey');
  34. };
  35. }, [location.pathname, sysSetting?.greyLogin]);
  36. return children;
  37. }
  38. // ==============================|| MAIN - REACT DOM RENDER ||============================== //
  39. const container = document.getElementById('root');
  40. const root = createRoot(container); // createRoot(container!) if you use TypeScript
  41. //const NotAuthorized = lazy(() => import('../views/NotAuthorized'))
  42. //const Error = lazy(() => import('../views/Error'))
  43. root.render(
  44. <StrictMode>
  45. <ReduxProvider store={store}>
  46. <SysSettingProvider>
  47. <I18nProvider>
  48. <BrowserRouter
  49. basename="/"
  50. future={{ v7_startTransition: true, v7_relativeSplatPath: true }}
  51. >
  52. <RefreshTokenProvider>
  53. <AutoLogoutProvider>
  54. <GreyWrapper>
  55. <App />
  56. </GreyWrapper>
  57. </AutoLogoutProvider>
  58. </RefreshTokenProvider>
  59. </BrowserRouter>
  60. </I18nProvider>
  61. </SysSettingProvider>
  62. </ReduxProvider>
  63. </StrictMode>
  64. );
  65. // If you want to start measuring performance in your app, pass a function
  66. // to log results (for example: reportWebVitals(console.log))
  67. // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
  68. reportWebVitals();