diff --git a/src/components/App/DefaultState.ts b/src/components/App/DefaultState.ts index 1290da98da..1294ddf45d 100644 --- a/src/components/App/DefaultState.ts +++ b/src/components/App/DefaultState.ts @@ -2,7 +2,6 @@ import { defaultState as goalTimelineState } from "components/GoalTimeline/Defau import { defaultState as loginState } from "components/Login/Redux/LoginReducer"; import { defaultState as currentProjectState } from "components/Project/ProjectReduxTypes"; import { defaultState as exportProjectState } from "components/ProjectExport/Redux/ExportProjectReduxTypes"; -import { defaultState as createProjectState } from "components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes"; import { defaultState as pronunciationsState } from "components/Pronunciations/Redux/PronunciationsReduxTypes"; import { defaultState as treeViewState } from "components/TreeView/Redux/TreeViewReduxTypes"; import { defaultState as characterInventoryState } from "goals/CharacterInventory/Redux/CharacterInventoryReducer"; @@ -15,10 +14,6 @@ export const defaultState = { loginState: { ...loginState }, //project - createProjectState: { - ...createProjectState, - success: true, - }, currentProjectState: { ...currentProjectState }, exportProjectState: { ...exportProjectState }, diff --git a/src/components/ProjectExport/Redux/ExportProjectActions.ts b/src/components/ProjectExport/Redux/ExportProjectActions.ts index cfea4ba26a..8bd8488ff1 100644 --- a/src/components/ProjectExport/Redux/ExportProjectActions.ts +++ b/src/components/ProjectExport/Redux/ExportProjectActions.ts @@ -1,10 +1,39 @@ +import { Action, PayloadAction } from "@reduxjs/toolkit"; + import { deleteLift, downloadLift, exportLift } from "backend"; import { - ExportProjectAction, - ExportStatus, -} from "components/ProjectExport/Redux/ExportProjectReduxTypes"; + downloadingAction, + exportingAction, + failureAction, + resetAction, + successAction, +} from "components/ProjectExport/Redux//ExportProjectReducer"; import { StoreStateDispatch } from "types/Redux/actions"; +// Action Creation Functions + +export function exporting(projectId: string): PayloadAction { + return exportingAction(projectId); +} + +export function downloading(projectId: string): PayloadAction { + return downloadingAction(projectId); +} + +export function failure(projectId: string): PayloadAction { + return failureAction(projectId); +} + +export function reset(): Action { + return resetAction(); +} + +export function success(projectId: string): PayloadAction { + return successAction(projectId); +} + +// Dispatch Functions + export function asyncExportProject(projectId: string) { return async (dispatch: StoreStateDispatch) => { dispatch(exporting(projectId)); @@ -27,31 +56,3 @@ export function asyncResetExport() { await deleteLift(); }; } - -function exporting(projectId: string): ExportProjectAction { - return { - type: ExportStatus.Exporting, - projectId, - }; -} -function downloading(projectId: string): ExportProjectAction { - return { - type: ExportStatus.Downloading, - projectId, - }; -} -export function success(projectId: string): ExportProjectAction { - return { - type: ExportStatus.Success, - projectId, - }; -} -export function failure(projectId: string): ExportProjectAction { - return { - type: ExportStatus.Failure, - projectId, - }; -} -function reset(): ExportProjectAction { - return { type: ExportStatus.Default }; -} diff --git a/src/components/ProjectExport/Redux/ExportProjectReducer.ts b/src/components/ProjectExport/Redux/ExportProjectReducer.ts index 6306fe529a..d830a50508 100644 --- a/src/components/ProjectExport/Redux/ExportProjectReducer.ts +++ b/src/components/ProjectExport/Redux/ExportProjectReducer.ts @@ -1,29 +1,43 @@ +import { createSlice } from "@reduxjs/toolkit"; + import { defaultState, - ExportProjectAction, - ExportProjectState, ExportStatus, } from "components/ProjectExport/Redux/ExportProjectReduxTypes"; -import { StoreAction, StoreActionTypes } from "rootActions"; +import { StoreActionTypes } from "rootActions"; + +const exportProjectSlice = createSlice({ + name: "exportProjectState", + initialState: defaultState, + reducers: { + downloadingAction: (state, action) => { + state.projectId = action.payload; + state.status = ExportStatus.Downloading; + }, + exportingAction: (state, action) => { + state.projectId = action.payload; + state.status = ExportStatus.Exporting; + }, + failureAction: (state, action) => { + state.projectId = action.payload; + state.status = ExportStatus.Failure; + }, + resetAction: () => defaultState, + successAction: (state, action) => { + state.projectId = action.payload; + state.status = ExportStatus.Success; + }, + }, + extraReducers: (builder) => + builder.addCase(StoreActionTypes.RESET, () => defaultState), +}); + +export const { + downloadingAction, + exportingAction, + failureAction, + resetAction, + successAction, +} = exportProjectSlice.actions; -export const exportProjectReducer = ( - state: ExportProjectState = defaultState, - action: StoreAction | ExportProjectAction -): ExportProjectState => { - switch (action.type) { - case ExportStatus.Exporting: - case ExportStatus.Downloading: - case ExportStatus.Success: - case ExportStatus.Failure: - return { - ...defaultState, - projectId: action.projectId ?? "", - status: action.type, - }; - case ExportStatus.Default: - case StoreActionTypes.RESET: - return defaultState; - default: - return state; - } -}; +export default exportProjectSlice.reducer; diff --git a/src/components/ProjectExport/Redux/ExportProjectReduxTypes.ts b/src/components/ProjectExport/Redux/ExportProjectReduxTypes.ts index 6b910ca38a..3725b60e9d 100644 --- a/src/components/ProjectExport/Redux/ExportProjectReduxTypes.ts +++ b/src/components/ProjectExport/Redux/ExportProjectReduxTypes.ts @@ -6,11 +6,6 @@ export enum ExportStatus { Failure = "FAILURE", } -export interface ExportProjectAction { - type: ExportStatus; - projectId?: string; -} - export interface ExportProjectState { projectId: string; status: ExportStatus; diff --git a/src/components/ProjectExport/Redux/tests/ExportProjectActions.test.tsx b/src/components/ProjectExport/Redux/tests/ExportProjectActions.test.tsx new file mode 100644 index 0000000000..5ff440a77a --- /dev/null +++ b/src/components/ProjectExport/Redux/tests/ExportProjectActions.test.tsx @@ -0,0 +1,85 @@ +import { PreloadedState } from "redux"; + +import { defaultState } from "components/App/DefaultState"; +import { + asyncDownloadExport, + asyncExportProject, + asyncResetExport, +} from "components/ProjectExport/Redux/ExportProjectActions"; +import { ExportStatus } from "components/ProjectExport/Redux/ExportProjectReduxTypes"; +import { RootState, setupStore } from "store"; + +jest.mock("backend", () => ({ + deleteLift: jest.fn, + downloadLift: (...args: any[]) => mockDownloadList(...args), + exportLift: (...args: any[]) => mockExportLift(...args), +})); + +const mockDownloadList = jest.fn(); +const mockExportLift = jest.fn(); +const mockProjId = "project-id"; + +// Preloaded values for store when testing +const persistedDefaultState: PreloadedState = { + ...defaultState, + _persist: { version: 1, rehydrated: false }, +}; + +describe("ExportProjectActions", () => { + describe("asyncDownloadExport", () => { + it("correctly affects state on success", async () => { + const store = setupStore(); + mockDownloadList.mockResolvedValueOnce({}); + await store.dispatch(asyncDownloadExport(mockProjId)); + const { projectId, status } = store.getState().exportProjectState; + expect(projectId).toEqual(mockProjId); + expect(status).toEqual(ExportStatus.Downloading); + }); + + it("correctly affects state on failure", async () => { + const store = setupStore(); + mockDownloadList.mockRejectedValueOnce({}); + await store.dispatch(asyncDownloadExport(mockProjId)); + const { projectId, status } = store.getState().exportProjectState; + expect(projectId).toEqual(mockProjId); + expect(status).toEqual(ExportStatus.Failure); + }); + }); + + describe("asyncExportProject", () => { + it("correctly affects state on success", async () => { + const store = setupStore(); + mockExportLift.mockResolvedValueOnce({}); + await store.dispatch(asyncExportProject(mockProjId)); + const { projectId, status } = store.getState().exportProjectState; + expect(projectId).toEqual(mockProjId); + expect(status).toEqual(ExportStatus.Exporting); + }); + + it("correctly affects state on failure", async () => { + const store = setupStore(); + mockExportLift.mockRejectedValueOnce({}); + await store.dispatch(asyncExportProject(mockProjId)); + const { projectId, status } = store.getState().exportProjectState; + expect(projectId).toEqual(mockProjId); + expect(status).toEqual(ExportStatus.Failure); + }); + }); + + describe("asyncResetExport", () => { + it("correctly affects state", async () => { + const nonDefaultState = { + projectId: "nonempty-string", + status: ExportStatus.Success, + }; + const store = setupStore({ + ...persistedDefaultState, + exportProjectState: nonDefaultState, + }); + await store.dispatch(asyncResetExport()); + const { projectId, status } = store.getState().exportProjectState; + expect(projectId).toEqual(""); + expect(status).toEqual(ExportStatus.Default); + }); + }); +}); diff --git a/src/components/ProjectScreen/CreateProject/index.tsx b/src/components/ProjectScreen/CreateProject.tsx similarity index 94% rename from src/components/ProjectScreen/CreateProject/index.tsx rename to src/components/ProjectScreen/CreateProject.tsx index 6e4ab1a57c..8174810bae 100644 --- a/src/components/ProjectScreen/CreateProject/index.tsx +++ b/src/components/ProjectScreen/CreateProject.tsx @@ -11,7 +11,7 @@ import { Typography, } from "@mui/material"; import { LanguagePicker, languagePickerStrings_en } from "mui-language-picker"; -import React, { Fragment, ReactElement, useEffect, useState } from "react"; +import React, { Fragment, ReactElement, useState } from "react"; import { Trans, useTranslation } from "react-i18next"; import { WritingSystem } from "api/models"; @@ -20,10 +20,8 @@ import { FileInputButton, LoadingDoneButton } from "components/Buttons"; import { asyncCreateProject, asyncFinishProject, - reset, -} from "components/ProjectScreen/CreateProject/Redux/CreateProjectActions"; -import { StoreState } from "types"; -import { useAppDispatch, useAppSelector } from "types/hooks"; +} from "components/ProjectScreen/CreateProjectActions"; +import { useAppDispatch } from "types/hooks"; import theme from "types/theme"; import { newWritingSystem } from "types/writingSystem"; @@ -41,18 +39,12 @@ const undBcp47 = "und"; export default function CreateProject(): ReactElement { const dispatch = useAppDispatch(); - const { inProgress, success } = useAppSelector( - (state: StoreState) => state.createProjectState - ); - - useEffect(() => { - dispatch(reset()); - }, [dispatch]); - const [analysisLang, setAnalysisLang] = useState(newWritingSystem(undBcp47)); const [error, setError] = useState({ empty: false, nameTaken: false }); const [languageData, setLanguageData] = useState(); + const [loading, setLoading] = useState(false); const [name, setName] = useState(""); + const [success, setSuccess] = useState(false); const [vernLang, setVernLang] = useState(newWritingSystem(undBcp47)); const [vernLangIsOther, setVernLangIsOther] = useState(false); const [vernLangOptions, setVernLangOptions] = useState([]); @@ -178,10 +170,16 @@ export default function CreateProject(): ReactElement { return; } + setLoading(true); + if (languageData) { - dispatch(asyncFinishProject(name, vernLang)); + await dispatch(asyncFinishProject(name, vernLang)).then(() => + setSuccess(true) + ); } else { - dispatch(asyncCreateProject(name, vernLang, [analysisLang])); + await dispatch(asyncCreateProject(name, vernLang, [analysisLang])).then( + () => setSuccess(true) + ); } }; @@ -297,7 +295,7 @@ export default function CreateProject(): ReactElement { disabled={!vernLang.bcp47 || vernLang.bcp47 === undBcp47} done={success} doneText={t("createProject.success")} - loading={inProgress} + loading={loading} > {t("createProject.create")} diff --git a/src/components/ProjectScreen/CreateProject/Redux/CreateProjectActions.ts b/src/components/ProjectScreen/CreateProject/Redux/CreateProjectActions.ts deleted file mode 100644 index d0a593086d..0000000000 --- a/src/components/ProjectScreen/CreateProject/Redux/CreateProjectActions.ts +++ /dev/null @@ -1,100 +0,0 @@ -import { WritingSystem } from "api/models"; -import { createProject, finishUploadLift, getProject } from "backend"; -import router from "browserRouter"; -import { asyncCreateUserEdits } from "components/GoalTimeline/Redux/GoalActions"; -import { setNewCurrentProject } from "components/Project/ProjectActions"; -import { - CreateProjectAction, - CreateProjectActionTypes, -} from "components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes"; -import { StoreStateDispatch } from "types/Redux/actions"; -import { Path } from "types/path"; -import { newProject } from "types/project"; - -/** thunk action creator for creating a project without an import. */ -export function asyncCreateProject( - name: string, - vernacularWritingSystem: WritingSystem, - analysisWritingSystems: WritingSystem[] -) { - return async (dispatch: StoreStateDispatch) => { - dispatch(inProgress()); - - const project = newProject(name); - project.vernacularWritingSystem = vernacularWritingSystem; - project.analysisWritingSystems = analysisWritingSystems; - - await createProject(project) - .then(async (createdProject) => { - dispatch(setNewCurrentProject(createdProject)); - dispatch(success()); - - // Manually pause so they have a chance to see the success message. - setTimeout(() => { - dispatch(asyncCreateUserEdits()); - router.navigate(Path.ProjSettings); - }, 1000); - }) - .catch((e) => { - dispatch(failure(e.response?.statusText)); - }); - }; -} - -/** thunk action creator for creating a project with a pre-uploaded import. */ -export function asyncFinishProject( - name: string, - vernacularWritingSystem: WritingSystem -) { - return async (dispatch: StoreStateDispatch) => { - dispatch(inProgress()); - - const project = newProject(name); - project.vernacularWritingSystem = vernacularWritingSystem; - - await createProject(project) - .then(async (createdProject) => { - await finishUploadLift(createdProject.id); - createdProject = await getProject(createdProject.id); - dispatch(setNewCurrentProject(createdProject)); - dispatch(success()); - - // Manually pause so they have a chance to see the success message. - setTimeout(() => { - dispatch(asyncCreateUserEdits()); - router.navigate(Path.ProjSettings); - }, 1000); - }) - .catch((e) => { - dispatch(failure(e.response?.statusText)); - }); - }; -} - -export function inProgress(): CreateProjectAction { - return { - type: CreateProjectActionTypes.CREATE_PROJECT_IN_PROGRESS, - payload: {}, - }; -} - -export function success(): CreateProjectAction { - return { - type: CreateProjectActionTypes.CREATE_PROJECT_SUCCESS, - payload: {}, - }; -} - -export function failure(errorMsg = ""): CreateProjectAction { - return { - type: CreateProjectActionTypes.CREATE_PROJECT_FAILURE, - payload: { errorMsg }, - }; -} - -export function reset(): CreateProjectAction { - return { - type: CreateProjectActionTypes.CREATE_PROJECT_RESET, - payload: {}, - }; -} diff --git a/src/components/ProjectScreen/CreateProject/Redux/CreateProjectReducer.ts b/src/components/ProjectScreen/CreateProject/Redux/CreateProjectReducer.ts deleted file mode 100644 index 31685a01d3..0000000000 --- a/src/components/ProjectScreen/CreateProject/Redux/CreateProjectReducer.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { - CreateProjectAction, - CreateProjectActionTypes, - CreateProjectState, - defaultState, -} from "components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes"; -import { StoreAction, StoreActionTypes } from "rootActions"; - -export const createProjectReducer = ( - state: CreateProjectState = defaultState, - action: CreateProjectAction | StoreAction -): CreateProjectState => { - switch (action.type) { - case CreateProjectActionTypes.CREATE_PROJECT_IN_PROGRESS: - return { ...defaultState, inProgress: true }; - case CreateProjectActionTypes.CREATE_PROJECT_SUCCESS: - return { ...defaultState, success: true }; - case CreateProjectActionTypes.CREATE_PROJECT_FAILURE: - return { ...defaultState, errorMsg: action.payload.errorMsg ?? "" }; - case CreateProjectActionTypes.CREATE_PROJECT_RESET: - return defaultState; - case StoreActionTypes.RESET: - return defaultState; - default: - return state; - } -}; diff --git a/src/components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes.ts b/src/components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes.ts deleted file mode 100644 index 39d2b6987a..0000000000 --- a/src/components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes.ts +++ /dev/null @@ -1,29 +0,0 @@ -export enum CreateProjectActionTypes { - CREATE_PROJECT_FAILURE = "CREATE_PROJECT_FAILURE", - CREATE_PROJECT_IN_PROGRESS = "CREATE_PROJECT_IN_PROGRESS", - CREATE_PROJECT_RESET = "CREATE_PROJECT_RESET", - CREATE_PROJECT_SUCCESS = "CREATE_PROJECT_SUCCESS", -} - -type CreateProjectType = - | typeof CreateProjectActionTypes.CREATE_PROJECT_FAILURE - | typeof CreateProjectActionTypes.CREATE_PROJECT_IN_PROGRESS - | typeof CreateProjectActionTypes.CREATE_PROJECT_RESET - | typeof CreateProjectActionTypes.CREATE_PROJECT_SUCCESS; - -export interface CreateProjectAction { - type: CreateProjectType; - payload: { errorMsg?: string }; -} - -export interface CreateProjectState { - inProgress: boolean; - success: boolean; - errorMsg: string; -} - -export const defaultState: CreateProjectState = { - success: false, - inProgress: false, - errorMsg: "", -}; diff --git a/src/components/ProjectScreen/CreateProject/tests/CreateProjectActions.test.tsx b/src/components/ProjectScreen/CreateProject/tests/CreateProjectActions.test.tsx deleted file mode 100644 index 0c5af9eb1b..0000000000 --- a/src/components/ProjectScreen/CreateProject/tests/CreateProjectActions.test.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import configureMockStore from "redux-mock-store"; -import thunk from "redux-thunk"; - -import * as action from "components/ProjectScreen/CreateProject/Redux/CreateProjectActions"; -import { defaultState } from "components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes"; -import { newWritingSystem } from "types/writingSystem"; - -jest.mock("backend", () => ({ - createProject: () => Promise.reject({ response: "intentional failure" }), -})); - -const mockStore = configureMockStore([thunk])(defaultState); - -const project = { - name: "testProjectName", - vernacularLanguage: newWritingSystem("testVernCode", "testVernName"), - analysisLanguages: [newWritingSystem("testAnalysisCode", "testAnalysisName")], -}; - -beforeEach(() => { - mockStore.clearActions(); -}); - -describe("CreateProjectActions", () => { - test("asyncCreateProject correctly affects state", async () => { - await mockStore.dispatch( - action.asyncCreateProject( - project.name, - project.vernacularLanguage, - project.analysisLanguages - ) - ); - expect(mockStore.getActions()).toEqual([ - action.inProgress(), - action.failure(), // backend.createProject mocked to fail - ]); - }); - - test("asyncFinishProject correctly affects state", async () => { - await mockStore.dispatch( - action.asyncFinishProject(project.name, project.vernacularLanguage) - ); - expect(mockStore.getActions()).toEqual([ - action.inProgress(), - action.failure(), // backend.createProject mocked to fail - ]); - }); -}); diff --git a/src/components/ProjectScreen/CreateProject/tests/CreateProjectReducer.test.tsx b/src/components/ProjectScreen/CreateProject/tests/CreateProjectReducer.test.tsx deleted file mode 100644 index 89b80daff9..0000000000 --- a/src/components/ProjectScreen/CreateProject/tests/CreateProjectReducer.test.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { - failure, - inProgress, - reset, - success, -} from "components/ProjectScreen/CreateProject/Redux/CreateProjectActions"; -import * as reducer from "components/ProjectScreen/CreateProject/Redux/CreateProjectReducer"; -import { - CreateProjectState, - defaultState, -} from "components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes"; -import { StoreAction, StoreActionTypes } from "rootActions"; - -describe("CreateProjectReducer", () => { - test("undefined state and reset action, expecting default state", () => { - expect(reducer.createProjectReducer(undefined, reset())).toEqual( - defaultState - ); - }); - - test("undefined state and failure action, expecting error message", () => { - const errorMsg = ""; - expect(reducer.createProjectReducer(undefined, failure(errorMsg))).toEqual({ - ...defaultState, - errorMsg, - }); - }); - - test("empty state and in-progress action, expecting inProgress", () => { - expect( - reducer.createProjectReducer({} as CreateProjectState, inProgress()) - ).toEqual({ ...defaultState, inProgress: true }); - }); - - test("empty state and success action, expecting success", () => { - expect( - reducer.createProjectReducer({} as CreateProjectState, success()) - ).toEqual({ ...defaultState, success: true }); - }); - - test("empty state and store reset action, expecting default state", () => { - const storeResetAction: StoreAction = { type: StoreActionTypes.RESET }; - expect( - reducer.createProjectReducer({} as CreateProjectState, storeResetAction) - ).toEqual(defaultState); - }); -}); diff --git a/src/components/ProjectScreen/CreateProjectActions.ts b/src/components/ProjectScreen/CreateProjectActions.ts new file mode 100644 index 0000000000..1c6a3c2e85 --- /dev/null +++ b/src/components/ProjectScreen/CreateProjectActions.ts @@ -0,0 +1,54 @@ +import { WritingSystem } from "api/models"; +import { createProject, finishUploadLift, getProject } from "backend"; +import router from "browserRouter"; +import { asyncCreateUserEdits } from "components/GoalTimeline/Redux/GoalActions"; +import { setNewCurrentProject } from "components/Project/ProjectActions"; +import { StoreStateDispatch } from "types/Redux/actions"; +import { Path } from "types/path"; +import { newProject } from "types/project"; + +// Dispatch Functions + +/*** Create a project without an import. */ +export function asyncCreateProject( + name: string, + vernacularWritingSystem: WritingSystem, + analysisWritingSystems: WritingSystem[] +) { + return async (dispatch: StoreStateDispatch) => { + const project = newProject(name); + project.vernacularWritingSystem = vernacularWritingSystem; + project.analysisWritingSystems = analysisWritingSystems; + + const createdProject = await createProject(project); + dispatch(setNewCurrentProject(createdProject)); + + // Manually pause so they have a chance to see the success message. + setTimeout(() => { + dispatch(asyncCreateUserEdits()); + router.navigate(Path.ProjSettings); + }, 1000); + }; +} + +/*** Create a project with a pre-uploaded import. */ +export function asyncFinishProject( + name: string, + vernacularWritingSystem: WritingSystem +) { + return async (dispatch: StoreStateDispatch) => { + const project = newProject(name); + project.vernacularWritingSystem = vernacularWritingSystem; + + const projId = (await createProject(project)).id; + await finishUploadLift(projId); + const createdProject = await getProject(projId); + dispatch(setNewCurrentProject(createdProject)); + + // Manually pause so they have a chance to see the success message. + setTimeout(() => { + dispatch(asyncCreateUserEdits()); + router.navigate(Path.ProjSettings); + }, 1000); + }; +} diff --git a/src/components/ProjectScreen/CreateProject/tests/CreateProjectComponent.test.tsx b/src/components/ProjectScreen/tests/CreateProject.test.tsx similarity index 95% rename from src/components/ProjectScreen/CreateProject/tests/CreateProjectComponent.test.tsx rename to src/components/ProjectScreen/tests/CreateProject.test.tsx index b39d3c42d2..f87d550a1b 100644 --- a/src/components/ProjectScreen/CreateProject/tests/CreateProjectComponent.test.tsx +++ b/src/components/ProjectScreen/tests/CreateProject.test.tsx @@ -17,7 +17,6 @@ import CreateProject, { formId, selectIdVern, } from "components/ProjectScreen/CreateProject"; -import { defaultState } from "components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes"; import { newWritingSystem } from "types/writingSystem"; jest.mock("backend", () => ({ @@ -29,10 +28,7 @@ const mockProjectDuplicateCheck = jest.fn(); const mockUploadLiftAndGetWritingSystems = jest.fn(); const createMockStore = configureMockStore(); -const mockState = { - currentProjectState: { project: {} }, - createProjectState: defaultState, -}; +const mockState = { currentProjectState: { project: {} } }; const mockStore = createMockStore(mockState); const mockChangeEvent = ( diff --git a/src/rootReducer.ts b/src/rootReducer.ts index dabea8c886..b0863ed7f0 100644 --- a/src/rootReducer.ts +++ b/src/rootReducer.ts @@ -3,8 +3,7 @@ import { combineReducers, Reducer } from "redux"; import goalsReducer from "components/GoalTimeline/Redux/GoalReducer"; import { loginReducer } from "components/Login/Redux/LoginReducer"; import { projectReducer } from "components/Project/ProjectReducer"; -import { exportProjectReducer } from "components/ProjectExport/Redux/ExportProjectReducer"; -import { createProjectReducer } from "components/ProjectScreen/CreateProject/Redux/CreateProjectReducer"; +import exportProjectReducer from "components/ProjectExport/Redux/ExportProjectReducer"; import { pronunciationsReducer } from "components/Pronunciations/Redux/PronunciationsReducer"; import { treeViewReducer } from "components/TreeView/Redux/TreeViewReducer"; import { characterInventoryReducer } from "goals/CharacterInventory/Redux/CharacterInventoryReducer"; @@ -18,7 +17,6 @@ export const rootReducer: Reducer = combineReducers({ loginState: loginReducer, //project - createProjectState: createProjectReducer, currentProjectState: projectReducer, exportProjectState: exportProjectReducer, diff --git a/src/types/index.ts b/src/types/index.ts index a82aa20a00..114069a2de 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,7 +1,6 @@ import { LoginState } from "components/Login/Redux/LoginReduxTypes"; import { CurrentProjectState } from "components/Project/ProjectReduxTypes"; import { ExportProjectState } from "components/ProjectExport/Redux/ExportProjectReduxTypes"; -import { CreateProjectState } from "components/ProjectScreen/CreateProject/Redux/CreateProjectReduxTypes"; import { PronunciationsState } from "components/Pronunciations/Redux/PronunciationsReduxTypes"; import { TreeViewState } from "components/TreeView/Redux/TreeViewReduxTypes"; import { CharacterInventoryState } from "goals/CharacterInventory/Redux/CharacterInventoryReduxTypes"; @@ -16,7 +15,6 @@ export interface StoreState { loginState: LoginState; //project - createProjectState: CreateProjectState; currentProjectState: CurrentProjectState; exportProjectState: ExportProjectState;