diff --git a/src/backend/index.ts b/src/backend/index.ts index c2d425c921..923ae70725 100644 --- a/src/backend/index.ts +++ b/src/backend/index.ts @@ -26,8 +26,8 @@ import { Word, } from "api/models"; import * as LocalStorage from "backend/localStorage"; -import router from "browserRouter"; import authHeader from "components/Login/AuthHeaders"; +import router from "router/browserRouter"; import { Goal, GoalStep } from "types/goals"; import { Hash } from "types/hash"; import { Path } from "types/path"; diff --git a/src/components/App/component.tsx b/src/components/App/component.tsx index 0d4bee29f6..12c2152216 100644 --- a/src/components/App/component.tsx +++ b/src/components/App/component.tsx @@ -1,9 +1,9 @@ import { ReactElement, Suspense } from "react"; import { RouterProvider } from "react-router-dom"; -import router from "browserRouter"; import AnnouncementBanner from "components/AnnouncementBanner/AnnouncementBanner"; import UpperRightToastContainer from "components/Toast/UpperRightToastContainer"; +import router from "router/browserRouter"; /** * The top-level component diff --git a/src/components/GoalTimeline/tests/GoalRedux.test.tsx b/src/components/GoalTimeline/tests/GoalRedux.test.tsx index b53e3b0ef1..ef6ca59c35 100644 --- a/src/components/GoalTimeline/tests/GoalRedux.test.tsx +++ b/src/components/GoalTimeline/tests/GoalRedux.test.tsx @@ -44,11 +44,11 @@ jest.mock("backend", () => ({ getUserEditById: (...args: any[]) => mockGetUserEditById(...args), updateUser: (user: User) => mockUpdateUser(user), })); -jest.mock("browserRouter", () => ({ - navigate: (path: Path) => mockNavigate(path), -})); jest.mock("components/Project/ProjectActions", () => ({})); jest.mock("components/Pronunciations/Recorder"); +jest.mock("router/browserRouter", () => ({ + navigate: (path: Path) => mockNavigate(path), +})); const mockAddGoalToUserEdit = jest.fn(); const mockAddStepToGoal = jest.fn(); diff --git a/src/components/Login/Login.tsx b/src/components/Login/Login.tsx index fa00ca5907..5d67731b90 100644 --- a/src/components/Login/Login.tsx +++ b/src/components/Login/Login.tsx @@ -20,12 +20,12 @@ import { useTranslation } from "react-i18next"; import { BannerType } from "api/models"; import { getBannerText } from "backend"; -import router from "browserRouter"; import { LoadingButton } from "components/Buttons"; import Captcha from "components/Login/Captcha"; import { asyncLogIn } from "components/Login/Redux/LoginActions"; import { LoginStatus } from "components/Login/Redux/LoginReduxTypes"; import { reset } from "rootActions"; +import router from "router/browserRouter"; import { StoreState } from "types"; import { useAppDispatch, useAppSelector } from "types/hooks"; import { Path } from "types/path"; diff --git a/src/components/Login/Redux/LoginActions.ts b/src/components/Login/Redux/LoginActions.ts index 2d795b2c7d..31025ef8af 100644 --- a/src/components/Login/Redux/LoginActions.ts +++ b/src/components/Login/Redux/LoginActions.ts @@ -3,7 +3,6 @@ import Hex from "crypto-js/enc-hex"; import sha256 from "crypto-js/sha256"; import * as backend from "backend"; -import router from "browserRouter"; import { setLoginAttemptAction, setLoginFailureAction, @@ -12,6 +11,7 @@ import { setSignupFailureAction, setSignupSuccessAction, } from "components/Login/Redux/LoginReducer"; +import router from "router/browserRouter"; import { StoreStateDispatch } from "types/Redux/actions"; import { Path } from "types/path"; import { newUser } from "types/user"; diff --git a/src/components/Login/Signup.tsx b/src/components/Login/Signup.tsx index 3f20468023..f58535aaa3 100644 --- a/src/components/Login/Signup.tsx +++ b/src/components/Login/Signup.tsx @@ -16,12 +16,12 @@ import { } from "react"; import { useTranslation } from "react-i18next"; -import router from "browserRouter"; import { LoadingDoneButton } from "components/Buttons"; import Captcha from "components/Login/Captcha"; import { asyncSignUp } from "components/Login/Redux/LoginActions"; import { LoginStatus } from "components/Login/Redux/LoginReduxTypes"; import { reset } from "rootActions"; +import router from "router/browserRouter"; import { StoreState } from "types"; import { useAppDispatch, useAppSelector } from "types/hooks"; import { Path } from "types/path"; diff --git a/src/components/Login/tests/Login.test.tsx b/src/components/Login/tests/Login.test.tsx index 28f75cb3fd..c5752fe4aa 100644 --- a/src/components/Login/tests/Login.test.tsx +++ b/src/components/Login/tests/Login.test.tsx @@ -20,10 +20,10 @@ jest.mock( jest.mock("backend", () => ({ getBannerText: () => Promise.resolve(""), })); -jest.mock("browserRouter"); jest.mock("components/Login/Redux/LoginActions", () => ({ asyncLogIn: (...args: any[]) => mockAsyncLogIn(...args), })); +jest.mock("router/browserRouter"); jest.mock("types/hooks", () => { return { ...jest.requireActual("types/hooks"), diff --git a/src/components/Login/tests/Signup.test.tsx b/src/components/Login/tests/Signup.test.tsx index e37744b9f5..671caa9b80 100644 --- a/src/components/Login/tests/Signup.test.tsx +++ b/src/components/Login/tests/Signup.test.tsx @@ -21,10 +21,10 @@ jest.mock( jest.mock("backend", () => ({ getBannerText: () => Promise.resolve(""), })); -jest.mock("browserRouter"); jest.mock("components/Login/Redux/LoginActions", () => ({ asyncSignUp: (...args: any[]) => mockAsyncSignUp(...args), })); +jest.mock("router/browserRouter"); jest.mock("types/hooks", () => { return { ...jest.requireActual("types/hooks"), diff --git a/src/components/ProjectScreen/CreateProjectActions.ts b/src/components/ProjectScreen/CreateProjectActions.ts index 3ec4d323e9..d5dae4f6a9 100644 --- a/src/components/ProjectScreen/CreateProjectActions.ts +++ b/src/components/ProjectScreen/CreateProjectActions.ts @@ -1,8 +1,8 @@ import { type WritingSystem } from "api/models"; import { createProject, finishUploadLift, getProject } from "backend"; -import router from "browserRouter"; import { asyncSetNewCurrentProject } from "components/Project/ProjectActions"; import { asyncCreateUserEdits } from "goals/Redux/GoalActions"; +import router from "router/browserRouter"; import { type StoreStateDispatch } from "types/Redux/actions"; import { Path } from "types/path"; import { newProject } from "types/project"; diff --git a/src/goals/CharacterInventory/Redux/CharacterInventoryActions.ts b/src/goals/CharacterInventory/Redux/CharacterInventoryActions.ts index eeaa59e4f2..9b77784098 100644 --- a/src/goals/CharacterInventory/Redux/CharacterInventoryActions.ts +++ b/src/goals/CharacterInventory/Redux/CharacterInventoryActions.ts @@ -2,7 +2,6 @@ import { type Action, type PayloadAction } from "@reduxjs/toolkit"; import { type Project } from "api/models"; import { getFrontierWords, updateWord } from "backend"; -import router from "browserRouter"; import { asyncUpdateCurrentProject } from "components/Project/ProjectActions"; import { type CharInvChanges, @@ -30,6 +29,7 @@ import { addCharInvChangesToGoal, asyncUpdateGoal, } from "goals/Redux/GoalActions"; +import router from "router/browserRouter"; import { type StoreState } from "types"; import { type StoreStateDispatch } from "types/Redux/actions"; import { type Hash } from "types/hash"; diff --git a/src/goals/CharacterInventory/Redux/tests/CharacterInventoryActions.test.tsx b/src/goals/CharacterInventory/Redux/tests/CharacterInventoryActions.test.tsx index 9b2380a075..51f9090c91 100644 --- a/src/goals/CharacterInventory/Redux/tests/CharacterInventoryActions.test.tsx +++ b/src/goals/CharacterInventory/Redux/tests/CharacterInventoryActions.test.tsx @@ -30,7 +30,6 @@ jest.mock("backend", () => ({ getFrontierWords: (...args: any[]) => mockGetFrontierWords(...args), updateWord: (word: Word) => mockUpdateWord(word), })); -jest.mock("browserRouter"); jest.mock("components/Project/ProjectActions", () => ({ asyncUpdateCurrentProject: (...args: any[]) => mockAsyncUpdateCurrentProject(...args), @@ -40,6 +39,7 @@ jest.mock("goals/Redux/GoalActions", () => ({ addCharInvChangesToGoal: (changes: CharInvChanges) => mockAddCharInvChangesToGoal(changes), })); +jest.mock("router/browserRouter"); const mockAddCharInvChangesToGoal = jest.fn(); const mockAsyncUpdateCurrentProject = jest.fn(); diff --git a/src/goals/Redux/GoalActions.ts b/src/goals/Redux/GoalActions.ts index 58bbaa58c0..fa5705bc92 100644 --- a/src/goals/Redux/GoalActions.ts +++ b/src/goals/Redux/GoalActions.ts @@ -4,7 +4,6 @@ import { MergeUndoIds, Word } from "api/models"; import * as Backend from "backend"; import { getDuplicates, getGraylistEntries } from "backend"; import { getCurrentUser, getProjectId } from "backend/localStorage"; -import router from "browserRouter"; import { CharInvChanges } from "goals/CharacterInventory/CharacterInventoryTypes"; import { dispatchMergeStepData } from "goals/MergeDuplicates/Redux/MergeDupsActions"; import { @@ -19,6 +18,7 @@ import { updateStepFromDataAction, } from "goals/Redux/GoalReducer"; import { EntryEdit } from "goals/ReviewEntries/ReviewEntriesTypes"; +import router from "router/browserRouter"; import { StoreState } from "types"; import { StoreStateDispatch } from "types/Redux/actions"; import { Goal, GoalStatus, GoalType } from "types/goals"; diff --git a/src/types/appRoutes.tsx b/src/router/appRoutes.tsx similarity index 100% rename from src/types/appRoutes.tsx rename to src/router/appRoutes.tsx diff --git a/src/browserRouter.tsx b/src/router/browserRouter.tsx similarity index 95% rename from src/browserRouter.tsx rename to src/router/browserRouter.tsx index caf458626e..bda27d67e6 100644 --- a/src/browserRouter.tsx +++ b/src/router/browserRouter.tsx @@ -1,8 +1,8 @@ import { createBrowserRouter } from "react-router-dom"; +import { appRoutes } from "router/appRoutes"; import { store } from "store"; import { changePage } from "types/Redux/analytics"; -import { appRoutes } from "types/appRoutes"; import { Path } from "types/path"; const router = createBrowserRouter(appRoutes);