diff --git a/app/src/pages/gyms/GymDetail.tsx b/app/src/pages/gyms/GymDetail.tsx index b6069a0..9eb0b98 100644 --- a/app/src/pages/gyms/GymDetail.tsx +++ b/app/src/pages/gyms/GymDetail.tsx @@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next'; import { useQueryClient } from '@tanstack/react-query'; import { ArrowLeft, + CalendarX, Dumbbell, Image as ImageIcon, Megaphone, @@ -53,43 +54,94 @@ import { useToast } from '../../components/toast'; import { Avatar } from '../../components/Avatar'; import { AuthImage } from '../../components/AuthImage'; import { useTopbar, type TopbarAction, type TopbarCustomGroup } from '../../topbar'; -import { normalizeAvailability, TIME_SLOTS, dayFull } from '../../lib/availability'; +import { + normalizeAvailability, + TIME_SLOTS, + dayFull, + dayShort, + formatDayRange, +} from '../../lib/availability'; import ClaimModal from '../../components/gyms/ClaimModal'; import InviteGymModal from '../../components/gyms/InviteGymModal'; import GymGallery from '../../components/gyms/GymGallery'; import GymQrModal from '../../components/gyms/GymQrModal'; import { EquipmentSection, GymEditForm } from './GymSections'; -/* Lista godzin otwarcia: wiersz na dzień (czytelna w wąskiej kolumnie), „dziś” wyróżnione. */ -function HoursList({ gym }: { gym: Gym }) { +/* Godziny otwarcia w całym wierszu pod hero (informacja kluczowa — nie w bocznej kolumnie). + Pasek tygodnia wzorowany na kartach z /gyms: siedem dni, „dziś” wyróżnione, dni otwarte + akcentowo. Rozszerzony o pełne nazwy/godziny (tu mamy całą szerokość) i zwartą formę + na telefonie. Wyjątki harmonogramu pod paskiem, tylko gdy istnieją (ich edycja: modal Informacje). */ +function HoursBand({ gym }: { gym: Gym }) { const { t } = useTranslation('gyms'); const availability = normalizeAvailability(gym.availability); const todayIdx = (new Date().getDay() + 6) % 7; - const fmt = (r: { start: string; end: string } | null) => - r ? `${r.start}–${r.end}` : t('hours.closed'); + const { data } = useGymExceptions(gym.id); + const exceptions: GymException[] = data?.exceptions ?? []; + const hasHours = availability.some(Boolean); + if (!hasHours && exceptions.length === 0) return null; return ( -
- {availability.map((day, i) => ( + + {hasHours && ( + <> + +
+ {availability.map((day, i) => ( +
+
+ {/* telefon: skrót dnia + zwarty zakres; desktop: pełna nazwa + pełne godziny */} + {dayShort(i)} + {dayFull(i)} +
+
+ {day ? formatDayRange(day) : '—'} + + {day ? `${day.start}–${day.end}` : t('hours.closed')} + +
+
+ ))} +
+ + )} + {exceptions.length > 0 && (
- - {dayFull(i)} - {i === todayIdx && ( - - {t('common:fmt.today')} + + {t('detail.exceptionsLabel')} + + {exceptions.map((ex) => ( + + + {fmtDate(ex.date)} + + {ex.availability + ? `${ex.availability.start}–${ex.availability.end}` + : t('hours.closed')} - )} - - - {fmt(day)} - + + ))}
- ))} -
+ )} + ); } @@ -701,6 +753,9 @@ export default function GymDetail() { + {/* GODZINY: cały wiersz bezpośrednio pod hero (informacja kluczowa) */} + + {removeError && (
{removeError} @@ -726,14 +781,6 @@ export default function GymDetail() {
- - - -
- {t('detail.exceptionsLabel')} -
- -
diff --git a/app/test/e2e/gyms.spec.ts b/app/test/e2e/gyms.spec.ts index 9488fea..1961c68 100644 --- a/app/test/e2e/gyms.spec.ts +++ b/app/test/e2e/gyms.spec.ts @@ -101,7 +101,12 @@ test('właściciel ma menu „Siłownie" i zarządza swoją siłownią', async ( // open the gym detail await page.getByRole('link', { name: 'Żelazna Świątynia' }).click(); await expect(page.getByRole('heading', { name: 'Urządzenia' })).toBeVisible(); + // pasek godzin w całym wierszu pod hero: godziny siłowni + wyjątek harmonogramu + await expect(page.getByText('06:00–22:00')).toBeVisible(); await expect(page.getByText('Wyjątki', { exact: true })).toBeVisible(); + await expect(page.getByText('10:00–14:00')).toBeVisible(); + // godziny mają JEDNO miejsce — nie dublują się w kolumnie bocznej + await expect(page.getByText('06:00–22:00')).toHaveCount(1); // karta „Dane" pokazuje strukturalny adres siłowni await expect(page.getByText('Mokotowska 12A')).toBeVisible(); await expect(page.getByText('00-900 Warszawa')).toBeVisible(); diff --git a/app/test/e2e/mock-api.ts b/app/test/e2e/mock-api.ts index 6f4c33a..ec4bb6f 100644 --- a/app/test/e2e/mock-api.ts +++ b/app/test/e2e/mock-api.ts @@ -1298,6 +1298,23 @@ export function mockApi(page: Page, opts: MockApiOptions = {}) { }), }); } + // GET: własna siłownia ma jeden wyjątek (pokrywa pasek godzin w widoku detalu) + if (req.url().includes(`/gyms/${TEST_GYM_OWNED.id}/exceptions`)) { + return route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({ + exceptions: [ + { + id: 'ex-existing', + gymId: TEST_GYM_OWNED.id, + date: '2026-12-24', + availability: { start: '10:00', end: '14:00' }, + }, + ], + }), + }); + } return route.fulfill({ status: 200, contentType: 'application/json',