Compare commits
17 Commits
0153f223f2
...
feature/mo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85aff823fc | ||
| 13dd8fa426 | |||
|
|
f62be600cd | ||
| 0f5249726b | |||
|
|
fdb0ba3d2d | ||
| 367868cf1b | |||
|
|
78d0ab5ece | ||
| e2eb71522d | |||
|
|
00985732ec | ||
| b1b363a7e8 | |||
|
|
f5e16c44b3 | ||
| c5ca511ea7 | |||
|
|
42057ddb1c | ||
| 1a37afd16f | |||
|
|
f7b611bbbe | ||
| 55fc23ec64 | |||
|
|
dffbb48d99 |
@@ -66,7 +66,7 @@ export function rowToDto(row: RaceRow): RaceDto {
|
|||||||
distanceKm: parseFloat(row.distance_km),
|
distanceKm: parseFloat(row.distance_km),
|
||||||
status: row.status,
|
status: row.status,
|
||||||
officialUrl: row.official_url,
|
officialUrl: row.official_url,
|
||||||
coverImageUrl: row.cover_image_url,
|
coverImageUrl: row.cover_image_url ?? null,
|
||||||
startTime: row.start_time,
|
startTime: row.start_time,
|
||||||
clusterSchedule: row.cluster_schedule,
|
clusterSchedule: row.cluster_schedule,
|
||||||
bibPickup: row.bib_pickup,
|
bibPickup: row.bib_pickup,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<html lang="ru">
|
<html lang="ru">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Календарь стартов</title>
|
<title>Календарь стартов</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
4
frontend/package-lock.json
generated
4
frontend/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "calendar-run-frontend",
|
"name": "calendar-run-frontend",
|
||||||
"version": "0.6.0",
|
"version": "0.6.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "calendar-run-frontend",
|
"name": "calendar-run-frontend",
|
||||||
"version": "0.6.0",
|
"version": "0.6.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "calendar-run-frontend",
|
"name": "calendar-run-frontend",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.6.0",
|
"version": "0.6.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
24
frontend/public/favicon.svg
Normal file
24
frontend/public/favicon.svg
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="Календарь стартов">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="bg" x1="12" y1="4" x2="52" y2="60" gradientUnits="userSpaceOnUse">
|
||||||
|
<stop offset="0" stop-color="#1168d8" />
|
||||||
|
<stop offset="1" stop-color="#071927" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect width="64" height="64" rx="16" fill="url(#bg)" />
|
||||||
|
<path
|
||||||
|
d="M18 20h28a5 5 0 0 1 5 5v21a5 5 0 0 1-5 5H18a5 5 0 0 1-5-5V25a5 5 0 0 1 5-5Z"
|
||||||
|
fill="#ffffff"
|
||||||
|
/>
|
||||||
|
<path d="M13 29h38" stroke="#d6e1ea" stroke-width="4" />
|
||||||
|
<path d="M23 14v11M41 14v11" stroke="#b9f24a" stroke-width="5" stroke-linecap="round" />
|
||||||
|
<path
|
||||||
|
d="M22 41c5-8 13-8 18 0M22 41h18"
|
||||||
|
fill="none"
|
||||||
|
stroke="#1168d8"
|
||||||
|
stroke-width="5"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
/>
|
||||||
|
<circle cx="44" cy="44" r="5" fill="#ff6f5e" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 890 B |
@@ -10,6 +10,10 @@ function isNullableString(value: unknown): value is string | null {
|
|||||||
return value === null || typeof value === "string";
|
return value === null || typeof value === "string";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isOptionalNullableString(value: unknown): value is string | null | undefined {
|
||||||
|
return value === undefined || isNullableString(value);
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeRace(input: unknown): Race {
|
function normalizeRace(input: unknown): Race {
|
||||||
const race = input as Partial<Race>;
|
const race = input as Partial<Race>;
|
||||||
|
|
||||||
@@ -23,7 +27,7 @@ function normalizeRace(input: unknown): Race {
|
|||||||
race?.status === "registered" ||
|
race?.status === "registered" ||
|
||||||
race?.status === "completed") &&
|
race?.status === "completed") &&
|
||||||
isNullableString(race?.officialUrl) &&
|
isNullableString(race?.officialUrl) &&
|
||||||
isNullableString(race?.coverImageUrl) &&
|
isOptionalNullableString(race?.coverImageUrl) &&
|
||||||
isNullableString(race?.startTime) &&
|
isNullableString(race?.startTime) &&
|
||||||
isNullableString(race?.clusterSchedule) &&
|
isNullableString(race?.clusterSchedule) &&
|
||||||
isNullableString(race?.bibPickup) &&
|
isNullableString(race?.bibPickup) &&
|
||||||
@@ -49,7 +53,7 @@ function normalizeRace(input: unknown): Race {
|
|||||||
distanceKm: race.distanceKm,
|
distanceKm: race.distanceKm,
|
||||||
status: race.status,
|
status: race.status,
|
||||||
officialUrl: race.officialUrl,
|
officialUrl: race.officialUrl,
|
||||||
coverImageUrl: race.coverImageUrl,
|
coverImageUrl: race.coverImageUrl ?? null,
|
||||||
startTime: race.startTime,
|
startTime: race.startTime,
|
||||||
clusterSchedule: race.clusterSchedule,
|
clusterSchedule: race.clusterSchedule,
|
||||||
bibPickup: race.bibPickup,
|
bibPickup: race.bibPickup,
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import { NavLink, Outlet } from "react-router-dom";
|
import { Link, NavLink, Outlet } from "react-router-dom";
|
||||||
import { AppShellFooter } from "./AppShellFooter";
|
import { AppShellFooter } from "./AppShellFooter";
|
||||||
|
|
||||||
export function AppLayout(): JSX.Element {
|
export function AppLayout(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<div className="app-shell">
|
<div className="app-shell">
|
||||||
<header className="app-shell__header">
|
<header className="app-shell__header">
|
||||||
<div className="app-shell__brand">Календарь стартов</div>
|
<Link className="app-shell__brand" to="/">
|
||||||
|
Календарь стартов
|
||||||
|
</Link>
|
||||||
<nav className="app-shell__nav" aria-label="Основная навигация">
|
<nav className="app-shell__nav" aria-label="Основная навигация">
|
||||||
<NavLink
|
<NavLink
|
||||||
to="/"
|
to="/"
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { useCallback, useMemo, useRef, useState } from "react";
|
import { useCallback, useMemo, useRef, useState } from "react";
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
import { Link, useNavigate } from "react-router-dom";
|
||||||
import type { Race } from "../api";
|
import type { Race } from "../api";
|
||||||
import { buildMonthCells, groupRacesByYmd, toYmd, WEEKDAY_LABELS_SHORT_RU } from "../lib";
|
import { buildMonthCells, groupRacesByYmd, isRaceDateInPast, toYmd, WEEKDAY_LABELS_SHORT_RU } from "../lib";
|
||||||
|
|
||||||
const MONTH_NAMES_RU_SHORT = [
|
const MONTH_NAMES_RU_SHORT = [
|
||||||
"янв.",
|
"янв.",
|
||||||
"февр.",
|
"февр.",
|
||||||
"мар.",
|
"мар.",
|
||||||
"апр.",
|
"апр.",
|
||||||
"мая",
|
"май",
|
||||||
"июн.",
|
"июн.",
|
||||||
"июл.",
|
"июл.",
|
||||||
"авг.",
|
"авг.",
|
||||||
@@ -20,6 +20,13 @@ const MONTH_NAMES_RU_SHORT = [
|
|||||||
|
|
||||||
const POPOVER_LEAVE_MS = 140;
|
const POPOVER_LEAVE_MS = 140;
|
||||||
|
|
||||||
|
function toLocalYmd(date: Date): string {
|
||||||
|
const y = date.getFullYear();
|
||||||
|
const m = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
|
const d = String(date.getDate()).padStart(2, "0");
|
||||||
|
return `${y}-${m}-${d}`;
|
||||||
|
}
|
||||||
|
|
||||||
interface RacesCalendarProps {
|
interface RacesCalendarProps {
|
||||||
displayYear: number;
|
displayYear: number;
|
||||||
monthFilter: string;
|
monthFilter: string;
|
||||||
@@ -77,6 +84,8 @@ function CalendarMonthBlock(props: {
|
|||||||
setOpenYmd: (v: string | null) => void;
|
setOpenYmd: (v: string | null) => void;
|
||||||
scheduleClose: () => void;
|
scheduleClose: () => void;
|
||||||
cancelClose: () => void;
|
cancelClose: () => void;
|
||||||
|
onMonthSelect?: (monthIndex: number) => void;
|
||||||
|
todayYmd: string;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
const {
|
const {
|
||||||
year,
|
year,
|
||||||
@@ -88,6 +97,8 @@ function CalendarMonthBlock(props: {
|
|||||||
setOpenYmd,
|
setOpenYmd,
|
||||||
scheduleClose,
|
scheduleClose,
|
||||||
cancelClose,
|
cancelClose,
|
||||||
|
onMonthSelect,
|
||||||
|
todayYmd,
|
||||||
} = props;
|
} = props;
|
||||||
const cells = useMemo(() => buildMonthCells(year, monthIndex), [year, monthIndex]);
|
const cells = useMemo(() => buildMonthCells(year, monthIndex), [year, monthIndex]);
|
||||||
const title = `${MONTH_NAMES_RU_SHORT[monthIndex]} ${year}`;
|
const title = `${MONTH_NAMES_RU_SHORT[monthIndex]} ${year}`;
|
||||||
@@ -96,7 +107,21 @@ function CalendarMonthBlock(props: {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={blockClass}>
|
<div className={blockClass}>
|
||||||
<h3 className="races-cal__month-title">{title}</h3>
|
<h3 className="races-cal__month-title">
|
||||||
|
{onMonthSelect ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="races-cal__month-title-button"
|
||||||
|
onClick={() => {
|
||||||
|
onMonthSelect(monthIndex);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
title
|
||||||
|
)}
|
||||||
|
</h3>
|
||||||
<div className="races-cal__weekdays" aria-hidden>
|
<div className="races-cal__weekdays" aria-hidden>
|
||||||
{WEEKDAY_LABELS_SHORT_RU.map((d) => (
|
{WEEKDAY_LABELS_SHORT_RU.map((d) => (
|
||||||
<span key={d} className="races-cal__weekday">
|
<span key={d} className="races-cal__weekday">
|
||||||
@@ -113,11 +138,22 @@ function CalendarMonthBlock(props: {
|
|||||||
const dayRaces = racesByYmd.get(ymd) ?? [];
|
const dayRaces = racesByYmd.get(ymd) ?? [];
|
||||||
const hasRaces = dayRaces.length > 0;
|
const hasRaces = dayRaces.length > 0;
|
||||||
const isOpen = openYmd === ymd;
|
const isOpen = openYmd === ymd;
|
||||||
|
const isPast = isRaceDateInPast(ymd);
|
||||||
|
const isToday = ymd === todayYmd;
|
||||||
|
const cellClassName = [
|
||||||
|
"races-cal__cell",
|
||||||
|
hasRaces ? "races-cal__cell--has-race" : "",
|
||||||
|
isOpen ? "races-cal__cell--open" : "",
|
||||||
|
isPast ? "races-cal__cell--past" : "",
|
||||||
|
isToday ? "races-cal__cell--today" : "",
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={ymd}
|
key={ymd}
|
||||||
className={`races-cal__cell${hasRaces ? " races-cal__cell--has-race" : ""}${isOpen ? " races-cal__cell--open" : ""}`}
|
className={cellClassName}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
cancelClose();
|
cancelClose();
|
||||||
setOpenYmd(hasRaces ? ymd : null);
|
setOpenYmd(hasRaces ? ymd : null);
|
||||||
@@ -182,6 +218,7 @@ export function RacesCalendar(props: RacesCalendarProps): JSX.Element {
|
|||||||
}, [cancelClose]);
|
}, [cancelClose]);
|
||||||
|
|
||||||
const racesByYmd = useMemo(() => groupRacesByYmd(races), [races]);
|
const racesByYmd = useMemo(() => groupRacesByYmd(races), [races]);
|
||||||
|
const todayYmd = useMemo(() => toLocalYmd(new Date()), []);
|
||||||
|
|
||||||
const focusedMonthIndex = monthFilter === "" ? null : parseInt(monthFilter, 10) - 1;
|
const focusedMonthIndex = monthFilter === "" ? null : parseInt(monthFilter, 10) - 1;
|
||||||
|
|
||||||
@@ -202,6 +239,11 @@ export function RacesCalendar(props: RacesCalendarProps): JSX.Element {
|
|||||||
setOpenYmd={setOpenYmd}
|
setOpenYmd={setOpenYmd}
|
||||||
scheduleClose={scheduleClose}
|
scheduleClose={scheduleClose}
|
||||||
cancelClose={cancelClose}
|
cancelClose={cancelClose}
|
||||||
|
onMonthSelect={(mi) => {
|
||||||
|
onMonthFilterChange(String(mi + 1));
|
||||||
|
setOpenYmd(null);
|
||||||
|
}}
|
||||||
|
todayYmd={todayYmd}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -240,6 +282,7 @@ export function RacesCalendar(props: RacesCalendarProps): JSX.Element {
|
|||||||
setOpenYmd={setOpenYmd}
|
setOpenYmd={setOpenYmd}
|
||||||
scheduleClose={scheduleClose}
|
scheduleClose={scheduleClose}
|
||||||
cancelClose={cancelClose}
|
cancelClose={cancelClose}
|
||||||
|
todayYmd={todayYmd}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { CSSProperties } from "react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import type { Race } from "../api";
|
import type { Race } from "../api";
|
||||||
@@ -7,6 +8,7 @@ import {
|
|||||||
formatDistance,
|
formatDistance,
|
||||||
formatRaceDate,
|
formatRaceDate,
|
||||||
getRaceCountdownLabel,
|
getRaceCountdownLabel,
|
||||||
|
getRaceVisual,
|
||||||
getPaceLabel,
|
getPaceLabel,
|
||||||
isCloseDistance,
|
isCloseDistance,
|
||||||
parseFinishTimeToSeconds,
|
parseFinishTimeToSeconds,
|
||||||
@@ -16,6 +18,10 @@ import {
|
|||||||
|
|
||||||
const PR_DISTANCES = [5, 10, 21.1, 42.2] as const;
|
const PR_DISTANCES = [5, 10, 21.1, 42.2] as const;
|
||||||
|
|
||||||
|
type DashboardHeroStyle = CSSProperties & {
|
||||||
|
"--dashboard-hero-image"?: string;
|
||||||
|
};
|
||||||
|
|
||||||
function getErrorMessage(error: unknown): string {
|
function getErrorMessage(error: unknown): string {
|
||||||
if (error instanceof ApiError) {
|
if (error instanceof ApiError) {
|
||||||
return error.message;
|
return error.message;
|
||||||
@@ -23,6 +29,10 @@ function getErrorMessage(error: unknown): string {
|
|||||||
return "Не удалось загрузить данные обзора.";
|
return "Не удалось загрузить данные обзора.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toCssUrl(value: string): string {
|
||||||
|
return `url(${JSON.stringify(value)})`;
|
||||||
|
}
|
||||||
|
|
||||||
export function DashboardPage(): JSX.Element {
|
export function DashboardPage(): JSX.Element {
|
||||||
const [races, setRaces] = useState<Race[]>([]);
|
const [races, setRaces] = useState<Race[]>([]);
|
||||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||||
@@ -136,6 +146,10 @@ export function DashboardPage(): JSX.Element {
|
|||||||
dashboardMetrics.seasonTotal > 0
|
dashboardMetrics.seasonTotal > 0
|
||||||
? Math.round((dashboardMetrics.seasonCompletedCount / dashboardMetrics.seasonTotal) * 100)
|
? Math.round((dashboardMetrics.seasonCompletedCount / dashboardMetrics.seasonTotal) * 100)
|
||||||
: 0;
|
: 0;
|
||||||
|
const dashboardHeroVisual = dashboardMetrics.nextRace ? getRaceVisual(dashboardMetrics.nextRace) : null;
|
||||||
|
const dashboardHeroStyle: DashboardHeroStyle | undefined = dashboardHeroVisual
|
||||||
|
? { "--dashboard-hero-image": toCssUrl(dashboardHeroVisual.imageSrc) }
|
||||||
|
: undefined;
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
@@ -157,7 +171,11 @@ export function DashboardPage(): JSX.Element {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="page page--dashboard">
|
<section className="page page--dashboard">
|
||||||
<section className="dashboard-hero" aria-label="Обзор сезона">
|
<section
|
||||||
|
className={`dashboard-hero${dashboardHeroVisual ? " dashboard-hero--with-image" : ""}`}
|
||||||
|
style={dashboardHeroStyle}
|
||||||
|
aria-label="Обзор сезона"
|
||||||
|
>
|
||||||
<div className="dashboard-hero__content">
|
<div className="dashboard-hero__content">
|
||||||
<p className="dashboard-hero__eyebrow">Календарь сезона</p>
|
<p className="dashboard-hero__eyebrow">Календарь сезона</p>
|
||||||
<h1 className="dashboard-hero__title">Беговой штаб</h1>
|
<h1 className="dashboard-hero__title">Беговой штаб</h1>
|
||||||
|
|||||||
@@ -96,6 +96,17 @@ function validateForm(form: FormData): string[] {
|
|||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isRaceDateTodayOrPast(date: string): boolean {
|
||||||
|
if (!date.trim()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const today = new Date();
|
||||||
|
const y = today.getFullYear();
|
||||||
|
const m = String(today.getMonth() + 1).padStart(2, "0");
|
||||||
|
const d = String(today.getDate()).padStart(2, "0");
|
||||||
|
return isRaceDateInPast(date) || date.slice(0, 10) === `${y}-${m}-${d}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function RaceFormPage(): JSX.Element {
|
export function RaceFormPage(): JSX.Element {
|
||||||
const { raceId } = useParams<{ raceId: string }>();
|
const { raceId } = useParams<{ raceId: string }>();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -248,6 +259,7 @@ export function RaceFormPage(): JSX.Element {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const hideOrgScheduleFields = isEditMode && isRaceDateInPast(form.date);
|
const hideOrgScheduleFields = isEditMode && isRaceDateInPast(form.date);
|
||||||
|
const showResultFields = isRaceDateTodayOrPast(form.date);
|
||||||
const pageTitle = isEditMode ? "Редактирование старта" : "Новый старт";
|
const pageTitle = isEditMode ? "Редактирование старта" : "Новый старт";
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -414,33 +426,35 @@ export function RaceFormPage(): JSX.Element {
|
|||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset className="race-form__group">
|
{showResultFields ? (
|
||||||
<legend className="race-form__legend">Результаты</legend>
|
<fieldset className="race-form__group">
|
||||||
|
<legend className="race-form__legend">Результаты</legend>
|
||||||
|
|
||||||
<label className="race-form__field">
|
<label className="race-form__field">
|
||||||
<span className="race-form__label">Финишное время</span>
|
<span className="race-form__label">Финишное время</span>
|
||||||
<input
|
<input
|
||||||
className="race-form__input"
|
className="race-form__input"
|
||||||
type="text"
|
type="text"
|
||||||
name="finishTime"
|
name="finishTime"
|
||||||
value={form.finishTime}
|
value={form.finishTime}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
placeholder="1:45:30"
|
placeholder="1:45:30"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className="race-form__field">
|
<label className="race-form__field">
|
||||||
<span className="race-form__label">Место на финише</span>
|
<span className="race-form__label">Место на финише</span>
|
||||||
<input
|
<input
|
||||||
className="race-form__input"
|
className="race-form__input"
|
||||||
type="text"
|
type="text"
|
||||||
name="finishPlace"
|
name="finishPlace"
|
||||||
value={form.finishPlace}
|
value={form.finishPlace}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
placeholder="12/340"
|
placeholder="12/340"
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<fieldset className="race-form__group">
|
<fieldset className="race-form__group">
|
||||||
<legend className="race-form__legend">Дополнительно</legend>
|
<legend className="race-form__legend">Дополнительно</legend>
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import {
|
|||||||
getRaceStatusClassName,
|
getRaceStatusClassName,
|
||||||
getRaceStatusLabel,
|
getRaceStatusLabel,
|
||||||
parseRaceDate,
|
parseRaceDate,
|
||||||
splitRacesByDate,
|
sortByDateAsc,
|
||||||
|
sortByDateDesc,
|
||||||
} from "../lib";
|
} from "../lib";
|
||||||
|
|
||||||
const MONTH_OPTIONS: { value: string; label: string }[] = [
|
const MONTH_OPTIONS: { value: string; label: string }[] = [
|
||||||
@@ -32,6 +33,7 @@ const MONTH_OPTIONS: { value: string; label: string }[] = [
|
|||||||
const VIEW_STORAGE_KEY = "races-view-mode";
|
const VIEW_STORAGE_KEY = "races-view-mode";
|
||||||
|
|
||||||
type ViewMode = "list" | "calendar";
|
type ViewMode = "list" | "calendar";
|
||||||
|
type RaceListTab = "upcoming" | "completed";
|
||||||
|
|
||||||
function yearSelectOptions(): number[] {
|
function yearSelectOptions(): number[] {
|
||||||
const current = new Date().getFullYear();
|
const current = new Date().getFullYear();
|
||||||
@@ -60,11 +62,11 @@ function readInitialViewMode(): ViewMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function RaceList(props: { title: string; races: Race[] }): JSX.Element {
|
function RaceList(props: { title: string; races: Race[]; variant: RaceListTab }): JSX.Element {
|
||||||
const { title, races } = props;
|
const { title, races, variant } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="race-list" aria-label={title}>
|
<section className={`race-list race-list--${variant}`} aria-label={title}>
|
||||||
<h2 className="race-list__title">{title}</h2>
|
<h2 className="race-list__title">{title}</h2>
|
||||||
{races.length > 0 ? (
|
{races.length > 0 ? (
|
||||||
<ul className="race-list__items">
|
<ul className="race-list__items">
|
||||||
@@ -137,6 +139,7 @@ export function RacesPage(): JSX.Element {
|
|||||||
const [yearFilter, setYearFilter] = useState<string>("");
|
const [yearFilter, setYearFilter] = useState<string>("");
|
||||||
const [monthFilter, setMonthFilter] = useState<string>("");
|
const [monthFilter, setMonthFilter] = useState<string>("");
|
||||||
const [viewMode, setViewMode] = useState<ViewMode>(() => readInitialViewMode());
|
const [viewMode, setViewMode] = useState<ViewMode>(() => readInitialViewMode());
|
||||||
|
const [activeListTab, setActiveListTab] = useState<RaceListTab>("upcoming");
|
||||||
|
|
||||||
const setViewModePersist = useCallback((mode: ViewMode) => {
|
const setViewModePersist = useCallback((mode: ViewMode) => {
|
||||||
setViewMode(mode);
|
setViewMode(mode);
|
||||||
@@ -220,7 +223,32 @@ export function RacesPage(): JSX.Element {
|
|||||||
};
|
};
|
||||||
}, [listQuery]);
|
}, [listQuery]);
|
||||||
|
|
||||||
const { upcoming, past } = useMemo(() => splitRacesByDate(races), [races]);
|
const { upcoming, completed } = useMemo(
|
||||||
|
() => ({
|
||||||
|
upcoming: sortByDateAsc(races.filter((race) => race.status !== "completed")),
|
||||||
|
completed: sortByDateDesc(races.filter((race) => race.status === "completed")),
|
||||||
|
}),
|
||||||
|
[races],
|
||||||
|
);
|
||||||
|
const statusMessage = useMemo(() => {
|
||||||
|
if (errorMessage && !isLoading) {
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
if (isLoading) {
|
||||||
|
return "Загружаем данные...";
|
||||||
|
}
|
||||||
|
if (viewMode === "calendar" && monthFilter === "") {
|
||||||
|
return "Выберите месяц, чтобы увидеть его крупным планом.";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}, [errorMessage, isLoading, monthFilter, viewMode]);
|
||||||
|
const statusClassName = [
|
||||||
|
"races-status__message",
|
||||||
|
!statusMessage ? "races-status__message--empty" : "",
|
||||||
|
errorMessage && !isLoading ? "races-status__message--error" : "",
|
||||||
|
]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(" ");
|
||||||
|
|
||||||
if (errorMessage && races.length === 0 && !isLoading) {
|
if (errorMessage && races.length === 0 && !isLoading) {
|
||||||
return (
|
return (
|
||||||
@@ -294,27 +322,46 @@ export function RacesPage(): JSX.Element {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{errorMessage && !isLoading ? (
|
<div className="races-status" aria-live="polite">
|
||||||
<p className="page__subtitle page__subtitle--error" role="alert" style={{ marginTop: "var(--space-4)" }}>
|
<p
|
||||||
{errorMessage}
|
className={statusClassName}
|
||||||
|
role={errorMessage && !isLoading ? "alert" : undefined}
|
||||||
|
aria-busy={isLoading || undefined}
|
||||||
|
aria-hidden={!statusMessage || undefined}
|
||||||
|
>
|
||||||
|
{statusMessage || "\u00a0"}
|
||||||
</p>
|
</p>
|
||||||
) : null}
|
</div>
|
||||||
|
|
||||||
{viewMode === "calendar" && monthFilter === "" ? (
|
|
||||||
<p className="page__subtitle races-cal__filter-hint">Выберите месяц, чтобы увидеть его крупным планом.</p>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{isLoading ? (
|
|
||||||
<p className="page__subtitle" aria-busy="true">
|
|
||||||
Загружаем данные...
|
|
||||||
</p>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{viewMode === "list" ? (
|
{viewMode === "list" ? (
|
||||||
<div className="race-lists">
|
<>
|
||||||
<RaceList title="Будущие" races={upcoming} />
|
<div className="race-list-tabs" role="tablist" aria-label="Раздел стартов">
|
||||||
<RaceList title="Прошедшие" races={past} />
|
<button
|
||||||
</div>
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
aria-selected={activeListTab === "upcoming"}
|
||||||
|
className={`race-list-tabs__btn${activeListTab === "upcoming" ? " race-list-tabs__btn--active" : ""}`}
|
||||||
|
onClick={() => setActiveListTab("upcoming")}
|
||||||
|
>
|
||||||
|
Будущие
|
||||||
|
<span className="race-list-tabs__count">{upcoming.length}</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
role="tab"
|
||||||
|
aria-selected={activeListTab === "completed"}
|
||||||
|
className={`race-list-tabs__btn${activeListTab === "completed" ? " race-list-tabs__btn--active" : ""}`}
|
||||||
|
onClick={() => setActiveListTab("completed")}
|
||||||
|
>
|
||||||
|
Прошедшие
|
||||||
|
<span className="race-list-tabs__count">{completed.length}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className={`race-lists race-lists--mobile-${activeListTab}`}>
|
||||||
|
<RaceList title="Будущие" races={upcoming} variant="upcoming" />
|
||||||
|
<RaceList title="Завершенные" races={completed} variant="completed" />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className="races-cal-wrap">
|
<div className="races-cal-wrap">
|
||||||
<RacesCalendar
|
<RacesCalendar
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ a {
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-shell__brand:hover,
|
||||||
|
.app-shell__brand:focus-visible {
|
||||||
|
color: var(--color-text);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
.app-shell__nav {
|
.app-shell__nav {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -242,6 +248,27 @@ a {
|
|||||||
gap: var(--space-4);
|
gap: var(--space-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.race-list-tabs {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.race-list-tabs__btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: var(--space-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.race-list-tabs__count {
|
||||||
|
min-width: 1.75rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
padding: 0.1rem var(--space-2);
|
||||||
|
background: var(--color-surface-soft);
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
font-size: var(--font-size-caption);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
.race-list {
|
.race-list {
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
@@ -961,6 +988,25 @@ a {
|
|||||||
margin-top: var(--space-6);
|
margin-top: var(--space-6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.races-status {
|
||||||
|
min-height: calc(var(--line-height-base) * var(--font-size-caption));
|
||||||
|
margin-top: var(--space-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.races-status__message {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
font-size: var(--font-size-caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
.races-status__message--empty {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.races-status__message--error {
|
||||||
|
color: var(--color-danger);
|
||||||
|
}
|
||||||
|
|
||||||
.races-cal__filter-hint {
|
.races-cal__filter-hint {
|
||||||
margin-top: var(--space-3);
|
margin-top: var(--space-3);
|
||||||
color: var(--color-text-muted);
|
color: var(--color-text-muted);
|
||||||
@@ -1006,6 +1052,26 @@ a {
|
|||||||
color: var(--color-text);
|
color: var(--color-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.races-cal__month-title-button {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: inherit;
|
||||||
|
font: inherit;
|
||||||
|
font-weight: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.races-cal__month-title-button:hover,
|
||||||
|
.races-cal__month-title-button:focus-visible {
|
||||||
|
color: var(--color-accent);
|
||||||
|
text-decoration: underline;
|
||||||
|
text-underline-offset: 2px;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
.races-cal__weekdays {
|
.races-cal__weekdays {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(7, 1fr);
|
grid-template-columns: repeat(7, 1fr);
|
||||||
@@ -1040,6 +1106,12 @@ a {
|
|||||||
color: var(--color-accent);
|
color: var(--color-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.races-cal__cell--past .races-cal__day-btn {
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
background: #f0f2f4;
|
||||||
|
border-color: #d8dde2;
|
||||||
|
}
|
||||||
|
|
||||||
.races-cal__cell--open {
|
.races-cal__cell--open {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
@@ -1070,6 +1142,12 @@ a {
|
|||||||
border-color: var(--color-accent);
|
border-color: var(--color-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.races-cal__cell--today .races-cal__day-btn,
|
||||||
|
.races-cal__cell--today .races-cal__day-btn:hover,
|
||||||
|
.races-cal__cell--today .races-cal__day-btn:focus-visible {
|
||||||
|
border-color: var(--color-text);
|
||||||
|
}
|
||||||
|
|
||||||
.races-cal__popover {
|
.races-cal__popover {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: calc(100% + var(--space-1));
|
top: calc(100% + var(--space-1));
|
||||||
@@ -1226,6 +1304,11 @@ body {
|
|||||||
color: var(--color-bg-deep);
|
color: var(--color-bg-deep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app-shell__brand:hover,
|
||||||
|
.app-shell__brand:focus-visible {
|
||||||
|
color: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
.app-shell__link {
|
.app-shell__link {
|
||||||
font-size: var(--font-size-caption);
|
font-size: var(--font-size-caption);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@@ -1293,6 +1376,12 @@ body {
|
|||||||
url("/images/runner-hero.jpg") center / cover;
|
url("/images/runner-hero.jpg") center / cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dashboard-hero--with-image {
|
||||||
|
background:
|
||||||
|
linear-gradient(90deg, rgba(7, 25, 39, 0.94) 0%, rgba(7, 25, 39, 0.68) 48%, rgba(7, 25, 39, 0.2) 100%),
|
||||||
|
var(--dashboard-hero-image) center / cover;
|
||||||
|
}
|
||||||
|
|
||||||
.dashboard-hero__content,
|
.dashboard-hero__content,
|
||||||
.dashboard-hero__panel {
|
.dashboard-hero__panel {
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -1747,18 +1836,61 @@ body {
|
|||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.races-cal__month-title-button {
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
transition:
|
||||||
|
color 0.15s ease,
|
||||||
|
text-decoration-color 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.races-cal__month-title-button:hover,
|
||||||
|
.races-cal__month-title-button:focus-visible {
|
||||||
|
color: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
.races-cal__cell--has-race .races-cal__day-btn {
|
.races-cal__cell--has-race .races-cal__day-btn {
|
||||||
color: #071927;
|
color: #071927;
|
||||||
background: linear-gradient(135deg, rgba(185, 242, 74, 0.7), rgba(17, 104, 216, 0.14));
|
background: linear-gradient(135deg, rgba(185, 242, 74, 0.7), rgba(17, 104, 216, 0.14));
|
||||||
border-color: rgba(17, 104, 216, 0.18);
|
border-color: rgba(17, 104, 216, 0.18);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.races-cal__cell--past .races-cal__day-btn,
|
||||||
|
.races-cal__cell--past.races-cal__cell--has-race .races-cal__day-btn {
|
||||||
|
color: #6f7c87;
|
||||||
|
background: #eef1f3;
|
||||||
|
border-color: #d4dbe1;
|
||||||
|
}
|
||||||
|
|
||||||
.races-cal__cell--has-race .races-cal__day-btn:hover,
|
.races-cal__cell--has-race .races-cal__day-btn:hover,
|
||||||
.races-cal__cell--has-race .races-cal__day-btn:focus-visible {
|
.races-cal__cell--has-race .races-cal__day-btn:focus-visible {
|
||||||
background: var(--color-lime);
|
background: var(--color-lime);
|
||||||
border-color: var(--color-bg-deep);
|
border-color: var(--color-bg-deep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.races-cal__cell--past .races-cal__day-btn:hover,
|
||||||
|
.races-cal__cell--past .races-cal__day-btn:focus-visible,
|
||||||
|
.races-cal__cell--past.races-cal__cell--has-race .races-cal__day-btn:hover,
|
||||||
|
.races-cal__cell--past.races-cal__cell--has-race .races-cal__day-btn:focus-visible {
|
||||||
|
color: #52616d;
|
||||||
|
background: #e3e8ec;
|
||||||
|
border-color: #aeb9c3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.races-cal__cell--today .races-cal__day-btn,
|
||||||
|
.races-cal__cell--today.races-cal__cell--has-race .races-cal__day-btn,
|
||||||
|
.races-cal__cell--today.races-cal__cell--past .races-cal__day-btn {
|
||||||
|
border-color: #071927;
|
||||||
|
box-shadow: inset 0 0 0 1px #071927;
|
||||||
|
}
|
||||||
|
|
||||||
|
.races-cal__cell--today .races-cal__day-btn:hover,
|
||||||
|
.races-cal__cell--today .races-cal__day-btn:focus-visible,
|
||||||
|
.races-cal__cell--today.races-cal__cell--has-race .races-cal__day-btn:hover,
|
||||||
|
.races-cal__cell--today.races-cal__cell--has-race .races-cal__day-btn:focus-visible {
|
||||||
|
border-color: #071927;
|
||||||
|
box-shadow: inset 0 0 0 1px #071927;
|
||||||
|
}
|
||||||
|
|
||||||
.races-cal__popover {
|
.races-cal__popover {
|
||||||
border-color: rgba(17, 104, 216, 0.2);
|
border-color: rgba(17, 104, 216, 0.2);
|
||||||
border-radius: var(--radius-md);
|
border-radius: var(--radius-md);
|
||||||
@@ -1879,6 +2011,53 @@ body {
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.race-list-tabs {
|
||||||
|
margin-top: var(--space-6);
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: var(--space-1);
|
||||||
|
padding: var(--space-1);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
background: var(--color-surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
.race-list-tabs__btn {
|
||||||
|
min-height: 2.75rem;
|
||||||
|
border: 0;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
background: transparent;
|
||||||
|
color: var(--color-text-muted);
|
||||||
|
font: inherit;
|
||||||
|
font-weight: 700;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.race-list-tabs__btn:hover,
|
||||||
|
.race-list-tabs__btn:focus-visible {
|
||||||
|
color: var(--color-text);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.race-list-tabs__btn--active {
|
||||||
|
background: var(--color-accent);
|
||||||
|
color: var(--color-surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
.race-list-tabs__btn--active .race-list-tabs__count {
|
||||||
|
background: var(--color-surface);
|
||||||
|
color: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.race-lists {
|
||||||
|
margin-top: var(--space-4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.race-lists--mobile-upcoming .race-list--completed,
|
||||||
|
.race-lists--mobile-completed .race-list--upcoming {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.races-cal__year {
|
.races-cal__year {
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user