From d720c8818b336155ff28de51d4fdc427be5e51e8 Mon Sep 17 00:00:00 2001 From: ilee2u Date: Thu, 25 Jan 2024 13:17:27 -0500 Subject: [PATCH] temp: experimenting with removing old code --- src/api.test.jsx | 1 + src/core/ExamStateProvider.jsx | 1 + src/data/index.js | 2 +- src/data/thunks.js | 8 ++++++-- src/index.jsx | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/api.test.jsx b/src/api.test.jsx index 1cabd935..15916c07 100644 --- a/src/api.test.jsx +++ b/src/api.test.jsx @@ -6,6 +6,7 @@ import { store } from './data'; describe('External API integration tests', () => { describe('Test isExam with exam', () => { beforeAll(() => { + console.log(getState()); jest.mock('./data'); const mockExam = Factory.build('exam', { attempt: Factory.build('attempt') }); const mockToken = Factory.build('examAccessToken'); diff --git a/src/core/ExamStateProvider.jsx b/src/core/ExamStateProvider.jsx index ced1d07c..f5b202a9 100644 --- a/src/core/ExamStateProvider.jsx +++ b/src/core/ExamStateProvider.jsx @@ -26,6 +26,7 @@ const StateProvider = ({ children, ...state }) => { const mapStateToProps = (state) => ({ ...state.examState }); +// TODO: FIGURE OUT WHAT THIS IS, AND HOW TO GET AROUND IT. const ExamStateProvider = withExamStore( StateProvider, mapStateToProps, diff --git a/src/data/index.js b/src/data/index.js index 9c6cb1a3..740c59db 100644 --- a/src/data/index.js +++ b/src/data/index.js @@ -17,5 +17,5 @@ export { examRequiresAccessToken, } from './thunks'; -export { default as store } from './store'; +// export { default as store } from './store'; export { default as Emitter } from './emitter'; diff --git a/src/data/thunks.js b/src/data/thunks.js index d1d06cf6..d9d8061a 100644 --- a/src/data/thunks.js +++ b/src/data/thunks.js @@ -50,7 +50,10 @@ const EXAM_START_TIMEOUT_MILLISECONDS = 5000; * @param noLoading - if set to false shows spinner while executing the function */ function updateAttemptAfter(courseId, sequenceId, promiseToBeResolvedFirst = null, noLoading = false) { - return async (dispatch) => { + return async (dispatch, getState) => { + // TODO: Figure out where the heck this getState is supposed to come from???? + // And also remove the getState from this thunk b/c it was not here originally... + const { exam } = getState().examState; if (!noLoading) { dispatch(setIsLoading({ isLoading: true })); } if (promiseToBeResolvedFirst) { try { @@ -66,6 +69,7 @@ function updateAttemptAfter(courseId, sequenceId, promiseToBeResolvedFirst = nul } try { const attemptData = await fetchExamAttemptsData(courseId, sequenceId); + console.log("EXAM:", exam); dispatch(setExamState({ exam: attemptData.exam, activeAttempt: !isEmpty(attemptData.active_attempt) ? attemptData.active_attempt : null, @@ -83,7 +87,7 @@ export function getExamAttemptsData(courseId, sequenceId) { } export function getLatestAttemptData(courseId) { - return async (dispatch) => { + return async (dispatch, getState) => { dispatch(setIsLoading({ isLoading: true })); try { const attemptData = await fetchLatestAttempt(courseId); diff --git a/src/index.jsx b/src/index.jsx index f87c5372..b4ae92b0 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -6,5 +6,5 @@ export { isExam, fetchExamAccess, } from './api'; -export { store } from './data'; +// export { store } from './data'; export { reducer } from './data/slice';