Skip to content

Commit

Permalink
VKT(Frontend): Update stored examiner details when upsert succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoivisto committed Nov 1, 2024
1 parent b113a88 commit 6d7a054
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { AxiosError } from 'axios';
import { AxiosError, AxiosResponse } from 'axios';
import { call, put, select, takeLatest } from 'redux-saga/effects';

import axiosInstance from 'configs/axios';
import { APIEndpoints } from 'enums/api';
import { ExaminerDetails } from 'interfaces/examinerDetails';
import { ExaminerDetailsUpsert } from 'interfaces/examinerDetailsUpsert';
import { setAPIError } from 'redux/reducers/APIError';
import { storeExaminerDetails } from 'redux/reducers/examinerDetails';
import {
acceptExaminerDetailsUpsert,
rejectExaminerDetailsUpsert,
Expand All @@ -19,12 +21,13 @@ function* startExaminerDetailsUpsertSaga() {
yield select(examinerDetailsUpsertSelector);

const { oid: _oid, id: _id, ...detailsToSubmit } = examinerDetails;
yield call(
const updatedExaminerResponse: AxiosResponse<ExaminerDetails> = yield call(
axiosInstance.post,
APIEndpoints.ExaminerDetails.replace(/:oid/, examinerDetails.oid),
detailsToSubmit,
);
yield put(acceptExaminerDetailsUpsert());
yield put(storeExaminerDetails(updatedExaminerResponse.data));
} catch (error) {
const errorMessage = NotifierUtils.getAPIErrorMessage(error as AxiosError);
yield put(setAPIError(errorMessage));
Expand Down

0 comments on commit 6d7a054

Please sign in to comment.