Silownie: godziny otwarcia w calym wierszu pod hero (pasek tygodnia + wyjatki gdy sa) zamiast karty w kolumnie bocznej
This commit is contained in:
@@ -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 (
|
||||
<div className="flex flex-col gap-1">
|
||||
{availability.map((day, i) => (
|
||||
<Card className="mb-5 p-4 sm:p-5">
|
||||
{hasHours && (
|
||||
<>
|
||||
<SectionHeader title={t('detail.hoursTitle')} />
|
||||
<div className="grid grid-cols-7 gap-1 sm:gap-1.5">
|
||||
{availability.map((day, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className={`min-w-0 rounded-[10px] px-1 py-2 text-center sm:px-2 ${
|
||||
day ? 'bg-accent/10' : 'bg-input/50'
|
||||
} ${i === todayIdx ? 'outline outline-1 outline-accent/50' : ''}`}
|
||||
>
|
||||
<div
|
||||
className={`truncate 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 sm:block">{dayFull(i)}</span>
|
||||
</div>
|
||||
<div
|
||||
className={`truncate 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('hours.closed')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{exceptions.length > 0 && (
|
||||
<div
|
||||
key={i}
|
||||
className={`flex items-center justify-between gap-3 rounded-[10px] px-3 py-1.5 text-[0.85rem] ${
|
||||
i === todayIdx ? 'bg-accent/10 outline outline-1 outline-accent/40' : ''
|
||||
className={`flex flex-wrap items-center gap-2 ${
|
||||
hasHours ? 'mt-4 border-t border-line pt-3.5' : ''
|
||||
}`}
|
||||
>
|
||||
<span className={`flex items-center gap-2 ${day ? 'font-semibold' : 'text-dim/70'}`}>
|
||||
{dayFull(i)}
|
||||
{i === todayIdx && (
|
||||
<span className="rounded-full bg-accent px-2 py-0.5 text-[0.62rem] font-extrabold uppercase tracking-wide text-accent-ink">
|
||||
{t('common:fmt.today')}
|
||||
<span className="text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
|
||||
{t('detail.exceptionsLabel')}
|
||||
</span>
|
||||
{exceptions.map((ex) => (
|
||||
<span
|
||||
key={ex.id}
|
||||
className="inline-flex items-center gap-1.5 rounded-[10px] border border-dashed border-danger/40 bg-danger/7 px-2.5 py-1 text-[0.78rem]"
|
||||
>
|
||||
<CalendarX className="h-3 w-3 shrink-0 text-danger" />
|
||||
<b className="tabular-nums">{fmtDate(ex.date)}</b>
|
||||
<span className="text-dim">
|
||||
{ex.availability
|
||||
? `${ex.availability.start}–${ex.availability.end}`
|
||||
: t('hours.closed')}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className={`tabular-nums ${day ? 'font-semibold' : 'text-dim/60'}`}>
|
||||
{fmt(day)}
|
||||
</span>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -701,6 +753,9 @@ export default function GymDetail() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* GODZINY: cały wiersz bezpośrednio pod hero (informacja kluczowa) */}
|
||||
<HoursBand gym={gym} />
|
||||
|
||||
{removeError && (
|
||||
<div className="mb-4">
|
||||
<ErrorText>{removeError}</ErrorText>
|
||||
@@ -726,14 +781,6 @@ export default function GymDetail() {
|
||||
</div>
|
||||
|
||||
<div className="flex min-w-0 flex-col gap-4">
|
||||
<Card>
|
||||
<SectionHeader title={t('detail.hoursTitle')} />
|
||||
<HoursList gym={gym} />
|
||||
<div className="mt-4 mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
|
||||
{t('detail.exceptionsLabel')}
|
||||
</div>
|
||||
<ExceptionsList gymId={gym.id} canManage={isOwner} />
|
||||
</Card>
|
||||
<Card>
|
||||
<SectionHeader title={t('detail.dataTitle')} />
|
||||
<div className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-[0.85rem]">
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user