diff --git a/src/pages/ExamsPage/components/ExamSelection.jsx b/src/pages/ExamsPage/components/ExamSelection.jsx index ea8356a..425af72 100644 --- a/src/pages/ExamsPage/components/ExamSelection.jsx +++ b/src/pages/ExamsPage/components/ExamSelection.jsx @@ -5,12 +5,22 @@ import { } from '@edx/paragon'; import PropTypes from 'prop-types'; +// todo: implement substring search +// const searchByExamName = (exams, examName) => { +// const isMatchingExam = (exam) => exam === examName; +// const match = exams.filter(isMatchingExam); +// console.log('log'); +// }; + +const updateCurrentExamIndex = (exam) => 'hello'; + const ExamSelection = ({ exams }) => (
{exams.map(exam => ( - {exam.name} + // todo: update redux state + console.log(exam.id)}>{exam.name} ))}
diff --git a/src/pages/ExamsPage/data/reducer.js b/src/pages/ExamsPage/data/reducer.js index 01352b4..da3aa9e 100644 --- a/src/pages/ExamsPage/data/reducer.js +++ b/src/pages/ExamsPage/data/reducer.js @@ -31,12 +31,18 @@ const slice = createSlice({ } )), }), + // todo: setCurrentExam + loadCurrentExamIndex: (state, { payload }) => ({ + ...state, + currentExamIndex: 1, + }), }, }); export const { loadExams, loadExamAttempts, + loadCurrentExamIndex, } = slice.actions; export const { diff --git a/src/pages/ExamsPage/hooks.js b/src/pages/ExamsPage/hooks.js index 098989f..001ac5d 100644 --- a/src/pages/ExamsPage/hooks.js +++ b/src/pages/ExamsPage/hooks.js @@ -48,11 +48,13 @@ export const useInitializeExamsPage = (courseId) => { export const useExamsData = () => { const [exampleValue, setExampleValue] = state.exampleValue(0); const examsList = useSelector(selectors.courseExamsList); - const currentExam = useSelector(selectors.currentExam); + // todo: add setter here + const [currentExam, setCurrentExam] = useSelector(selectors.currentExam); const isLoading = reduxHooks.useRequestIsPending(RequestKeys.fetchCourseExams); return { currentExam, + setCurrentExam, examsList, isLoading, exampleValue,