API+App+Admin: telemetria bytnosci w ogolnym widoku sirowni - GET /gyms/:id/presence-stats (heatmapa dzien×godzina, sredni pobyt, wizyty/dzien, szczyt, teraz w srodku, top urzadzenia; stale 30 dni), wspoldzielony komponent PresenceHeatmap, telemetria wyciagnieta z podstrony statystyk; pasek godzin w forma zegarowa z minutami, usuniete karta Dane i filtr okresu; swagger + testy integracyjne, unit i e2e
This commit is contained in:
74
admin/src/components/gyms/PresenceHeatmap.tsx
Normal file
74
admin/src/components/gyms/PresenceHeatmap.tsx
Normal file
@@ -0,0 +1,74 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { dayName } from '../../lib/format';
|
||||
import { dayShort } from '../../lib/availability';
|
||||
|
||||
export interface PresenceHeatCell {
|
||||
day: number;
|
||||
hour: number;
|
||||
count: number;
|
||||
}
|
||||
|
||||
/* Mapa ciepła bytności 7 (dzień 0=pon) × 24 (godzina) — natężenie ~ udział w szczycie,
|
||||
styl kafli jak mapa urządzeń. Lustrzana kopia komponentu z app (identyczny widok
|
||||
w obu pakietach). Etykiety dni skrócone (pełna nazwa w tytulu wiersza), siatka
|
||||
skaluje się do szerokosci kolumny — bez minimalnej szerokosci i przewijania. */
|
||||
export function PresenceHeatmapGrid({ cells }: { cells: PresenceHeatCell[] }) {
|
||||
const max = cells.reduce((m, c) => Math.max(m, c.count), 0);
|
||||
return (
|
||||
<div className="min-w-0">
|
||||
<div
|
||||
className="grid gap-[3px]"
|
||||
style={{ gridTemplateColumns: 'minmax(2.4rem, 3.4rem) repeat(24, minmax(0, 1fr))' }}
|
||||
>
|
||||
<span />
|
||||
{Array.from({ length: 24 }, (_, hour) => (
|
||||
<span
|
||||
key={hour}
|
||||
className="min-w-0 truncate text-center text-[0.6rem] font-bold tabular-nums text-dim"
|
||||
>
|
||||
{hour % 3 === 0 ? String(hour).padStart(2, '0') : ''}
|
||||
</span>
|
||||
))}
|
||||
{Array.from({ length: 7 }, (_, day) => (
|
||||
<HeatmapRow key={day} day={day} cells={cells} max={max} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HeatmapRow({ day, cells, max }: { day: number; cells: PresenceHeatCell[]; max: number }) {
|
||||
const { t } = useTranslation('gyms');
|
||||
return (
|
||||
<>
|
||||
<span
|
||||
title={dayName(day + 1)}
|
||||
className="flex min-w-0 items-center pr-1 text-[0.68rem] font-semibold text-dim"
|
||||
>
|
||||
<span className="truncate">{dayShort(day)}</span>
|
||||
</span>
|
||||
{Array.from({ length: 24 }, (_, hour) => {
|
||||
const cell = cells.find((c) => c.day === day && c.hour === hour);
|
||||
const count = cell?.count ?? 0;
|
||||
const intensity = max > 0 ? count / max : 0;
|
||||
return (
|
||||
<span
|
||||
key={hour}
|
||||
title={t('stats.cellTitle', {
|
||||
day: dayName(day + 1),
|
||||
hour: String(hour).padStart(2, '0'),
|
||||
count,
|
||||
})}
|
||||
className="aspect-square rounded-[2px] border border-line/40"
|
||||
style={{
|
||||
background:
|
||||
intensity > 0
|
||||
? `color-mix(in srgb, var(--accent) ${Math.round(18 + intensity * 82)}%, var(--bg-input))`
|
||||
: 'var(--bg-input)',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -79,7 +79,7 @@
|
||||
"tilePhotos_other": "{{count}} photos",
|
||||
"tileAnnouncementsCount_one": "{{count}} announcement",
|
||||
"tileAnnouncementsCount_other": "{{count}} announcements",
|
||||
"basicInfo": "Basic information",
|
||||
"basicInfo": "Information",
|
||||
"groupGallery": "Gallery",
|
||||
"groupEquipment": "Equipment",
|
||||
"groupOwners": "Owners",
|
||||
@@ -115,19 +115,7 @@
|
||||
"newAction": "New announcement"
|
||||
},
|
||||
"equipmentDesc": "Machines and equipment available at this gym.",
|
||||
"hours": "Opening hours",
|
||||
"exceptions": "Exceptions",
|
||||
"data": "Details",
|
||||
"kindLabel": "Type",
|
||||
"kindReal": "Real",
|
||||
"kindVirtual": "Virtual",
|
||||
"privateLabel": "Private",
|
||||
"capacityLabel": "Capacity",
|
||||
"streetLabel": "Street",
|
||||
"cityCodeLabel": "Code and city",
|
||||
"countryLabel": "Country",
|
||||
"locationLabel": "Location",
|
||||
"ownersLabel": "Owners",
|
||||
"exceptionsTitle": "Schedule exceptions",
|
||||
"exceptionsDesc": "One-off changes for a specific day (closure or other hours).",
|
||||
"manageGallery": "Manage gallery",
|
||||
@@ -176,19 +164,15 @@
|
||||
"presenceNow_other": "now: {{count}} people",
|
||||
"presenceFull": "full",
|
||||
"presence": {
|
||||
"title": "Presence",
|
||||
"desc": "Gym check-ins (QR code / “I'm working out” button).",
|
||||
"empty": "No presence data in this period.",
|
||||
"title": "Attendance",
|
||||
"empty": "No check-ins in the last 30 days.",
|
||||
"live": "inside now",
|
||||
"visitsRange": "visits ({{days}} days)",
|
||||
"rangeAria": "Presence date range",
|
||||
"rangeDays_one": "{{count}} day",
|
||||
"rangeDays_other": "{{count}} days",
|
||||
"visits": "visits (30 days)",
|
||||
"avgStay": "avg stay",
|
||||
"visitsPerDay": "visits/day",
|
||||
"peak": "hourly peak",
|
||||
"minutesShort": "min",
|
||||
"heatmap": "When people show up (day × hour)",
|
||||
"heatmap": "When they train (day × hour)",
|
||||
"topEquipment": "Most used equipment",
|
||||
"qrGroup": "QR",
|
||||
"qrAction": "QR code",
|
||||
@@ -198,5 +182,9 @@
|
||||
"qrDownload": "Download PNG",
|
||||
"qrCopy": "Copy link",
|
||||
"qrCopied": "Copied"
|
||||
},
|
||||
"stats": {
|
||||
"cellTitle_one": "{{day}}, {{hour}}:00 — {{count}} visit",
|
||||
"cellTitle_other": "{{day}}, {{hour}}:00 — {{count}} visits"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
"tileAnnouncementsCount_few": "{{count}} ogłoszenia",
|
||||
"tileAnnouncementsCount_many": "{{count}} ogłoszeń",
|
||||
"tileAnnouncementsCount_other": "{{count}} ogłoszeń",
|
||||
"basicInfo": "Podstawowe informacje",
|
||||
"basicInfo": "Informacje",
|
||||
"groupGallery": "Galeria",
|
||||
"groupEquipment": "Urządzenia",
|
||||
"groupOwners": "Właściciele",
|
||||
@@ -127,19 +127,7 @@
|
||||
"newAction": "Nowe ogłoszenie"
|
||||
},
|
||||
"equipmentDesc": "Maszyny i urządzenia dostępne w tej siłowni.",
|
||||
"hours": "Godziny otwarcia",
|
||||
"exceptions": "Wyjątki",
|
||||
"data": "Dane",
|
||||
"kindLabel": "Rodzaj",
|
||||
"kindReal": "Realna",
|
||||
"kindVirtual": "Wirtualna",
|
||||
"privateLabel": "Prywatna",
|
||||
"capacityLabel": "Pojemność",
|
||||
"streetLabel": "Ulica",
|
||||
"cityCodeLabel": "Kod i miasto",
|
||||
"countryLabel": "Kraj",
|
||||
"locationLabel": "Lokalizacja",
|
||||
"ownersLabel": "Właściciele",
|
||||
"exceptionsTitle": "Wyjątki w harmonogramie",
|
||||
"exceptionsDesc": "Jednorazowe zmiany na konkretny dzień (zamknięcie lub inne godziny).",
|
||||
"manageGallery": "Zarządzaj galerią",
|
||||
@@ -189,15 +177,9 @@
|
||||
"presenceFull": "pełno",
|
||||
"presence": {
|
||||
"title": "Bytność",
|
||||
"desc": "Meldunki na siłowni (kod QR / przycisk „Idę ćwiczyć”).",
|
||||
"empty": "Brak danych bytności w tym okresie.",
|
||||
"empty": "Brak meldunków w ostatnich 30 dniach.",
|
||||
"live": "teraz w środku",
|
||||
"visitsRange": "wizyty ({{days}} dni)",
|
||||
"rangeAria": "Zakres dat bytności",
|
||||
"rangeDays_one": "{{count}} dzień",
|
||||
"rangeDays_few": "{{count}} dni",
|
||||
"rangeDays_many": "{{count}} dni",
|
||||
"rangeDays_other": "{{count}} dni",
|
||||
"visits": "wizyty (30 dni)",
|
||||
"avgStay": "śr. pobyt",
|
||||
"visitsPerDay": "wizyt/dzień",
|
||||
"peak": "rekord godzinowy",
|
||||
@@ -212,5 +194,11 @@
|
||||
"qrDownload": "Pobierz PNG",
|
||||
"qrCopy": "Kopiuj link",
|
||||
"qrCopied": "Skopiowano"
|
||||
},
|
||||
"stats": {
|
||||
"cellTitle_one": "{{day}}, {{hour}}:00 — {{count}} wizyta",
|
||||
"cellTitle_few": "{{day}}, {{hour}}:00 — {{count}} wizyty",
|
||||
"cellTitle_many": "{{day}}, {{hour}}:00 — {{count}} wizyt",
|
||||
"cellTitle_other": "{{day}}, {{hour}}:00 — {{count}} wizyt"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,3 +75,13 @@ export function shortTime(t: string): string {
|
||||
export function formatDayRange(day: DayAvailability): string {
|
||||
return `${shortTime(day.start)}–${shortTime(day.end)}`;
|
||||
}
|
||||
|
||||
/** "06:00" -> "6:00" — minuty zawsze widoczne, usuwane tylko zero wiodące. */
|
||||
export function clockTime(t: string): string {
|
||||
return t.replace(/^0/, '');
|
||||
}
|
||||
|
||||
/** Zakres dnia z minutami do paska godzin, np. "6:00–22:00". */
|
||||
export function formatDayRangeClock(day: DayAvailability): string {
|
||||
return `${clockTime(day.start)}–${clockTime(day.end)}`;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
Crown,
|
||||
Dumbbell,
|
||||
Image as ImageIcon,
|
||||
MapPin,
|
||||
Settings,
|
||||
Star,
|
||||
Trash2,
|
||||
@@ -20,6 +19,7 @@ import { useTopbar, type TopbarCustomGroup } from '../../topbar';
|
||||
import { api } from '../../api/client';
|
||||
import { AuthImage } from '../../components/AuthImage';
|
||||
import GymQrModal from '../../components/gyms/GymQrModal';
|
||||
import { PresenceHeatmapGrid } from '../../components/gyms/PresenceHeatmap';
|
||||
import { UserPicker } from '../../components/UserPicker';
|
||||
import { AddressFields, addressPayload, isAddressComplete } from '../../components/AddressFields';
|
||||
import { useAdminUsers } from '../users/user-queries';
|
||||
@@ -63,11 +63,11 @@ import { AvailabilityEditor } from '../../components/AvailabilityEditor';
|
||||
import {
|
||||
dayFull,
|
||||
dayShort,
|
||||
formatDayRange,
|
||||
formatDayRangeClock,
|
||||
normalizeAvailability,
|
||||
TIME_SLOTS,
|
||||
} from '../../lib/availability';
|
||||
import { fmtDate, fmtDateTime, fmtNumber } from '../../lib/format';
|
||||
import { fmtDate, fmtDateTime } from '../../lib/format';
|
||||
|
||||
/* Godziny otwarcia w całym wierszu pod hero — lustrzany widok jak w apce (informacja
|
||||
kluczowa, więc nie w kolumnie bocznej). Pasek tygodnia wzorowany na kartach listy:
|
||||
@@ -85,10 +85,9 @@ function HoursBand({ gym }: { gym: Gym }) {
|
||||
const hasHours = availability.some(Boolean);
|
||||
if (!hasHours && exceptions.length === 0) return null;
|
||||
return (
|
||||
<Card className="mb-5 p-4 sm:p-5">
|
||||
<Card className="@container mb-5 p-4 sm:p-5">
|
||||
{hasHours && (
|
||||
<>
|
||||
<SectionHeader title={t('hours')} />
|
||||
<div className="grid grid-cols-7 gap-1 sm:gap-1.5">
|
||||
{availability.map((day, i) => (
|
||||
<div
|
||||
@@ -98,29 +97,34 @@ function HoursBand({ gym }: { gym: Gym }) {
|
||||
} ${i === todayIdx ? 'outline outline-1 outline-accent/50' : ''}`}
|
||||
>
|
||||
<div
|
||||
className={`truncate text-[0.74rem] font-semibold sm:text-[0.78rem] ${
|
||||
className={`flex items-center justify-center gap-1 text-[0.74rem] font-semibold sm:text-[0.78rem] ${
|
||||
day ? 'text-accent-text' : 'text-dim/60'
|
||||
}`}
|
||||
>
|
||||
{/* telefon: skrót dnia + zwarty zakres; desktop: pełna nazwa + pełne godziny */}
|
||||
<span className="uppercase tracking-wide sm:hidden">{dayShort(i)}</span>
|
||||
<span className="hidden items-center justify-center gap-1.5 sm:flex">
|
||||
{dayFull(i)}
|
||||
{i === todayIdx && (
|
||||
<span className="rounded-full bg-accent px-1.5 py-0.5 text-[0.58rem] font-extrabold uppercase tracking-wide text-accent-ink">
|
||||
{t('today')}
|
||||
</span>
|
||||
)}
|
||||
{/* pelna nazwa dnia tylko gdy miesci sie w kolumnie (container query karty),
|
||||
ponizej skrot; minuty godzin sa zawsze widoczne — ponizej @3xl zakres
|
||||
lamie sie do dwoch linii zamiast byc przycinany lub gubic minuty;
|
||||
badge „dziś" rownolegle obok nazwy (od @2xl), nie osobna linia */}
|
||||
<span className="min-w-0 truncate uppercase tracking-wide @4xl:hidden">
|
||||
{dayShort(i)}
|
||||
</span>
|
||||
<span className="hidden min-w-0 truncate @4xl:inline">{dayFull(i)}</span>
|
||||
{i === todayIdx && (
|
||||
<span className="hidden shrink-0 rounded-full bg-accent px-1 py-0.5 text-[0.5rem] font-extrabold uppercase leading-none text-accent-ink @2xl:inline-block">
|
||||
{t('today')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div
|
||||
className={`truncate text-[0.66rem] font-semibold tabular-nums sm:text-[0.8rem] ${
|
||||
className={`text-[0.66rem] font-semibold tabular-nums sm:text-[0.8rem] ${
|
||||
day ? 'text-ink' : 'text-dim/50'
|
||||
}`}
|
||||
>
|
||||
<span className="sm:hidden">{day ? formatDayRange(day) : '—'}</span>
|
||||
<span className="hidden sm:block">
|
||||
{day ? `${day.start}–${day.end}` : t('closed')}
|
||||
<span className="break-words @3xl:hidden">
|
||||
{day ? formatDayRangeClock(day) : '—'}
|
||||
</span>
|
||||
<span className="hidden whitespace-nowrap @3xl:block">
|
||||
{day ? formatDayRangeClock(day) : t('closed')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -174,44 +178,28 @@ function PresenceTelemetry({ gymId, rangeDays }: { gymId: string; rangeDays: num
|
||||
}
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="grid grid-cols-2 gap-2 sm:grid-cols-5">
|
||||
{[
|
||||
{ label: t('presence.live'), value: String(s.live) },
|
||||
{ label: t('presence.visitsRange', { days: rangeDays }), value: String(s.visits) },
|
||||
{
|
||||
label: t('presence.avgStay'),
|
||||
value:
|
||||
s.avgStayMinutes != null ? `${s.avgStayMinutes} ${t('presence.minutesShort')}` : '—',
|
||||
},
|
||||
{ label: t('presence.peak'), value: String(s.peak) },
|
||||
{ label: t('presence.visitsPerDay'), value: fmtNumber(s.visitsPerDay) },
|
||||
].map((k) => (
|
||||
<div
|
||||
key={k.label}
|
||||
className="rounded-[10px] border border-line bg-input/50 px-3 py-2 text-[0.78rem]"
|
||||
>
|
||||
<span className="block truncate text-dim">{k.label}</span>
|
||||
<b className="font-display text-[1.05rem] tabular-nums">{k.value}</b>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{s.heatmap.length > 0 && (
|
||||
<div>
|
||||
<div className="min-w-0">
|
||||
<div className="mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
|
||||
{t('presence.heatmap')}
|
||||
</div>
|
||||
<div
|
||||
className="grid gap-px"
|
||||
style={{ gridTemplateColumns: '2.4rem repeat(24, minmax(0, 1fr))' }}
|
||||
>
|
||||
{Array.from({ length: 7 }, (_, day) => (
|
||||
<FragmentRow key={day} day={day} stats={s} />
|
||||
))}
|
||||
</div>
|
||||
<PresenceHeatmapGrid cells={s.heatmap} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Metryki: etykieta lewa, wartość prawa — zwarta lista mieści się w każdym metrażu. */}
|
||||
<dl className="flex flex-col">
|
||||
<PresenceRow label={t('presence.live')} value={String(s.live)} live={s.live > 0} />
|
||||
<PresenceRow label={t('presence.visits')} value={String(s.visits)} />
|
||||
<PresenceRow
|
||||
label={t('presence.avgStay')}
|
||||
value={s.avgStayMinutes != null ? String(s.avgStayMinutes) : '—'}
|
||||
unit={s.avgStayMinutes != null ? t('presence.minutesShort') : undefined}
|
||||
/>
|
||||
<PresenceRow label={t('presence.peak')} value={String(s.peak)} />
|
||||
<PresenceRow label={t('presence.visitsPerDay')} value={String(s.visitsPerDay)} />
|
||||
</dl>
|
||||
|
||||
{s.topEquipment.length > 0 && (
|
||||
<div>
|
||||
<div className="mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
|
||||
@@ -233,31 +221,30 @@ function PresenceTelemetry({ gymId, rangeDays }: { gymId: string; rangeDays: num
|
||||
);
|
||||
}
|
||||
|
||||
/* Wiersz heatmapy: etykieta dnia + 24 kafle godziny (kolor ~ natężenie). */
|
||||
function FragmentRow({ day, stats }: { day: number; stats: GymPresenceStatsResponse['stats'] }) {
|
||||
/* Wiersz metryki bytności: etykieta po lewej, wartość (opcjonalna jednostka) po prawej. */
|
||||
function PresenceRow({
|
||||
label,
|
||||
value,
|
||||
unit,
|
||||
live,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
unit?: string;
|
||||
live?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<span className="pr-1 text-right text-[0.65rem] font-bold uppercase text-dim">
|
||||
{dayFull(day).slice(0, 2)}
|
||||
</span>
|
||||
{Array.from({ length: 24 }, (_, hour) => {
|
||||
const cell = stats.heatmap.find((h) => h.day === day && h.hour === hour);
|
||||
const intensity = cell && stats.peak > 0 ? cell.count / stats.peak : 0;
|
||||
return (
|
||||
<span
|
||||
key={hour}
|
||||
title={`${dayFull(day)} ${String(hour).padStart(2, '0')}:00 — ${cell?.count ?? 0}`}
|
||||
className="aspect-square rounded-[2px] border border-line/40"
|
||||
style={{
|
||||
background:
|
||||
intensity > 0
|
||||
? `color-mix(in srgb, var(--accent) ${Math.round(18 + intensity * 82)}%, var(--bg-input))`
|
||||
: 'var(--bg-input)',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
<div className="flex items-baseline justify-between gap-3 border-b border-line/40 py-1.5 last:border-b-0">
|
||||
<dt className="min-w-0 text-[0.8125rem] text-dim">{label}</dt>
|
||||
<dd
|
||||
className={`shrink-0 font-display text-[1.1rem] font-bold tabular-nums ${
|
||||
live ? 'text-accent-text' : ''
|
||||
}`}
|
||||
>
|
||||
{value}
|
||||
{unit && <span className="ml-1 text-[0.72rem] font-semibold text-dim">{` ${unit}`}</span>}
|
||||
</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -271,9 +258,9 @@ function GalleryTile({ gym }: { gym: Gym }) {
|
||||
to={`/gyms/${gym.id}/gallery`}
|
||||
className="flex flex-col rounded-2xl border border-line bg-card p-3 transition-colors hover:border-accent/55"
|
||||
>
|
||||
<div className="grid h-20 grid-cols-4 gap-1.5">
|
||||
<div className="grid h-28 grid-cols-4 grid-rows-1 gap-1.5">
|
||||
{preview.length === 0 ? (
|
||||
<div className="col-span-4 grid place-items-center rounded-[10px] border border-dashed border-line bg-input/50 text-dim">
|
||||
<div className="col-span-4 row-span-1 grid place-items-center rounded-[10px] border border-dashed border-line bg-input/50 text-dim">
|
||||
<ImageIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</div>
|
||||
) : (
|
||||
@@ -305,20 +292,35 @@ function EquipmentTile({ gym }: { gym: Gym }) {
|
||||
to={`/gyms/${gym.id}/equipment`}
|
||||
className="flex flex-col rounded-2xl border border-line bg-card p-3 transition-colors hover:border-accent/55"
|
||||
>
|
||||
<div className="grid h-20 grid-cols-2 content-center gap-1.5">
|
||||
<div className="grid h-28 grid-cols-4 grid-rows-[minmax(0,1fr)_auto] gap-1.5">
|
||||
{preview.length === 0 ? (
|
||||
<div className="col-span-2 grid place-items-center rounded-[10px] border border-dashed border-line bg-input/50 text-dim">
|
||||
<div className="col-span-4 row-span-2 grid place-items-center rounded-[10px] border border-dashed border-line bg-input/50 text-dim">
|
||||
<Dumbbell className="h-5 w-5" aria-hidden="true" />
|
||||
</div>
|
||||
) : (
|
||||
preview.map((e) => (
|
||||
<span
|
||||
key={e.id}
|
||||
className="min-w-0 truncate rounded-[8px] border border-line bg-input/50 px-1.5 py-1 text-[0.65rem] font-semibold text-dim"
|
||||
>
|
||||
{formatGymEquipment(e, i18n.language)}
|
||||
</span>
|
||||
))
|
||||
preview.map((e) => {
|
||||
const photo = e.photos?.[0];
|
||||
return (
|
||||
<div key={e.id} className="flex min-w-0 flex-col gap-1">
|
||||
{photo ? (
|
||||
<div className="min-h-0 flex-1 overflow-hidden rounded-[8px] border border-line bg-input">
|
||||
<AuthImage
|
||||
src={photo.url}
|
||||
alt={formatGymEquipment(e, i18n.language)}
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid min-h-0 flex-1 place-items-center rounded-[8px] border border-line bg-input/50 text-dim">
|
||||
<Dumbbell className="h-4 w-4" aria-hidden="true" />
|
||||
</div>
|
||||
)}
|
||||
<span className="truncate text-[0.62rem] font-semibold text-dim">
|
||||
{formatGymEquipment(e, i18n.language)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-2.5 flex items-center justify-between gap-2">
|
||||
@@ -333,8 +335,8 @@ function EquipmentTile({ gym }: { gym: Gym }) {
|
||||
);
|
||||
}
|
||||
|
||||
/* Kafelek Ogłoszeń: najnowsze ogłoszenie (tytuł + data) lub pusty stan + licznik; klik → podstrona. */
|
||||
function AnnouncementsTile({ gymId }: { gymId: string }) {
|
||||
/* Kafelek Ogłoszeń (pełny wiersz): lista 3 najnowszych (tytuł + data) lub pusty stan + licznik; klik → podstrona. */
|
||||
function AnnouncementsTile({ gymId, className }: { gymId: string; className?: string }) {
|
||||
const { t } = useTranslation('gyms');
|
||||
const { data } = useQuery({
|
||||
queryKey: ['admin-announcements', gymId],
|
||||
@@ -344,20 +346,24 @@ function AnnouncementsTile({ gymId }: { gymId: string }) {
|
||||
),
|
||||
});
|
||||
const announcements = data?.announcements ?? [];
|
||||
const latest = announcements[0];
|
||||
return (
|
||||
<Link
|
||||
to={`/gyms/${gymId}/announcements`}
|
||||
className="flex flex-col rounded-2xl border border-line bg-card p-3 transition-colors hover:border-accent/55"
|
||||
className={`flex flex-col rounded-2xl border border-line bg-card p-3 transition-colors hover:border-accent/55 ${className ?? ''}`}
|
||||
>
|
||||
<div className="flex h-20 flex-col justify-center rounded-[10px] border border-line bg-input/40 px-3 py-2">
|
||||
{latest ? (
|
||||
<>
|
||||
<span className="truncate text-[0.85rem] font-bold">{latest.title}</span>
|
||||
<span className="mt-0.5 text-[0.72rem] tabular-nums text-dim">
|
||||
{fmtDateTime(latest.createdAt)}
|
||||
</span>
|
||||
</>
|
||||
<div className="flex min-h-20 flex-1 flex-col justify-center gap-1.5 rounded-[10px] border border-line bg-input/40 px-3 py-2">
|
||||
{announcements.length > 0 ? (
|
||||
announcements.slice(0, 3).map((a) => (
|
||||
<div
|
||||
key={a.id}
|
||||
className="flex min-w-0 items-baseline justify-between gap-3 border-l-2 border-accent/60 pl-2"
|
||||
>
|
||||
<span className="min-w-0 truncate text-[0.85rem] font-semibold">{a.title}</span>
|
||||
<span className="shrink-0 text-[0.72rem] tabular-nums text-dim">
|
||||
{fmtDateTime(a.createdAt)}
|
||||
</span>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<span className="text-[0.8125rem] text-dim">{t('noAnnouncements')}</span>
|
||||
)}
|
||||
@@ -776,7 +782,6 @@ export default function GymDetail() {
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [ownersOpen, setOwnersOpen] = useState(false);
|
||||
const [qrOpen, setQrOpen] = useState(false);
|
||||
const [presenceRange, setPresenceRange] = useState(30);
|
||||
const [confirmOpen, setConfirmOpen] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
@@ -808,7 +813,8 @@ export default function GymDetail() {
|
||||
id: 'manage',
|
||||
label: t('groupManage'),
|
||||
icon: Settings,
|
||||
// na lg+ zwinięta do jednej kontrolki „Zarządzaj” (dropdown) — nie inline
|
||||
// akcje nigdy luzem na pasku: desktop = „Zarządzaj” + dropdown, tablet = zębatka
|
||||
// rozwijająca się do „Zarządzaj”, telefon = zębatka w dolnym pasku z pełną listą
|
||||
collapsed: true,
|
||||
actions: [
|
||||
{ label: t('basicInfo'), onClick: () => setEditOpen(true) },
|
||||
@@ -835,28 +841,6 @@ export default function GymDetail() {
|
||||
title: t('common:nav.gyms'),
|
||||
back: '/gyms',
|
||||
groups,
|
||||
// okres telemetrii bytności (grupa filtrów) — tylko REAL
|
||||
...(gym?.kind === 'REAL'
|
||||
? {
|
||||
filterActive: presenceRange !== 30,
|
||||
filters: [
|
||||
<Select
|
||||
key="presence-range"
|
||||
size="sm"
|
||||
className="h-9 w-40"
|
||||
aria-label={t('presence.rangeAria')}
|
||||
value={String(presenceRange)}
|
||||
onChange={(e) => setPresenceRange(Number(e.target.value))}
|
||||
>
|
||||
{[7, 30, 90].map((d) => (
|
||||
<option key={d} value={String(d)}>
|
||||
{t('presence.rangeDays', { count: d })}
|
||||
</option>
|
||||
))}
|
||||
</Select>,
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
|
||||
if (isLoading) return <Loading />;
|
||||
@@ -876,10 +860,6 @@ export default function GymDetail() {
|
||||
);
|
||||
}
|
||||
|
||||
const ownerNames = (gym.owners ?? []).map(
|
||||
(o) => [o.firstName, o.lastName].filter(Boolean).join(' ') || o.email,
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* HERO: okładka (zdjęcie lub placeholder) + nazwa + chipy metadanych */}
|
||||
@@ -921,10 +901,6 @@ export default function GymDetail() {
|
||||
{gym.name}
|
||||
</h1>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
<span className="inline-flex items-center gap-1.5 rounded-full bg-white/14 px-3 py-1 text-[0.78rem] font-semibold text-white backdrop-blur-sm">
|
||||
<MapPin className="h-3 w-3" />
|
||||
{gym.location || '—'}
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1.5 rounded-full bg-white/14 px-3 py-1 text-[0.78rem] font-semibold text-white backdrop-blur-sm">
|
||||
<Users className="h-3 w-3" />
|
||||
{t('common:counters.members', { count: gym._count?.memberships ?? 0 })}
|
||||
@@ -952,59 +928,24 @@ export default function GymDetail() {
|
||||
{/* GODZINY: cały wiersz bezpośrednio pod hero (jak w apce) */}
|
||||
<HoursBand gym={gym} />
|
||||
|
||||
{/* DWIE KOLUMNY: kafelki sekcji (klik → podstrony) + karta danych */}
|
||||
{/* DWIE KOLUMNY: kafelki sekcji (klik → podstrony) + karta bytności (jak w apce) */}
|
||||
<div className="grid grid-cols-1 items-start gap-4 lg:grid-cols-[1.5fr_1fr]">
|
||||
<div className="flex min-w-0 flex-col gap-4">
|
||||
<div
|
||||
className={`grid grid-cols-1 gap-3 ${
|
||||
gym.kind === 'REAL' ? 'sm:grid-cols-3' : 'sm:grid-cols-2'
|
||||
}`}
|
||||
>
|
||||
{/* wiersz 1: galeria + urządzenia obok siebie; wiersz 2: ogłoszenia na całą szerokość */}
|
||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
{gym.kind === 'REAL' && <GalleryTile gym={gym} />}
|
||||
<EquipmentTile gym={gym} />
|
||||
<AnnouncementsTile gymId={gym.id} />
|
||||
<AnnouncementsTile gymId={gym.id} className="sm:col-span-2" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex min-w-0 flex-col gap-4">
|
||||
{gym.kind === 'REAL' && (
|
||||
<Card>
|
||||
<SectionHeader title={t('presence.title')} description={t('presence.desc')} />
|
||||
<PresenceTelemetry gymId={gym.id} rangeDays={presenceRange} />
|
||||
<SectionHeader title={t('presence.title')} />
|
||||
<PresenceTelemetry gymId={gym.id} rangeDays={30} />
|
||||
</Card>
|
||||
)}
|
||||
<Card>
|
||||
<SectionHeader title={t('data')} />
|
||||
<div className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-[0.85rem]">
|
||||
<span className="text-dim">{t('kindLabel')}</span>
|
||||
<b>{gym.kind === 'REAL' ? t('kindReal') : t('kindVirtual')}</b>
|
||||
<span className="text-dim">{t('privateLabel')}</span>
|
||||
<b>{gym.isPrivate ? t('common:yes') : t('common:no')}</b>
|
||||
<span className="text-dim">{t('capacityLabel')}</span>
|
||||
<b className="font-display tabular-nums">{gym.capacity ?? '—'}</b>
|
||||
{gym.addressLine1 || gym.postalCode || gym.city ? (
|
||||
<>
|
||||
<span className="text-dim">{t('streetLabel')}</span>
|
||||
<b>{[gym.addressLine1, gym.addressLine2].filter(Boolean).join(', ') || '—'}</b>
|
||||
<span className="text-dim">{t('cityCodeLabel')}</span>
|
||||
<b>{[gym.postalCode, gym.city].filter(Boolean).join(' ') || '—'}</b>
|
||||
{gym.countryCode && gym.countryCode !== 'PL' && (
|
||||
<>
|
||||
<span className="text-dim">{t('countryLabel')}</span>
|
||||
<b>{gym.countryCode}</b>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span className="text-dim">{t('locationLabel')}</span>
|
||||
<b>{gym.location ?? '—'}</b>
|
||||
</>
|
||||
)}
|
||||
<span className="text-dim">{t('ownersLabel')}</span>
|
||||
<b>{ownerNames.length > 0 ? ownerNames.join(', ') : '—'}</b>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -318,6 +318,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Selecty w stylu aplikacji: natywna strzałka OS przylega do prawej ścianki —
|
||||
własna (appearance:none + chevron w tle) odsunięta od krawędzi; poza
|
||||
warstwami Tailwinda, więc padding-right wygrywa z px-3 komponentu */
|
||||
select[data-slot='select'] {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
padding-right: 2.25rem;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9b0ba' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 0.65rem center;
|
||||
background-size: 1rem 1rem;
|
||||
}
|
||||
|
||||
.light select[data-slot='select'] {
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6772' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
|
||||
}
|
||||
|
||||
/* Checkbox w stylu aplikacji: ciemne pole z krawędzią; po zaznaczeniu
|
||||
wypełnienie akcentem i ciemny „ptaszek" (look kontrolowany przez design,
|
||||
nie przez natywne widgety OS) */
|
||||
|
||||
Reference in New Issue
Block a user