Skip to content

Fix: submit button popup #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/apiFetch/Submission.ts
Original file line number Diff line number Diff line change
@@ -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') => {
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 9 additions & 4 deletions src/app/sagas/Submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ export const getUserLatestCode = (state: RootState) => state.code.code;

export function* lockCode(action: ActionType<typeof SubmissionActions.lockCode>) {
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);
}
Expand Down