From 4ab3d9c7ec4d9d3dbab13730101b108c314ac008 Mon Sep 17 00:00:00 2001 From: nflnkr Date: Mon, 10 Jun 2024 13:57:57 +0300 Subject: [PATCH] fix rules of hooks violation --- src/App.tsx | 99 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 57 insertions(+), 42 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 7e86ee7b..26e33444 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,30 +4,13 @@ import { lazily } from "react-lazily"; import ContactFormModal from "@ui_kit/ContactForm"; import SigninDialog from "./pages/auth/Signin"; import SignupDialog from "./pages/auth/Signup"; -import { - Navigate, - Route, - Routes, - useLocation, - useNavigate, -} from "react-router-dom"; +import { Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom"; import "./index.css"; import Landing from "./pages/Landing/Landing"; import Main from "./pages/main"; -import { - clearAuthToken, - getMessageFromFetchError, - UserAccount, - useUserFetcher, -} from "@frontend/kitui"; +import { clearAuthToken, getMessageFromFetchError, UserAccount, useUserFetcher } from "@frontend/kitui"; import type { OriginalUserAccount } from "@root/user"; -import { - clearUserData, - setCustomerAccount, - setUser, - setUserAccount, - useUserStore, -} from "@root/user"; +import { clearUserData, setCustomerAccount, setUser, setUserAccount, useUserStore } from "@root/user"; import { enqueueSnackbar } from "notistack"; import PrivateRoute from "@ui_kit/PrivateRoute"; import FloatingSupportChat from "@ui_kit/FloatingSupportChat"; @@ -50,15 +33,9 @@ const Analytics = lazy(() => import("./pages/Analytics/Analytics")); const EditPage = lazy(() => import("./pages/startPage/EditPage")); const { Tariffs } = lazily(() => import("./pages/Tariffs/Tariffs")); const { DesignPage } = lazily(() => import("./pages/DesignPage/DesignPage")); -const { IntegrationsPage } = lazily( - () => import("./pages/IntegrationsPage/IntegrationsPage"), -); -const { QuizAnswersPage } = lazily( - () => import("./pages/QuizAnswersPage/QuizAnswersPage"), -); -const ChatImageNewWindow = lazy( - () => import("@ui_kit/FloatingSupportChat/ChatImageNewWindow"), -); +const { IntegrationsPage } = lazily(() => import("./pages/IntegrationsPage/IntegrationsPage")); +const { QuizAnswersPage } = lazily(() => import("./pages/QuizAnswersPage/QuizAnswersPage")); +const ChatImageNewWindow = lazy(() => import("@ui_kit/FloatingSupportChat/ChatImageNewWindow")); const routeslink = [ { @@ -137,6 +114,8 @@ export default function App() { }, }); + useAfterpay(); + if (location.state?.redirectTo) return ( ); - useAfterpay(); - return ( <> {location.state?.backgroundLocation && ( - } /> - } /> - } /> - } /> - } /> + } + /> + } + /> + } + /> + } + /> + } + /> )} - } /> + } + /> + } /> + } /> + } /> } fallback={} />} + element={ + } + fallback={} + /> + } /> } />} /> - } /> + } + /> }> {routeslink.map((e, i) => (