import React, { useCallback } from "react"; import ReactDOM from "react-dom/client"; import { BrowserRouter, Navigate, Route, Routes, useLocation } from "react-router-dom"; import { CssBaseline, ThemeProvider } from "@mui/material"; import Faq from "./pages/Faq/Faq"; import Wallet from "./pages/Wallet"; import Payment from "./pages/Payment/Payment"; import Support from "./pages/Support/Support"; import AccountSetup from "./pages/AccountSetup/AccountSetup"; import Landing from "./pages/Landing/Landing"; import Tariffs from "./pages/Tariffs/Tariffs"; import SigninDialog from "./pages/auth/Signin"; import SignupDialog from "./pages/auth/Signup"; import PaymentHistory from "./pages/PaymentHistory/PaymentHistory"; import Basket from "./pages/Basket/Basket"; import TariffPage from "./pages/Tariffs/TariffsPage"; import lightTheme from "@utils/themes/light"; import PrivateRoute from "@utils/routes/privateRoute"; import reportWebVitals from "./reportWebVitals"; import { SnackbarProvider, enqueueSnackbar } from "notistack"; import "./index.css"; import Layout from "./components/Layout"; import { setUser, useUserStore } from "./stores/user"; import TariffConstructor from "./pages/TariffConstructor/TariffConstructor"; import { useUser } from "./utils/hooks/useUser"; const App = () => { const location = useLocation(); const userId = useUserStore(state => state.userId); useUser({ url: `https://hub.pena.digital/user/${userId}`, userId, onNewUser: setUser, onError: useCallback(error => { enqueueSnackbar(error.response?.data?.message ?? error.message ?? "Error fetching user"); setUser(null); }, []) }); if (location.state?.redirectTo) return ; return ( <> {location.state?.backgroundLocation && } /> } /> } } /> } /> } /> }> } /> } /> } /> } /> } /> } /> } /> } /> }> } /> } /> } /> } /> ); }; const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement); root.render( ); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals reportWebVitals();