- {gym.equipment.map((e) => {
- const hasPhotos = (e.photos?.length ?? 0) > 0;
- const content = (
- <>
- {hasPhotos ? (
+
+
+ {preview.length === 0 ? (
+
+
+
+ ) : (
+ preview.map((e) => {
+ const photo = e.photos?.[0];
+ return photo ? (
+
- ) : (
-
- )}
-
{formatGymEquipment(e, i18n.language)}
- >
- );
- return hasPhotos ? (
-
- ) : (
-
- {content}
-
- );
- })}
+
+ ) : (
+
+
+
+ );
+ })
+ )}
-
setPreview(null)}
- title={
- preview
- ? t('detail.photosAria', { name: localizedName(preview.equipment, i18n.language) })
- : ''
- }
- >
-
- {photos.map((p) => (
-
- ))}
-
-
- >
+
+
+ {t('detail.equipmentTitle')}
+
+
+ {t('common:counters.devices', { count: gym.equipment.length })}
+
+
+
+ );
+}
+
+/* Kafelek Ogłoszeń: najnowsze ogłoszenie (tytuł + data) lub pusty stan + licznik; klik → podstrona. */
+function AnnouncementsTile({ gymId }: { gymId: string }) {
+ const { t } = useTranslation('gyms');
+ const { data } = useGymAnnouncements(gymId);
+ const announcements = data?.announcements ?? [];
+ const latest = announcements[0];
+ return (
+
+
+ {latest ? (
+ <>
+ {latest.title}
+
+ {fmtDateTime(latest.createdAt)}
+
+ >
+ ) : (
+ {t('announcements.empty')}
+ )}
+
+
+
+ {t('detail.groupAnnouncements')}
+
+
+ {t('detail.tileAnnouncementsCount', { count: announcements.length })}
+
+
+
);
}
@@ -451,7 +458,6 @@ export default function GymDetail() {
const { data: presenceData } = useActivePresence();
const gym = data?.gym;
const presence = presenceData?.presence ?? null;
- const canManage = (data?.isAdmin ?? false) || (data?.roles ?? []).includes('OWNER');
const isOwner = (data?.roles ?? []).includes('OWNER');
const claim = (claimsData?.claims ?? []).find((c) => c.gymId === id) ?? null;
@@ -462,9 +468,6 @@ export default function GymDetail() {
const [claimOpen, setClaimOpen] = useState(false);
const [claimBusy, setClaimBusy] = useState(false);
const [editOpen, setEditOpen] = useState(false);
- const [galleryOpen, setGalleryOpen] = useState(false);
- const [equipmentOpen, setEquipmentOpen] = useState(false);
- const [announcementsOpen, setAnnouncementsOpen] = useState(false);
const [qrOpen, setQrOpen] = useState(false);
const [presenceBusy, setPresenceBusy] = useState(false);
@@ -535,94 +538,61 @@ export default function GymDetail() {
}
};
- // Operacje właściciela pogrupowane tematycznie w menu kontekstowym (topbar).
+ // Operacje właściciela: JEDNA grupa „Zarządzaj” (topbar). Pozycje Galeria/Urządzenia/
+ // Ogłoszenia nawigują na podstrony (świadome dublowanie z kafelkami — decyzja product);
+ // Informacje/QR/Zaproszenia/Usuń otwierają modale na tej stronie.
const groups: TopbarCustomGroup[] | undefined =
gym && isOwner
? [
{
- id: 'edit',
- label: t('detail.groupEdit'),
- icon: Pencil,
- actions: [{ label: t('detail.actionInfo'), onClick: () => setEditOpen(true) }],
- },
- ...(gym.kind === 'REAL'
- ? [
- {
- id: 'gallery',
- label: t('detail.groupGallery'),
- icon: ImageIcon,
- actions: [
- { label: t('detail.groupGallery'), onClick: () => setGalleryOpen(true) },
- ],
- } as TopbarCustomGroup,
- ]
- : []),
- ...(gym.kind === 'REAL'
- ? [
- {
- id: 'qr',
- label: tp('qr.group'),
- icon: QrCode,
- actions: [{ label: tp('qr.action'), onClick: () => setQrOpen(true) }],
- } as TopbarCustomGroup,
- ]
- : []),
- {
- id: 'equipment',
- label: t('detail.groupEquipment'),
- icon: Wrench,
- actions: [{ label: t('detail.groupEquipment'), onClick: () => setEquipmentOpen(true) }],
- },
- {
- id: 'announcements',
- label: t('detail.groupAnnouncements'),
- icon: Megaphone,
+ id: 'manage',
+ label: t('detail.groupManage'),
+ icon: Settings,
actions: [
- { label: t('detail.groupAnnouncements'), onClick: () => setAnnouncementsOpen(true) },
+ { label: t('detail.actionInfo'), onClick: () => setEditOpen(true) },
+ ...(gym.kind === 'REAL'
+ ? [
+ {
+ label: t('detail.groupGallery'),
+ to: `/gyms/${gym.id}/gallery`,
+ },
+ { label: tp('qr.action'), onClick: () => setQrOpen(true) },
+ ]
+ : []),
+ { label: t('detail.groupEquipment'), to: `/gyms/${gym.id}/equipment` },
+ { label: t('detail.groupAnnouncements'), to: `/gyms/${gym.id}/announcements` },
+ ...(gym.kind === 'VIRTUAL' && gym.isPrivate
+ ? [{ label: t('detail.actionInvite'), onClick: () => setInviteOpen(true) }]
+ : []),
+ {
+ label: t('detail.actionDelete'),
+ variant: 'danger',
+ onClick: () => setConfirmOpen(true),
+ },
],
},
- ...(gym.kind === 'VIRTUAL' && gym.isPrivate
- ? [
- {
- id: 'invite',
- label: t('detail.groupInvites'),
- icon: UserPlus,
- actions: [
- { label: t('detail.actionInvite'), onClick: () => setInviteOpen(true) },
- ],
- } as TopbarCustomGroup,
- ]
- : []),
]
: undefined;
+ // Spoza grupy: claim/wycofanie wniosku (VIRTUAL) — reszta operacji właściciela w „Zarządzaj”.
const ownerActions: TopbarAction[] | undefined =
- gym && isOwner
- ? [
- ...(gym.kind === 'VIRTUAL'
- ? claim
- ? ([
- {
- label: t('detail.actionWithdrawClaim'),
- variant: 'secondary',
- disabled: claimBusy,
- onClick: () => void withdrawClaim(),
- },
- ] as TopbarAction[])
- : ([
- {
- label: t('detail.actionClaimVerify'),
- variant: 'secondary',
- onClick: () => setClaimOpen(true),
- },
- ] as TopbarAction[])
- : []),
- {
- label: t('detail.actionDelete'),
- variant: 'danger',
- onClick: () => setConfirmOpen(true),
- },
- ]
+ gym && isOwner && gym.kind === 'VIRTUAL'
+ ? claim
+ ? [
+ {
+ label: t('detail.actionWithdrawClaim'),
+ variant: 'secondary',
+ disabled: claimBusy,
+ onClick: () => void withdrawClaim(),
+ },
+ ]
+ : [
+ {
+ label: t('detail.actionClaimVerify'),
+ variant: 'secondary',
+ onClick: () => setClaimOpen(true),
+ },
+ ]
: undefined;
// Meldunek bytności (REAL) — akcje dla każdego użytkownika siłowni.
@@ -769,22 +739,18 @@ export default function GymDetail() {
)}
- {/* DWIE KOLUMNY */}
+ {/* DWIE KOLUMNY: kafelki sekcji (klik → podstrony) + karta danych */}