diff --git a/src/app/apiFetch/Submission.ts b/src/app/apiFetch/Submission.ts index 19906494..631d3544 100644 --- a/src/app/apiFetch/Submission.ts +++ b/src/app/apiFetch/Submission.ts @@ -1,5 +1,5 @@ /* tslint:disable:no-console*/ -import { jsonResponseWrapper, setRequestHeaders } from 'app/apiFetch/utils'; +import { setRequestHeaders, textResponseWrapper } from 'app/apiFetch/utils'; import { API_BASE_URL } from '../../config/config'; export const codeCompile = (commitHash = 'latest') => { @@ -107,7 +107,7 @@ export const lockCode = () => { headers: setRequestHeaders(), method: 'PUT', }) - .then((response) => jsonResponseWrapper(response)) + .then((response) => textResponseWrapper(response)) .then((data) => data) .catch((error) => { console.error(error); diff --git a/src/app/sagas/Submission.ts b/src/app/sagas/Submission.ts index 1a072ed8..51d6a904 100644 --- a/src/app/sagas/Submission.ts +++ b/src/app/sagas/Submission.ts @@ -12,10 +12,15 @@ export const getUserLatestCode = (state: RootState) => state.code.code; export function* lockCode(action: ActionType) { try { - yield call(SubmissionFetch.lockCode); - yield put(NotificationActions.success('Code Locked')); - yield put(SubmissionActions.toggleLockCode()); - yield put(GameLogActions.clearAllLogs()); + const res = yield call(SubmissionFetch.lockCode); + + if (res.status === 200) { + yield put(NotificationActions.info('Processing code submission')); + yield put(SubmissionActions.toggleLockCode()); + yield put(GameLogActions.clearAllLogs()); + } else { + yield put(NotificationActions.error('Code cannot be locked')); + } } catch (err) { console.error(err); }