Skip to content

Commit

Permalink
feat: update redux state
Browse files Browse the repository at this point in the history
  • Loading branch information
varshamenon4 committed Jul 6, 2023
1 parent c7a672b commit 91101a6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/pages/ExamsPage/components/ExamSelection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check failure on line 15 in src/pages/ExamsPage/components/ExamSelection.jsx

View workflow job for this annotation

GitHub Actions / test (16)

'updateCurrentExamIndex' is assigned a value but never used

Check failure on line 15 in src/pages/ExamsPage/components/ExamSelection.jsx

View workflow job for this annotation

GitHub Actions / test (16)

'exam' is defined but never used

const ExamSelection = ({ exams }) => (
<div data-testid="exam_selection">
<SelectMenu defaultMessage="Select an exam...">
<MenuItem as={SearchField} />
{exams.map(exam => (
<MenuItem>{exam.name}</MenuItem>
// todo: update redux state
<MenuItem onClick={() => console.log(exam.id)}>{exam.name}</MenuItem>

Check warning on line 23 in src/pages/ExamsPage/components/ExamSelection.jsx

View workflow job for this annotation

GitHub Actions / test (16)

Unexpected console statement
))}
</SelectMenu>
</div>
Expand Down
6 changes: 6 additions & 0 deletions src/pages/ExamsPage/data/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ const slice = createSlice({
attemptsList: state.attemptsList.filter(attempt => attempt.attempt_id !== attemptId.payload),
})
,

Check failure on line 39 in src/pages/ExamsPage/data/reducer.js

View workflow job for this annotation

GitHub Actions / test (16)

Bad line breaking before and after ','
// todo: setCurrentExam
loadCurrentExamIndex: (state, { payload }) => ({

Check failure on line 41 in src/pages/ExamsPage/data/reducer.js

View workflow job for this annotation

GitHub Actions / test (16)

'payload' is defined but never used
...state,
currentExamIndex: 1,
}),
},
});

export const {
loadExams,
loadExamAttempts,
deleteExamAttempt,
loadCurrentExamIndex,
} = slice.actions;

export const {
Expand Down
4 changes: 3 additions & 1 deletion src/pages/ExamsPage/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,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,
Expand Down

0 comments on commit 91101a6

Please sign in to comment.