Merge pull request 'Изменить отображение текущей игры во вкладке группы (#2)' (#19) from issue-2-group-current-match into dev

Reviewed-on: #19
This commit was merged in pull request #19.
This commit is contained in:
2026-09-07 19:03:24 +03:00
2 changed files with 24 additions and 3 deletions
+11 -2
View File
@@ -4,7 +4,16 @@ import { useNavigate } from "react-router-dom";
import { formatTime, plural } from "../domain/format"; import { formatTime, plural } from "../domain/format";
import type { HomeInProgressMatch } from "../domain/types"; import type { HomeInProgressMatch } from "../domain/types";
export function InProgressMatches({ items }: { items: HomeInProgressMatch[] }) { /** Блок незавершённых партий. На главной партии приходят из разных групп, поэтому
* название группы нужно; на странице самой группы оно дублирует заголовок — там
* блок вызывается с showGroupName={false}. */
export function InProgressMatches({
items,
showGroupName = true,
}: {
items: HomeInProgressMatch[];
showGroupName?: boolean;
}) {
const navigate = useNavigate(); const navigate = useNavigate();
if (items.length === 0) return null; if (items.length === 0) return null;
@@ -21,7 +30,7 @@ export function InProgressMatches({ items }: { items: HomeInProgressMatch[] }) {
> >
<div style={{ minWidth: 0 }}> <div style={{ minWidth: 0 }}>
<div className="row" style={{ gap: 8 }}> <div className="row" style={{ gap: 8 }}>
<b>{m.group_name}</b> {showGroupName && <b>{m.group_name}</b>}
<span className="badge badge-live">идёт</span> <span className="badge badge-live">идёт</span>
</div> </div>
<div className="muted small"> <div className="muted small">
+13 -1
View File
@@ -6,6 +6,7 @@ import { ApiError } from "../api/client";
import { CreateGroupForm } from "../components/CreateGroupForm"; import { CreateGroupForm } from "../components/CreateGroupForm";
import { GroupInvitations } from "../components/GroupInvitations"; import { GroupInvitations } from "../components/GroupInvitations";
import { GroupSwitcher } from "../components/GroupSwitcher"; import { GroupSwitcher } from "../components/GroupSwitcher";
import { InProgressMatches } from "../components/InProgressMatches";
import { Leaderboard } from "../components/Leaderboard"; import { Leaderboard } from "../components/Leaderboard";
import { MatchListView } from "../components/MatchList"; import { MatchListView } from "../components/MatchList";
import { PlayerSuggestions } from "../components/PlayerSuggestions"; import { PlayerSuggestions } from "../components/PlayerSuggestions";
@@ -83,6 +84,14 @@ export function GroupPage() {
); );
} }
// Идущие партии выносим тем же блоком, что и на главной; из списка «Партии»
// их исключаем, иначе одна партия показалась бы на странице дважды.
const allMatches = matches?.items ?? [];
const inProgress = allMatches
.filter((m) => m.status === "in_progress")
.map((m) => ({ ...m, group_id: groupId, group_name: group?.name ?? "" }));
const finishedMatches = allMatches.filter((m) => m.status !== "in_progress");
return ( return (
<div> <div>
<div className="card"> <div className="card">
@@ -152,8 +161,11 @@ export function GroupPage() {
<GroupSwitcher /> <GroupSwitcher />
{/* Название группы не показываем: оно уже есть в заголовке страницы. */}
<InProgressMatches items={inProgress} showGroupName={false} />
<h3 style={{ marginTop: 8 }}>Партии</h3> <h3 style={{ marginTop: 8 }}>Партии</h3>
{matches && <MatchListView items={matches.items} />} {matches && <MatchListView items={finishedMatches} />}
</div> </div>
); );
} }