Merge branch 'dev' into 'staging'

fix rules of hooks violation

See merge request frontend/squiz!340
This commit is contained in:
Nastya 2024-06-10 18:47:14 +00:00
commit 5c9b0ecc0a

@ -4,30 +4,13 @@ import { lazily } from "react-lazily";
import ContactFormModal from "@ui_kit/ContactForm"; import ContactFormModal from "@ui_kit/ContactForm";
import SigninDialog from "./pages/auth/Signin"; import SigninDialog from "./pages/auth/Signin";
import SignupDialog from "./pages/auth/Signup"; import SignupDialog from "./pages/auth/Signup";
import { import { Navigate, Route, Routes, useLocation, useNavigate } from "react-router-dom";
Navigate,
Route,
Routes,
useLocation,
useNavigate,
} from "react-router-dom";
import "./index.css"; import "./index.css";
import Landing from "./pages/Landing/Landing"; import Landing from "./pages/Landing/Landing";
import Main from "./pages/main"; import Main from "./pages/main";
import { import { clearAuthToken, getMessageFromFetchError, UserAccount, useUserFetcher } from "@frontend/kitui";
clearAuthToken,
getMessageFromFetchError,
UserAccount,
useUserFetcher,
} from "@frontend/kitui";
import type { OriginalUserAccount } from "@root/user"; import type { OriginalUserAccount } from "@root/user";
import { import { clearUserData, setCustomerAccount, setUser, setUserAccount, useUserStore } from "@root/user";
clearUserData,
setCustomerAccount,
setUser,
setUserAccount,
useUserStore,
} from "@root/user";
import { enqueueSnackbar } from "notistack"; import { enqueueSnackbar } from "notistack";
import PrivateRoute from "@ui_kit/PrivateRoute"; import PrivateRoute from "@ui_kit/PrivateRoute";
import FloatingSupportChat from "@ui_kit/FloatingSupportChat"; 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 EditPage = lazy(() => import("./pages/startPage/EditPage"));
const { Tariffs } = lazily(() => import("./pages/Tariffs/Tariffs")); const { Tariffs } = lazily(() => import("./pages/Tariffs/Tariffs"));
const { DesignPage } = lazily(() => import("./pages/DesignPage/DesignPage")); const { DesignPage } = lazily(() => import("./pages/DesignPage/DesignPage"));
const { IntegrationsPage } = lazily( const { IntegrationsPage } = lazily(() => import("./pages/IntegrationsPage/IntegrationsPage"));
() => import("./pages/IntegrationsPage/IntegrationsPage"), const { QuizAnswersPage } = lazily(() => import("./pages/QuizAnswersPage/QuizAnswersPage"));
); const ChatImageNewWindow = lazy(() => import("@ui_kit/FloatingSupportChat/ChatImageNewWindow"));
const { QuizAnswersPage } = lazily(
() => import("./pages/QuizAnswersPage/QuizAnswersPage"),
);
const ChatImageNewWindow = lazy(
() => import("@ui_kit/FloatingSupportChat/ChatImageNewWindow"),
);
const routeslink = [ const routeslink = [
{ {
@ -137,6 +114,8 @@ export default function App() {
}, },
}); });
useAfterpay();
if (location.state?.redirectTo) if (location.state?.redirectTo)
return ( return (
<Navigate <Navigate
@ -146,39 +125,67 @@ export default function App() {
/> />
); );
useAfterpay();
return ( return (
<> <>
<ContactFormModal /> <ContactFormModal />
<FloatingSupportChat /> <FloatingSupportChat />
{location.state?.backgroundLocation && ( {location.state?.backgroundLocation && (
<Routes> <Routes>
<Route path="/signin" element={<SigninDialog />} /> <Route
<Route path="/signup" element={<SignupDialog />} /> path="/signin"
<Route path="/recover" element={<Restore />} /> element={<SigninDialog />}
<Route path="/changepwd" element={<RecoverPassword />} /> />
<Route path="/changepwd/expired" element={<OutdatedLink />} /> <Route
path="/signup"
element={<SignupDialog />}
/>
<Route
path="/recover"
element={<Restore />}
/>
<Route
path="/changepwd"
element={<RecoverPassword />}
/>
<Route
path="/changepwd/expired"
element={<OutdatedLink />}
/>
</Routes> </Routes>
)} )}
<Routes location={location.state?.backgroundLocation || location}> <Routes location={location.state?.backgroundLocation || location}>
<Route path="/" element={<Landing />} /> <Route
path="/"
element={<Landing />}
/>
<Route <Route
path="/signin" path="/signin"
element={ element={
<Navigate to="/" replace state={{ redirectTo: "/signin" }} /> <Navigate
to="/"
replace
state={{ redirectTo: "/signin" }}
/>
} }
/> />
<Route <Route
path="/signup" path="/signup"
element={ element={
<Navigate to="/" replace state={{ redirectTo: "/signup" }} /> <Navigate
to="/"
replace
state={{ redirectTo: "/signup" }}
/>
} }
/> />
<Route <Route
path="/recover" path="/recover"
element={ element={
<Navigate to="/" replace state={{ redirectTo: "/recover" }} /> <Navigate
to="/"
replace
state={{ redirectTo: "/recover" }}
/>
} }
/> />
<Route <Route
@ -209,7 +216,12 @@ export default function App() {
/> />
<Route <Route
path="/list" path="/list"
element={<LazyLoading children={<MyQuizzesFull />} fallback={<ListPageDummy/>} />} element={
<LazyLoading
children={<MyQuizzesFull />}
fallback={<ListPageDummy />}
/>
}
/> />
<Route <Route
path={"/view/:quizId"} path={"/view/:quizId"}
@ -231,7 +243,10 @@ export default function App() {
path={"/qaz"} path={"/qaz"}
element={<LazyLoading children={<InfoPrivilege />} />} element={<LazyLoading children={<InfoPrivilege />} />}
/> />
<Route path={"/image/:srcImage"} element={<ChatImageNewWindow />} /> <Route
path={"/image/:srcImage"}
element={<ChatImageNewWindow />}
/>
<Route element={<PrivateRoute />}> <Route element={<PrivateRoute />}>
{routeslink.map((e, i) => ( {routeslink.map((e, i) => (
<Route <Route