Skip to content

Commit 1ef639a

Browse files
committed
fix minors and info panel
1 parent 2b594a4 commit 1ef639a

File tree

3 files changed

+54
-41
lines changed

3 files changed

+54
-41
lines changed

services/app/apps/codebattle/assets/js/widgets/pages/tournament/CustomTournamentInfoPanel.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {
2-
memo, useState, useCallback, useRef,
2+
memo, useState, useEffect, useCallback, useRef,
33
} from 'react';
44

55
import { useSelector } from 'react-redux';
@@ -48,6 +48,16 @@ function CustomTournamentInfoPanel({
4848
: { panel: PanelModeCodes.ratingMode },
4949
);
5050

51+
useEffect(() => {
52+
if (players[currentUserId]) {
53+
setPanelMode({
54+
panel: PanelModeCodes.playerMode,
55+
});
56+
}
57+
58+
// eslint-disable-next-line react-hooks/exhaustive-deps
59+
}, players[currentUserId]?.id);
60+
5161
const allPlayers = useSelector(tournamentPlayersSelector);
5262

5363
const handleUserSelectClick = useCallback(
@@ -136,7 +146,7 @@ function CustomTournamentInfoPanel({
136146
pageNumber={pageNumber}
137147
pageSize={pageSize}
138148
hideBots={hideBots}
139-
hideResults={hideResults && !canModerate}
149+
hideResults={(hideResults && !canModerate) || (!players[currentUserId] && !canModerate)}
140150
/>
141151
)}
142152
{panelMode.panel === PanelModeCodes.topUserByClansMode && (

services/app/apps/codebattle/assets/js/widgets/pages/tournament/RatingPanel.jsx

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import range from 'lodash/range';
1010
import reverse from 'lodash/reverse';
1111
import { useDispatch } from 'react-redux';
1212

13+
import i18n from '../../../i18n';
1314
import mapStagesToTitle from '../../config/mapStagesToTitle';
1415
import { uploadPlayersMatches } from '../../middlewares/Tournament';
1516
import { actions } from '../../slices';
@@ -26,15 +27,15 @@ const navPlayerTabsClassName = cn(
2627
);
2728

2829
const tabLinkClassName = (active, isCurrent = false) => cn(
29-
'nav-item nav-link text-uppercase text-nowrap rounded-0 font-weight-bold p-3 border-0 w-100', {
30-
active,
31-
'text-primary': isCurrent,
32-
},
33-
);
30+
'nav-item nav-link text-uppercase text-nowrap rounded-0 font-weight-bold p-3 border-0 w-100', {
31+
active,
32+
'text-primary': isCurrent,
33+
},
34+
);
3435

3536
const tabContentClassName = active => cn('tab-pane fade', {
36-
'd-flex flex-column show active': active,
37-
});
37+
'd-flex flex-column show active': active,
38+
});
3839

3940
const PlayersList = memo(
4041
({
@@ -44,27 +45,27 @@ const PlayersList = memo(
4445
searchedUserId,
4546
hideBots,
4647
}) => players.map(player => {
47-
if (player.id === searchedUserId) {
48-
return <></>;
49-
}
48+
if (player.id === searchedUserId) {
49+
return <></>;
50+
}
5051

51-
const userMatches = matchList.filter(match => match.playerIds.includes(player.id));
52+
const userMatches = matchList.filter(match => match.playerIds.includes(player.id));
5253

53-
return (
54-
<TournamentUserPanel
55-
key={`user-panel-${player.id}`}
56-
matches={userMatches}
57-
currentUserId={currentUserId}
58-
userId={player.id}
59-
name={player.name}
60-
score={player.score}
61-
place={player.place}
62-
isBanned={player.isBanned}
63-
searchedUserId={searchedUserId}
64-
hideBots={hideBots}
65-
/>
66-
);
67-
}),
54+
return (
55+
<TournamentUserPanel
56+
key={`user-panel-${player.id}`}
57+
matches={userMatches}
58+
currentUserId={currentUserId}
59+
userId={player.id}
60+
name={player.name}
61+
score={player.score}
62+
place={player.place}
63+
isBanned={player.isBanned}
64+
searchedUserId={searchedUserId}
65+
hideBots={hideBots}
66+
/>
67+
);
68+
}),
6869
);
6970

7071
const SearchedUserPanel = memo(({
@@ -111,20 +112,20 @@ function RatingPanel({
111112

112113
const playersList = useMemo(
113114
() => Object.values(players)
114-
.sort((a, b) => b.score - a.score)
115-
.slice(0 + pageSize * (pageNumber - 1), pageSize * pageNumber)
116-
.reduce((acc, player) => {
117-
if (player.isBot && hideBots) {
118-
return acc;
119-
}
115+
.sort((a, b) => b.score - a.score)
116+
.slice(0 + pageSize * (pageNumber - 1), pageSize * pageNumber)
117+
.reduce((acc, player) => {
118+
if (player.isBot && hideBots) {
119+
return acc;
120+
}
120121

121-
if (player.id === currentUserId) {
122-
return [player, ...acc];
123-
}
122+
if (player.id === currentUserId) {
123+
return [player, ...acc];
124+
}
124125

125-
acc.push(player);
126-
return acc;
127-
}, []),
126+
acc.push(player);
127+
return acc;
128+
}, []),
128129
[players, currentUserId, pageSize, pageNumber, hideBots],
129130
);
130131
const topPlayersList = useMemo(
@@ -178,7 +179,7 @@ function RatingPanel({
178179
'text-uppercase font-weight-bold pt-2',
179180
)}
180181
>
181-
Wait reviling results
182+
{i18n.t('Wait reviling results')}
182183
</div>
183184
);
184185
}

services/app/apps/codebattle/priv/gettext/ru/LC_MESSAGES/default.po

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,3 +1022,5 @@ msgstr "Рейтинг"
10221022
msgid "Sended"
10231023
msgstr "Отправлено"
10241024

1025+
msgid "Wait reviling results"
1026+
msgstr "Ожидайте результатов соревнования"

0 commit comments

Comments
 (0)