Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate router components #2975

Merged
merged 10 commits into from
Apr 3, 2024
2 changes: 1 addition & 1 deletion src/backend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/components/App/component.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/components/GoalTimeline/tests/GoalRedux.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/Redux/LoginActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/tests/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login/tests/Signup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProjectScreen/CreateProjectActions.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/goals/Redux/GoalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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";
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/browserRouter.tsx → src/router/browserRouter.tsx
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
Loading