Skip to content

Commit

Permalink
YKI(Frontend): Reset exam session state on registration cancel
Browse files Browse the repository at this point in the history
This allows correctly navigating to different registration details
page. Previously the old exam session and new registration were in conflict.
  • Loading branch information
lket committed Nov 8, 2023
1 parent 8ca69ea commit 133053c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions frontend/packages/yki/src/redux/reducers/examSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const examSessionSlice = createSlice({
rejectExamSession(state) {
state.status = APIResponseStatus.Error;
},
resetExamSession() {
return initialState;
},
storeExamSession(state, action: PayloadAction<ExamSession>) {
state.status = APIResponseStatus.Success;
state.examSession = action.payload;
Expand All @@ -30,5 +33,9 @@ const examSessionSlice = createSlice({
});

export const examSessionReducer = examSessionSlice.reducer;
export const { loadExamSession, rejectExamSession, storeExamSession } =
examSessionSlice.actions;
export const {
loadExamSession,
rejectExamSession,
resetExamSession,
storeExamSession,
} = examSessionSlice.actions;
3 changes: 2 additions & 1 deletion frontend/packages/yki/src/redux/sagas/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
PublicRegistrationInitErrorResponse,
PublicRegistrationInitResponse,
} from 'interfaces/publicRegistration';
import { storeExamSession } from 'redux/reducers/examSession';
import { resetExamSession, storeExamSession } from 'redux/reducers/examSession';
import {
acceptCancelRegistration,
acceptPublicRegistrationInit,
Expand Down Expand Up @@ -111,6 +111,7 @@ function* cancelRegistrationSaga() {
);
yield put(acceptCancelRegistration());
yield put(resetPublicRegistration());
yield put(resetExamSession());
yield put(resetUserOpenRegistrations());
} catch (error) {
yield put(rejectCancelRegistration());
Expand Down

0 comments on commit 133053c

Please sign in to comment.