Skip to content

Commit 3ecaa63

Browse files
committed
Fix tournaments
1 parent fb5ff2b commit 3ecaa63

File tree

23 files changed

+969
-420
lines changed

23 files changed

+969
-420
lines changed

services/app/apps/codebattle/assets/js/widgets/pages/game/EditorToolbar.jsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ const EditorToolbar = ({
4242
actionBtnsProps,
4343
showControlBtns,
4444
isAdmin = false,
45-
isPremium = false,
4645
isHistory = false,
4746
}) => (
4847
<>
49-
<div ref={toolbarRef} className="cb-bg-panel cb-border-color rounded-top" data-player-type={type}>
48+
<div
49+
ref={toolbarRef}
50+
className="cb-bg-panel cb-border-color rounded-top"
51+
data-player-type={type}
52+
>
5053
<div className={toolbarClassNames} role="toolbar">
5154
<div className="d-flex justify-content-between">
5255
<div
@@ -68,15 +71,27 @@ const EditorToolbar = ({
6871
role="group"
6972
aria-label="Report actions"
7073
>
71-
{(isAdmin || isPremium) && !showControlBtns && <GameReportButton userId={player.id} gameId={gameId} />}
72-
{isAdmin && !showControlBtns && <GameBanPlayerButton userId={player.id} status={status} tournamentId={tournamentId} />}
74+
{!showControlBtns && (
75+
<GameReportButton userId={player.id} gameId={gameId} />
76+
)}
77+
{isAdmin && !showControlBtns && (
78+
<GameBanPlayerButton
79+
userId={player.id}
80+
status={status}
81+
tournamentId={tournamentId}
82+
/>
83+
)}
7384
</div>
7485
<div
7586
className={userInfoClassNames}
7687
role="group"
7788
aria-label="User info"
7889
>
79-
<UserInfo mode="dark" user={player} placement={Placements.bottomEnd} />
90+
<UserInfo
91+
mode="dark"
92+
user={player}
93+
placement={Placements.bottomEnd}
94+
/>
8095
{mode === GameRoomModes.standard && (
8196
<UserGameScore userId={player.id} />
8297
)}

services/app/apps/codebattle/assets/js/widgets/pages/game/GameReportButton.jsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import cn from 'classnames';
44
import { useDispatch, useSelector } from 'react-redux';
55

66
import { reportOnPlayer } from '@/middlewares/Main';
7-
import { userIsAdminSelector, userIsGamePlayerSelector } from '@/selectors';
7+
import {
8+
currentUserIsAdminSelector,
9+
userIsGamePlayerSelector,
10+
} from '@/selectors';
811

912
import i18n from '../../../i18n';
1013

@@ -18,18 +21,22 @@ const states = {
1821
const getText = state => {
1922
switch (state) {
2023
case states.loading:
21-
case states.idle: return i18n.t('Report');
22-
case states.success: return i18n.t('Sended');
23-
case states.error: return i18n.t('Error');
24-
default: return i18n.t('Report');
24+
case states.idle:
25+
return i18n.t('Report');
26+
case states.success:
27+
return i18n.t('Sended');
28+
case states.error:
29+
return i18n.t('Error');
30+
default:
31+
return i18n.t('Report');
2532
}
2633
};
2734

2835
const GameReportButton = ({ userId, gameId }) => {
2936
const dispatch = useDispatch();
3037
const [state, setState] = useState(states.idle);
3138

32-
const isAdmin = useSelector(userIsAdminSelector);
39+
const isAdmin = useSelector(currentUserIsAdminSelector);
3340
const isPlayer = useSelector(userIsGamePlayerSelector);
3441

3542
const onSuccess = () => setState(states.success);

services/app/apps/codebattle/assets/js/widgets/pages/lobby/SeasonProfilePanel.jsx

Lines changed: 125 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import axios from 'axios';
44
import { camelizeKeys } from 'humps';
55
import { useSelector } from 'react-redux';
66

7-
import { selectDefaultAvatarUrl } from '@/selectors';
7+
import {
8+
selectDefaultAvatarUrl,
9+
currentUserIsAdminSelector,
10+
} from '@/selectors';
811

912
import i18n from '../../../i18n';
1013

@@ -51,136 +54,142 @@ const SeasonProfilePanel = ({
5154
liveTournaments = [],
5255
user,
5356
controls,
54-
}) => (
55-
<div className="d-flex flex-column-reverse flex-lg-row flex-md-row my-0 my-lg-2 my-md-2">
56-
<div className="col-12 col-lg-8 col-md-8 my-2 my-lg-0 my-md-0">
57-
<div className="cb-bg-panel cb-rounded d-flex flex-column p-3 h-100 w-100 text-center">
58-
<h2 className="text-white">Codebattle Season Competition</h2>
59-
<p className="m-auto pb-3 px-4 text-white">
60-
Challenge the best! Participate in the Competition tournaments
61-
{', '}
62-
defeat your rivals to earn points
63-
{', '}
64-
and claim the first place in the programmer ranking.
65-
</p>
66-
{seasonTournaments?.length || liveTournaments?.length ? (
67-
<div className="cb-bg-highlight-panel">
68-
{liveTournaments?.length !== 0 && (
69-
<>
70-
<div className="d-flex justify-content-center align-items-center pt-2 cb-bg-panel">
71-
<span className="text-white text-uppercase h4">
72-
Live Tournaments
73-
</span>
74-
</div>
75-
{liveTournaments.map(tournament => (
76-
<TournamentListItem
77-
key={tournament.id}
78-
tournament={tournament}
79-
icon={activeIcon}
80-
/>
81-
))}
82-
</>
83-
)}
84-
{seasonTournaments?.length !== 0 && (
85-
<>
86-
<div className="d-flex justify-content-center pt-2 cb-bg-panel">
87-
<span className="text-white text-uppercase h4">
88-
Upcoming Tournaments
89-
</span>
90-
</div>
91-
<div
92-
className="d-flex flex-column cb-overflow-y-scroll position-relative"
93-
style={{ maxHeight: '280px' }}
94-
>
95-
{seasonTournaments.map(tournament => (
57+
}) => {
58+
const isAdmin = useSelector(currentUserIsAdminSelector);
59+
60+
return (
61+
<div className="d-flex flex-column-reverse flex-lg-row flex-md-row my-0 my-lg-2 my-md-2">
62+
<div className="col-12 col-lg-8 col-md-8 my-2 my-lg-0 my-md-0">
63+
<div className="cb-bg-panel cb-rounded d-flex flex-column p-3 h-100 w-100 text-center">
64+
<h2 className="text-white">Codebattle Season Competition</h2>
65+
<p className="m-auto pb-3 px-4 text-white">
66+
Challenge the best! Participate in the Competition tournaments
67+
{', '}
68+
defeat your rivals to earn points
69+
{', '}
70+
and claim the first place in the programmer ranking.
71+
</p>
72+
{seasonTournaments?.length || liveTournaments?.length ? (
73+
<div className="cb-bg-highlight-panel">
74+
{liveTournaments?.length !== 0 && (
75+
<>
76+
<div className="d-flex justify-content-center align-items-center pt-2 cb-bg-panel">
77+
<span className="text-white text-uppercase h4">
78+
Live Tournaments
79+
</span>
80+
</div>
81+
{liveTournaments.map(tournament => (
9682
<TournamentListItem
83+
isAdmin={isAdmin}
9784
key={tournament.id}
9885
tournament={tournament}
86+
icon={activeIcon}
9987
/>
10088
))}
101-
</div>
102-
</>
103-
)}
89+
</>
90+
)}
91+
{seasonTournaments?.length !== 0 && (
92+
<>
93+
<div className="d-flex justify-content-center pt-2 cb-bg-panel">
94+
<span className="text-white text-uppercase h4">
95+
Upcoming Tournaments
96+
</span>
97+
</div>
98+
<div
99+
className="d-flex flex-column cb-overflow-y-scroll position-relative"
100+
style={{ maxHeight: '280px' }}
101+
>
102+
{seasonTournaments.map(tournament => (
103+
<TournamentListItem
104+
isAdmin={isAdmin}
105+
key={tournament.id}
106+
tournament={tournament}
107+
/>
108+
))}
109+
</div>
110+
</>
111+
)}
112+
</div>
113+
) : (
114+
<div className="pt-2 mt-2">Competition not started yet</div>
115+
)}
116+
<div className="d-flex flex-column flex-lg-row flex-md-row w-100 pt-2 mt-2">
117+
<a
118+
href="/schedule#contest"
119+
type="button"
120+
className="btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
121+
>
122+
{i18n.t('Contests History')}
123+
</a>
124+
<a
125+
href="/schedule#my"
126+
type="button"
127+
className="btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
128+
>
129+
{i18n.t('My Tournaments')}
130+
</a>
131+
<a
132+
href="/tournaments"
133+
type="button"
134+
className="btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
135+
>
136+
{i18n.t('Create a Tournament')}
137+
</a>
104138
</div>
105-
) : (
106-
<div className="pt-2 mt-2">Competition not started yet</div>
107-
)}
108-
<div className="d-flex flex-column flex-lg-row flex-md-row w-100 pt-2 mt-2">
109-
<a
110-
href="/schedule#contest"
111-
type="button"
112-
className="btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
113-
>
114-
{i18n.t('Contests History')}
115-
</a>
116-
<a
117-
href="/schedule#my"
118-
type="button"
119-
className="btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
120-
>
121-
{i18n.t('My Tournaments')}
122-
</a>
123-
<a
124-
href="/tournaments"
125-
type="button"
126-
className="btn btn-secondary cb-btn-secondary mx-0 mx-md-2 mx-lg-2 w-100 cb-rounded text-nowrap"
127-
>
128-
{i18n.t('Create a Tournament')}
129-
</a>
130139
</div>
131140
</div>
132-
</div>
133-
<div className="col-12 col-lg-4 col-md-4 d-flex flex-column my-2 my-lg-0 my-md-0">
134-
<div className="cb-bg-panel cb-rounded">
135-
<div className="text-center p-2 py-3">
136-
<UserLogo user={user} />
137-
<span className="clan-tag mt-2">{user.name}</span>
138-
<span className="h1 clan-title m-0 text-white text-uppercase">
139-
Clan
140-
{': '}
141-
{user.clanId ? (
142-
user.clan
143-
) : (
144-
<a href="/settings" className="text-lowercase text-primary">
145-
<small>add clan</small>
146-
</a>
147-
)}
148-
</span>
149-
</div>
150-
151-
<div className="cb-bg-highlight-panel d-flex py-2 px-1">
152-
<div className="stat-item py-1 w-100">
153-
<span className="stat-value d-block cb-text-danger">
154-
{user.rating}
141+
<div className="col-12 col-lg-4 col-md-4 d-flex flex-column my-2 my-lg-0 my-md-0">
142+
<div className="cb-bg-panel cb-rounded">
143+
<div className="text-center p-2 py-3">
144+
<UserLogo user={user} />
145+
<span className="clan-tag mt-2">{user.name}</span>
146+
<span className="h1 clan-title m-0 text-white text-uppercase">
147+
Clan
148+
{': '}
149+
{user.clanId ? (
150+
user.clan
151+
) : (
152+
<a href="/settings" className="text-lowercase text-primary">
153+
<small>add clan</small>
154+
</a>
155+
)}
155156
</span>
156-
<span className="stat-label text-uppercase">(Elo Rating)</span>
157157
</div>
158-
<div className="stat-item py-1 w-100">
159-
{user.points ? (
160-
<span className="stat-value d-block cb-text-success">
161-
#
162-
{user.rank}
158+
159+
<div className="cb-bg-highlight-panel d-flex py-2 px-1">
160+
<div className="stat-item py-1 w-100">
161+
<span className="stat-value d-block cb-text-danger">
162+
{user.rating}
163163
</span>
164-
) : (
165-
<span className="stat-value d-block cb-text-danger">#0</span>
166-
)}
167-
<span className="stat-label text-uppercase">Place</span>
168-
</div>
169-
<div className="stat-item py-1 w-100">
170-
<span className="stat-value d-block cb-text-danger">
171-
{user.points || 0}
172-
</span>
173-
<span className="stat-label text-uppercase">Points</span>
164+
<span className="stat-label text-uppercase">(Elo Rating)</span>
165+
</div>
166+
<div className="stat-item py-1 w-100">
167+
{user.points ? (
168+
<span className="stat-value d-block cb-text-success">
169+
#
170+
{user.rank}
171+
</span>
172+
) : (
173+
<span className="stat-value d-block cb-text-danger">#0</span>
174+
)}
175+
<span className="stat-label text-uppercase">Place</span>
176+
</div>
177+
<div className="stat-item py-1 w-100">
178+
<span className="stat-value d-block cb-text-danger">
179+
{user.points || 0}
180+
</span>
181+
<span className="stat-label text-uppercase">Points</span>
182+
</div>
174183
</div>
175-
</div>
176184

177-
<div className="d-flex justify-content-center cb-font-size-small py-2 px-3 text-white">
178-
<span className="d-block">{contestDatesText}</span>
185+
<div className="d-flex justify-content-center cb-font-size-small py-2 px-3 text-white">
186+
<span className="d-block">{contestDatesText}</span>
187+
</div>
179188
</div>
189+
{controls}
180190
</div>
181-
{controls}
182191
</div>
183-
</div>
184-
);
192+
);
193+
};
185194

186195
export default SeasonProfilePanel;

0 commit comments

Comments
 (0)