diff --git a/admin/src/pages/gyms/GymDetail.tsx b/admin/src/pages/gyms/GymDetail.tsx
index 0d64ac9..faf0ce8 100644
--- a/admin/src/pages/gyms/GymDetail.tsx
+++ b/admin/src/pages/gyms/GymDetail.tsx
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { useNavigate, useParams } from 'react-router-dom';
import { useQuery, useQueryClient } from '@tanstack/react-query';
-import { ImagePlus, Star, X } from 'lucide-react';
+import { Dumbbell, ImagePlus, MapPin, Star, Users, X } from 'lucide-react';
import { useTopbar } from '../../topbar';
import { api } from '../../api/client';
import { AuthImage } from '../../components/AuthImage';
@@ -9,28 +9,49 @@ import type { Equipment, Gym, GymException, GymPhoto } from '../../api/types';
import { formatEquipmentSpec, formatGymEquipment } from '../../lib/equipment';
import {
BackButton,
- Badge,
Button,
Card,
Chip,
ErrorText,
Field,
Input,
- ListRow,
Loading,
- PageHeader,
SectionHeader,
Select,
SuccessText,
} from '../../components/ui';
import { AvailabilityEditor } from '../../components/AvailabilityEditor';
-import { formatAvailability, normalizeAvailability, TIME_SLOTS } from '../../lib/availability';
+import { normalizeAvailability, TIME_SLOTS } from '../../lib/availability';
-function InfoItem({ label, children }: { label: string; children: React.ReactNode }) {
+/* Lista godzin otwarcia: wiersz na dzień (czytelna w wąskiej kolumnie), „dziś” wyróżnione. */
+function HoursList({ gym }: { gym: Gym }) {
+ const availability = normalizeAvailability(gym.availability);
+ const todayIdx = (new Date().getDay() + 6) % 7;
+ const DOWS = ['Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela'];
+ const fmt = (r: { start: string; end: string } | null) =>
+ r ? `${r.start}–${r.end}` : 'zamknięte';
return (
-
-
{label}
-
{children}
+
+ {availability.map((day, i) => (
+
+
+ {DOWS[i]}
+ {i === todayIdx && (
+
+ dziś
+
+ )}
+
+
+ {fmt(day)}
+
+
+ ))}
);
}
@@ -165,77 +186,119 @@ export default function GymDetail() {
return (
<>
-
-
- {gym.kind === 'VIRTUAL' ? 'Wirtualna' : 'Realna'}
-
- {gym.isPrivate && Prywatna}
- {gym._count?.memberships ?? 0} członk.
- >
- }
- actions={}
- />
-
- {gym.coverPhoto && (
-
+ {/* HERO: okładka (zdjęcie lub placeholder) + nazwa + chipy metadanych */}
+
+ {gym.coverPhoto ? (
-
-
-
- {gym.name}
-
-
- {gym._count?.memberships ?? 0} członków
-
-
-
- )}
-
- {gym.kind === 'REAL' && (
-
- {}} />
-
- )}
-
-
-
-
- {gym.name}
- {gym.location || '—'}
- {formatAvailability(gym.availability) || '—'}
- {gym.capacity ?? '—'}
-
-
-
-
-
- {
- void queryClient.invalidateQueries({ queryKey: ['gyms'] });
- void queryClient.invalidateQueries({ queryKey: ['gym', gym.id] });
- }}
+ ) : (
+ <>
+
+
+
+ >
+ )}
+
-
+
+
+
+ {gym.name}
+
+
+
+
+ {gym.location || '—'}
+
+
+
+ {gym._count?.memberships ?? 0} członków
+
+
+
+ {gym.equipment.length} urządzeń
+
+ {gym.kind === 'VIRTUAL' && (
+
+ Wirtualna
+
+ )}
+ {gym.isPrivate && (
+
+ Prywatna
+
+ )}
+
+
+
+
+
-
-
-
+ {/* DWIE KOLUMNY */}
+
+
+ {gym.kind === 'REAL' && (
+
+ {}} />
+
+ )}
+
+
+
+
+
+ {
+ void queryClient.invalidateQueries({ queryKey: ['gyms'] });
+ void queryClient.invalidateQueries({ queryKey: ['gym', gym.id] });
+ }}
+ />
+
+
-
-
-
+
+
+
+
+
+ Wyjątki
+
+
+
+
+
+
+ Rodzaj
+ {gym.kind === 'REAL' ? 'Realna' : 'Wirtualna'}
+ Prywatna
+ {gym.isPrivate ? 'tak' : 'nie'}
+ Pojemność
+ {gym.capacity ?? '—'}
+
+
+
+
>
);
}
@@ -377,7 +440,7 @@ function EquipmentSection({ gym }: { gym: Gym }) {
className="w-20"
aria-label="Ilość"
/>
-
@@ -387,7 +450,8 @@ function EquipmentSection({ gym }: { gym: Gym }) {
);
}
-function ExceptionsSection({ gymId }: { gymId: string }) {
+/* Wyjątki: kompaktowy komposer (data + tryb + godziny) i lista w stylu aplikacji. */
+function ExceptionsBlock({ gymId }: { gymId: string }) {
const queryClient = useQueryClient();
const { data, isLoading } = useQuery({
queryKey: ['gym-exceptions', gymId],
@@ -402,8 +466,7 @@ function ExceptionsSection({ gymId }: { gymId: string }) {
const [error, setError] = useState('');
const [busy, setBusy] = useState(false);
- const add = async (e: React.FormEvent) => {
- e.preventDefault();
+ const add = async () => {
setError('');
setBusy(true);
try {
@@ -431,91 +494,121 @@ function ExceptionsSection({ gymId }: { gymId: string }) {
return (
<>
-
+
+
+ Dodaj wyjątek — data i tryb dnia
+
+ {/* wiersz 1: data + tryb; na wąskich ekranach każde przechodzi na pełną szerokość */}
+
+
setDate(e.target.value)}
+ aria-label="Data wyjątku"
+ className="w-full min-w-0 sm:w-44 sm:flex-none"
+ required
+ />
+
+ setClosed(true)}
+ className={`h-full flex-1 whitespace-nowrap rounded-[10px] px-3 text-[0.8125rem] font-semibold transition-colors sm:flex-none ${
+ closed ? 'bg-accent text-accent-ink' : 'text-dim hover:text-ink'
+ }`}
+ >
+ Zamknięte
+
+ setClosed(false)}
+ className={`h-full flex-1 whitespace-nowrap rounded-[10px] px-3 text-[0.8125rem] font-semibold transition-colors sm:flex-none ${
+ !closed ? 'bg-accent text-accent-ink' : 'text-dim hover:text-ink'
+ }`}
+ >
+ Inne godziny
+
+
+
+ {/* wiersz 2: godziny + akcja; selecty dzielą miejsce po równo, nigdy się nie łamią */}
+ {!closed && (
+
+
+
+ void add()}
+ disabled={busy || !date}
+ className="w-full sm:ml-auto sm:w-auto"
+ >
+ {busy ? 'Dodawanie…' : 'Dodaj'}
+
+
+ )}
+ {closed && (
+
+ void add()}
+ disabled={busy || !date}
+ className="w-full sm:w-auto"
+ >
+ {busy ? 'Dodawanie…' : 'Dodaj'}
+
+
+ )}
+ {error &&
{error}}
+
+
{isLoading ? (
) : (
-
- {exceptions.length === 0 && (
-
Brak wyjątków.
- )}
- {exceptions.map((ex) => (
-
remove(ex.id)}>
+ exceptions.length > 0 && (
+
+ {exceptions.map((ex) => (
+
+
+ {new Date(ex.date).toLocaleDateString('pl-PL')}
+
+
+ {ex.availability
+ ? `${ex.availability.start}–${ex.availability.end}`
+ : 'zamknięte'}
+
+ void remove(ex.id)}>
Usuń
- }
- />
- ))}
-
+
+ ))}
+
+ )
)}
-
>
);
}
diff --git a/admin/test/GymDetail.test.tsx b/admin/test/GymDetail.test.tsx
index 0598d2b..1242e00 100644
--- a/admin/test/GymDetail.test.tsx
+++ b/admin/test/GymDetail.test.tsx
@@ -83,10 +83,12 @@ describe('admin GymDetail page', () => {
renderGymDetail();
expect(await screen.findByRole('heading', { name: 'Gym A' })).toBeInTheDocument();
expect(screen.getByText('Warszawa')).toBeInTheDocument();
- expect(screen.getByText('12 członk.')).toBeInTheDocument();
+ expect(screen.getByText('12 członków')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Zapisz' })).toBeInTheDocument();
// „Usuń siłownię" jest w top menu (menu kontekstowe) — sprawdzamy zarejestrowaną konfigurację
- expect(useTopbarStore.getState().config?.actions?.some((a) => a.label === 'Usuń siłownię')).toBe(true);
+ expect(
+ useTopbarStore.getState().config?.actions?.some((a) => a.label === 'Usuń siłownię'),
+ ).toBe(true);
});
it('adding already-added equipment increases its quantity via PATCH', async () => {
@@ -107,11 +109,13 @@ describe('admin GymDetail page', () => {
expect(await screen.findByRole('heading', { name: 'Gym A' })).toBeInTheDocument();
// select pokazuje cały katalog ze specyfikacją — sprzęt już dodany jest oznaczony bieżącą ilością
- expect(await screen.findByRole('option', { name: 'hantle · 2.5–25 kg (2 szt.)' })).toBeInTheDocument();
+ expect(
+ await screen.findByRole('option', { name: 'hantle · 2.5–25 kg (2 szt.)' }),
+ ).toBeInTheDocument();
fireEvent.change(screen.getByRole('combobox', { name: 'Dodaj urządzenie' }), {
target: { value: 'eq-2' },
});
- fireEvent.click(screen.getByRole('button', { name: 'Dodaj' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Dodaj urządzenie' }));
await waitFor(() => expect(patchBody).toEqual({ quantity: 3 }));
});
});
diff --git a/admin/test/e2e/admin.spec.ts b/admin/test/e2e/admin.spec.ts
index aff8ed6..6271e48 100644
--- a/admin/test/e2e/admin.spec.ts
+++ b/admin/test/e2e/admin.spec.ts
@@ -28,8 +28,8 @@ test('dodawanie już dodanego sprzętu zwiększa jego ilość', async ({ page })
await expect(page.getByText('Dywan ×3')).toBeVisible();
// select pokazuje cały katalog — ponowne dodanie zwiększa ilość
- await page.getByLabel('Dodaj urządzenie').selectOption('eq-2');
- await page.getByRole('button', { name: 'Dodaj', exact: true }).click();
+ await page.getByRole('combobox', { name: 'Dodaj urządzenie' }).selectOption('eq-2');
+ await page.getByRole('button', { name: 'Dodaj urządzenie' }).click();
await expect(page.getByText('Dywan ×4')).toBeVisible();
});