Skip to content

Commit

Permalink
add reaction on validation pass code
Browse files Browse the repository at this point in the history
  • Loading branch information
ReDBrother committed Jan 28, 2024
1 parent bf963d2 commit 53afa81
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ export const sendEditorCursorSelection = (startOffset, endOffset) => {
});
};

export const sendPassCode = (passCode, onError) => () => {
export const sendPassCode = (passCode, onError) => dispatch => {
channel.push('enter_pass_code', { pass_code: passCode })
.receive('ok', () => {})
.receive('error', message => {
onError({ message });
.receive('ok', () => {
dispatch(actions.setLocked(false));
})
.receive('error', error => {
onError({ message: error.reason });
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Loading from '@/components/Loading';

import gifs from '../../config/gifs';
import ModalCodes from '../../config/modalCodes';
import { gamePlayersSelector, currentUserIdSelector } from '../../selectors';
import { gamePlayersSelector, currentUserIdSelector, gameAwardSelector } from '../../selectors';

function TournamentInfoPanel() {
const waitType = useSelector(state => state.game.waitType);
Expand All @@ -30,6 +30,7 @@ function TournamentInfoPanel() {
const AnimationModal = NiceModal.create(() => {
const modal = useModal(ModalCodes.gameResultModal);

const award = useSelector(gameAwardSelector);
const players = useSelector(state => gamePlayersSelector(state));
const currentUserId = useSelector(state => currentUserIdSelector(state));
const tournamentId = useSelector(state => state.game.gameStatus.tournamentId);
Expand Down Expand Up @@ -61,12 +62,16 @@ const AnimationModal = NiceModal.create(() => {
</Modal.Header>
<Modal.Body>
<div className="d-flex justify-content-center">
<img
className="w-100 rounded-lg"
style={{ maxWidth: '400px', height: '300px' }}
src={gifs[result]}
alt="animation"
/>
{award ? (
<>{award}</>
) : (
<img
className="w-100 rounded-lg"
style={{ maxWidth: '400px', height: '300px' }}
src={gifs[result]}
alt="animation"
/>
)}
</div>
{tournamentId && (
<div className="d-flex text-center justify-content-center">
Expand Down
3 changes: 3 additions & 0 deletions services/app/apps/codebattle/assets/js/widgets/slices/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const game = createSlice({
addAlert: (state, { payload }) => {
state.alerts = { ...state.alerts, ...payload };
},
setLocked: (state, { payload }) => {
state.locked = payload;
},
},
});

Expand Down

0 comments on commit 53afa81

Please sign in to comment.