I18n: siłownie, komunikator, zaproszenia i aktualności (partia 4) - Gyms/GymDetail/GymSections + modale (claim/create/gallery/invite/join), namespace gyms rozbudowany (upload/spec/sections/equipment/hours/detail/exceptions/announcements/invites/page); Messages/MessageThread/ThreadContextCard/MessageAttachmentCard (namespace messages); Invitations (nowy namespace invitations w i18n); Announcements + FeedItemRow (namespace feed, etykiety typów przez i18n.t); common: errorPrefix/yes/no/edit/saving + counters.devices; lib/equipment przez i18n.t, usuniety martwy EQUIPMENT_KIND_LABELS

This commit is contained in:
tisachi
2026-10-17 15:00:55 +02:00
parent 6944db8be8
commit bcd48f9962
27 changed files with 1182 additions and 418 deletions

View File

@@ -9,6 +9,7 @@ import {
} from 'lucide-react';
import { useQueryClient } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';
import i18n from '../i18n';
import { markFeedItemRead } from '../api/queries';
import type { FeedItem } from '../api/types';
import { timeAgo } from '../lib/format';
@@ -31,20 +32,20 @@ export function feedItemIcon(item: FeedItem): { Icon: LucideIcon; label: string
if (item.source === 'notification') {
switch (item.type) {
case 'PLAN_READY':
return { Icon: Dumbbell, label: 'Plan od trenera' };
return { Icon: Dumbbell, label: i18n.t('feed:itemType.planFromTrainer') };
case 'PLAN_SHARED':
return { Icon: Share2, label: 'Udostępniony plan' };
return { Icon: Share2, label: i18n.t('feed:itemType.sharedPlan') };
case 'GYM_DELETED':
return { Icon: Building2, label: 'Usunięta siłownia' };
return { Icon: Building2, label: i18n.t('feed:itemType.gymDeleted') };
}
}
switch (item.kind) {
case 'MANUAL':
return { Icon: Megaphone, label: item.gymName ?? 'Ogłoszenie' };
return { Icon: Megaphone, label: item.gymName ?? i18n.t('feed:itemType.announcement') };
case 'HOURS_CHANGE':
return { Icon: Clock, label: item.gymName ?? 'Zmiana godzin' };
return { Icon: Clock, label: item.gymName ?? i18n.t('feed:itemType.hoursChange') };
case 'EXCEPTION':
return { Icon: CalendarX, label: item.gymName ?? 'Wyjątek w godzinach' };
return { Icon: CalendarX, label: item.gymName ?? i18n.t('feed:itemType.exception') };
}
}

View File

@@ -16,6 +16,7 @@ export default function MessageAttachmentCard({
onOpenSession?: (sessionId: string) => void;
}) {
const { i18n } = useTranslation();
const { t } = useTranslation('messages');
return (
<button
type="button"
@@ -26,7 +27,9 @@ export default function MessageAttachmentCard({
<div className="mb-1.5 flex items-center gap-2">
<Dumbbell className="h-4 w-4 shrink-0 text-accent-text" />
<span className="truncate text-[0.875rem] font-semibold">
{attachment.exercise ? localizedName(attachment.exercise, i18n.language) : 'Wynik sesji'}
{attachment.exercise
? localizedName(attachment.exercise, i18n.language)
: t('attachSessionResult')}
</span>
<span className="text-dim text-[0.75rem] ml-auto shrink-0">
{fmtDate(attachment.sessionDate)} · {attachment.plan}
@@ -36,8 +39,10 @@ export default function MessageAttachmentCard({
<div className="space-y-1">
{attachment.exercise.sets.map((s) => (
<div key={s.index} className="flex flex-wrap gap-x-3 text-[0.875rem]">
<span className="text-dim">Seria {s.index + 1}</span>
<span className="font-semibold">{s.reps ?? '—'} powt.</span>
<span className="text-dim">{t('attachSet', { n: s.index + 1 })}</span>
<span className="font-semibold">
{s.reps ?? '—'} {t('plans:exec.repsUnit')}
</span>
<span>RIR {s.rir ?? '—'}</span>
{s.planned?.loadKg != null && <span className="text-dim">{s.planned.loadKg} kg</span>}
</div>
@@ -49,13 +54,13 @@ export default function MessageAttachmentCard({
<span key={e.name}>
<strong>{localizedName(e, i18n.language)}</strong>{' '}
<span className="text-dim">
{e.setsDone}/{e.setsTotal} serii
{t('attachSetsFrac', { done: e.setsDone, total: e.setsTotal })}
</span>
</span>
))}
</div>
)}
<span className="mt-1.5 block text-[0.75rem] text-dim">Kliknij, aby otworzyć historię</span>
<span className="mt-1.5 block text-[0.75rem] text-dim">{t('attachOpenHint')}</span>
</button>
);
}

View File

@@ -1,4 +1,5 @@
import { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useQueryClient } from '@tanstack/react-query';
import { createGymClaim, useMe, type GymClaimInput } from '../../api/queries';
import type { Availability, GymClaim } from '../../api/types';
@@ -43,6 +44,7 @@ export default function ClaimModal({
}) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const { data: me } = useMe();
const meUser = me?.user;
@@ -88,17 +90,17 @@ export default function ClaimModal({
const onFilesChange = (list: FileList | null) => {
const picked = Array.from(list ?? []);
if (picked.length > MAX_FILES) {
setFileError(`Maksymalnie ${MAX_FILES} plików`);
setFileError(t('upload.maxFiles', { count: MAX_FILES }));
return;
}
const badType = picked.find((f) => !ALLOWED_MIME.includes(f.type));
if (badType) {
setFileError(`Nieobsługiwany typ pliku: ${badType.name} (dozwolone: JPG, PNG, PDF)`);
setFileError(t('upload.badType', { name: badType.name, types: 'JPG, PNG, PDF' }));
return;
}
const tooBig = picked.find((f) => f.size > MAX_FILE_BYTES);
if (tooBig) {
setFileError(`Plik ${tooBig.name} jest większy niż 5 MB`);
setFileError(t('upload.tooBig', { name: tooBig.name }));
return;
}
setFileError(null);
@@ -138,7 +140,7 @@ export default function ClaimModal({
queryClient.invalidateQueries({ queryKey: ['gyms', 'claims'] }),
queryClient.invalidateQueries({ queryKey: ['gyms', 'virtual'] }),
]);
push('Wniosek złożony', 'success');
push(t('claim.toastOk'), 'success');
} catch (err) {
push((err as Error).message, 'error');
} finally {
@@ -150,108 +152,106 @@ export default function ClaimModal({
<Modal
open={open}
onClose={onClose}
title={isVerification ? `Wniosek o weryfikację: ${gym!.name}` : 'Nowy wniosek o siłownię'}
title={isVerification ? t('claim.titleVerify', { name: gym!.name }) : t('claim.titleNew')}
>
<form onSubmit={submit}>
{!isVerification && (
<>
<Field label="Nazwa siłowni">
<Field label={t('claim.gymNameLabel')}>
<Input
value={form.gymName}
onChange={(e) => setForm({ ...form, gymName: e.target.value })}
placeholder="np. Żelazna Świątynia"
placeholder={t('claim.gymNamePh')}
required
/>
</Field>
<Field label="Lokalizacja">
<Field label={t('claim.locationLabel')}>
<Input
value={form.gymLocation}
onChange={(e) => setForm({ ...form, gymLocation: e.target.value })}
placeholder="np. ul. Długa 5, Warszawa"
placeholder={t('claim.locationPh')}
required
/>
</Field>
<Field label="Dostępność">
<Field label={t('claim.availabilityLabel')}>
<AvailabilityEditor
value={form.availability}
onChange={(availability) => setForm({ ...form, availability })}
/>
</Field>
<Field label="Pojemność (osób)">
<Field label={t('claim.capacityLabel')}>
<Input
type="number"
value={form.capacity}
onChange={(e) => setForm({ ...form, capacity: e.target.value })}
placeholder="np. 50"
placeholder={t('claim.capacityPh')}
/>
</Field>
</>
)}
<Field label="Opis (dlaczego ta siłownia zasługuje na weryfikację / utworzenie)">
<Field label={t('claim.descLabel')}>
<Textarea
value={form.description}
onChange={(e) => setForm({ ...form, description: e.target.value })}
placeholder="Krótki opis"
placeholder={t('claim.descPh')}
rows={3}
required
/>
</Field>
{isVerification && (
<Field label="Pełny adres siłowni (opcjonalnie — nadpisze lokalizację)">
<Field label={t('claim.addressLabel')}>
<Input
value={form.address}
onChange={(e) => setForm({ ...form, address: e.target.value })}
placeholder="np. ul. Długa 5, 00-050 Warszawa"
placeholder={t('claim.addressPh')}
/>
</Field>
)}
<div className="grid grid-cols-1 gap-x-4 sm:grid-cols-2">
<Field label="Nazwa firmy">
<Field label={t('claim.companyLabel')}>
<Input
value={form.companyName}
onChange={(e) => setForm({ ...form, companyName: e.target.value })}
placeholder="np. Fit Sp. z o.o."
placeholder={t('claim.companyPh')}
/>
</Field>
<Field label="NIP (10 cyfr)">
<Field label={t('claim.nipLabel')}>
<Input
value={form.nip}
onChange={(e) =>
setForm({ ...form, nip: e.target.value.replace(/\D/g, '').slice(0, 10) })
}
placeholder="np. 1234567890"
placeholder={t('claim.nipPh')}
inputMode="numeric"
/>
</Field>
<Field label="Telefon">
<Field label={t('claim.phoneLabel')}>
<Input
value={form.phone}
onChange={(e) => setForm({ ...form, phone: e.target.value })}
placeholder="np. +48 600 000 000"
placeholder={t('claim.phonePh')}
/>
</Field>
<Field label="E-mail">
<Field label={t('claim.emailLabel')}>
<Input
type="email"
value={form.email}
onChange={(e) => setForm({ ...form, email: e.target.value })}
placeholder="np. kontakt@fitos.pl"
placeholder={t('claim.emailPh')}
/>
</Field>
</div>
<Field
label={`Dokumenty (opcjonalnie, do ${MAX_FILES} plików JPG/PNG/PDF, maks. 5 MB każdy)`}
>
<Field label={t('claim.docsLabel', { count: MAX_FILES })}>
<input
key={fileInputKey}
type="file"
multiple
accept={ALLOWED_MIME.join(',')}
aria-label="Dokumenty"
aria-label={t('claim.docsAria')}
onChange={(e) => onFilesChange(e.target.files)}
className="w-full text-[0.9rem] file:mr-3 file:rounded-xl file:border-0 file:bg-input file:px-3 file:py-2 file:text-[0.85rem] file:text-ink file:cursor-pointer"
/>
@@ -265,7 +265,7 @@ export default function ClaimModal({
{f.name}
<button
type="button"
aria-label={`Usuń ${f.name}`}
aria-label={t('claim.removeFileAria', { name: f.name })}
className="text-dim hover:text-danger cursor-pointer"
onClick={() => setFiles(files.filter((x) => x !== f))}
>
@@ -280,10 +280,10 @@ export default function ClaimModal({
<div className="flex flex-col-reverse sm:flex-row sm:justify-end gap-3 mt-2">
<Button type="button" variant="secondary" onClick={onClose}>
Anuluj
{t('common:cancel')}
</Button>
<Button type="submit" disabled={busy}>
{busy ? 'Wysyłanie…' : 'Złóż wniosek'}
{busy ? t('claim.sending') : t('claim.submit')}
</Button>
</div>
</form>

View File

@@ -1,4 +1,5 @@
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useQueryClient } from '@tanstack/react-query';
import { createGym, useMe } from '../../api/queries';
import type { Availability, GymKind } from '../../api/types';
@@ -16,6 +17,7 @@ import { emptyAvailability } from '../../lib/availability';
export default function GymCreateModal({ open, onClose }: { open: boolean; onClose: () => void }) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const { data: me } = useMe();
const isAdmin = me?.user.isAdmin ?? false;
@@ -76,7 +78,7 @@ export default function GymCreateModal({ open, onClose }: { open: boolean; onClo
});
onClose();
await queryClient.invalidateQueries({ queryKey: ['gyms'] });
push('Siłownia utworzona', 'success');
push(t('create.toastOk'), 'success');
} catch (err) {
push((err as Error).message, 'error');
} finally {
@@ -85,26 +87,26 @@ export default function GymCreateModal({ open, onClose }: { open: boolean; onClo
};
return (
<Modal open={open} onClose={onClose} title="Stwórz siłownię">
<Modal open={open} onClose={onClose} title={t('create.title')}>
<form onSubmit={handleCreate}>
<Field label="Nazwa">
<Field label={t('create.nameLabel')}>
<Input
value={form.name}
onChange={(e) => setForm({ ...form, name: e.target.value })}
placeholder="np. Żelazna Świątynia"
placeholder={t('create.namePh')}
required
/>
</Field>
{isAdmin && (
<Field label="Typ">
<Field label={t('create.kindLabel')}>
<Select
value={form.kind}
onChange={(e) =>
setForm({ ...form, kind: e.target.value as GymKind, isPrivate: false })
}
>
<option value="VIRTUAL">Wirtualna</option>
<option value="REAL">Realna</option>
<option value="VIRTUAL">{t('create.kindVirtual')}</option>
<option value="REAL">{t('create.kindReal')}</option>
</Select>
</Field>
)}
@@ -116,15 +118,15 @@ export default function GymCreateModal({ open, onClose }: { open: boolean; onClo
onChange={(e) => setForm({ ...form, isPrivate: e.target.checked })}
className="h-4 w-4 accent-accent"
/>
Prywatna (ukryta przed innymi)
{t('create.privateCheck')}
</label>
)}
{isVirtual ? (
<Field label="Lokalizacja">
<Field label={t('create.locationLabel')}>
<Input
value={form.location}
onChange={(e) => setForm({ ...form, location: e.target.value })}
placeholder="np. Warszawa"
placeholder={t('create.locationPh')}
required
/>
</Field>
@@ -137,26 +139,26 @@ export default function GymCreateModal({ open, onClose }: { open: boolean; onClo
/>
</div>
)}
<Field label="Dostępność">
<Field label={t('create.availabilityLabel')}>
<AvailabilityEditor
value={form.availability}
onChange={(availability) => setForm({ ...form, availability })}
/>
</Field>
<Field label="Pojemność (osób)">
<Field label={t('create.capacityLabel')}>
<Input
type="number"
value={form.capacity}
onChange={(e) => setForm({ ...form, capacity: e.target.value })}
placeholder="np. 50"
placeholder={t('create.capacityPh')}
/>
</Field>
<div className="flex flex-col-reverse sm:flex-row sm:justify-end gap-3 mt-2">
<Button type="button" variant="secondary" onClick={onClose}>
Anuluj
{t('common:cancel')}
</Button>
<Button type="submit" disabled={busy || !canSubmit}>
{busy ? 'Utwieranie…' : 'Utwórz'}
{busy ? t('create.busy') : t('create.submit')}
</Button>
</div>
</form>

View File

@@ -1,4 +1,5 @@
import { useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useQueryClient } from '@tanstack/react-query';
import { ImagePlus, Star, Trash2 } from 'lucide-react';
import { addGymPhotos, deleteGymPhoto, setGymPhotoCover } from '../../api/queries';
@@ -26,6 +27,7 @@ export default function GymGallery({
}) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const fileRef = useRef<HTMLInputElement>(null);
const [fileError, setFileError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
@@ -47,17 +49,17 @@ export default function GymGallery({
if (fileRef.current) fileRef.current.value = '';
if (picked.length === 0) return;
if (picked.length > MAX_FILES) {
setFileError(`Maksymalnie ${MAX_FILES} plików`);
setFileError(t('upload.maxFiles', { count: MAX_FILES }));
return;
}
const badType = picked.find((f) => !ALLOWED_MIME.includes(f.type));
if (badType) {
setFileError(`Nieobsługiwany typ pliku: ${badType.name} (dozwolone: JPG, PNG, WebP)`);
setFileError(t('upload.badType', { name: badType.name, types: 'JPG, PNG, WebP' }));
return;
}
const tooBig = picked.find((f) => f.size > MAX_FILE_BYTES);
if (tooBig) {
setFileError(`Plik ${tooBig.name} jest większy niż 5 MB`);
setFileError(t('upload.tooBig', { name: tooBig.name }));
return;
}
setFileError(null);
@@ -69,7 +71,7 @@ export default function GymGallery({
try {
await addGymPhotos(gym.id, files);
await invalidate();
push('Dodano zdjęcia', 'success');
push(t('gallery.toastAdded'), 'success');
} catch (err) {
push((err as Error).message, 'error');
} finally {
@@ -83,7 +85,7 @@ export default function GymGallery({
try {
await deleteGymPhoto(gym.id, photo.id);
await invalidate();
push('Usunięto zdjęcie', 'success');
push(t('gallery.toastRemoved'), 'success');
} catch (err) {
push((err as Error).message, 'error');
} finally {
@@ -96,7 +98,7 @@ export default function GymGallery({
try {
await setGymPhotoCover(gym.id, photo.id);
await invalidate();
push('Ustawiono okładkę', 'success');
push(t('gallery.toastCover'), 'success');
} catch (err) {
push((err as Error).message, 'error');
} finally {
@@ -107,9 +109,7 @@ export default function GymGallery({
return (
<div>
<div className="flex items-center justify-between gap-3 flex-wrap">
<p className="text-[0.875rem] text-dim">
Zdjęcia siłowni. Pierwsze zdjęcie (najmniejsza kolejność) jest okładką.
</p>
<p className="text-[0.875rem] text-dim">{t('gallery.hint')}</p>
{canManage && (
<Button
size="sm"
@@ -118,7 +118,7 @@ export default function GymGallery({
disabled={busy}
>
<ImagePlus className="w-4 h-4" />
Dodaj zdjęcia
{t('gallery.addBtn')}
</Button>
)}
{canManage && (
@@ -127,7 +127,7 @@ export default function GymGallery({
type="file"
multiple
accept={ALLOWED_MIME.join(',')}
aria-label="Dodaj zdjęcia"
aria-label={t('gallery.addAria')}
className="hidden"
onChange={(e) => onFilesChange(e.target.files)}
/>
@@ -136,7 +136,7 @@ export default function GymGallery({
{fileError && <ErrorText>{fileError}</ErrorText>}
{photos.length === 0 ? (
<p className="mt-3 text-[0.875rem] text-dim">Brak zdjęć.</p>
<p className="mt-3 text-[0.875rem] text-dim">{t('gallery.empty')}</p>
) : (
<div className="mt-3 grid grid-cols-2 sm:grid-cols-3 gap-2">
{photos.map((p) => {
@@ -151,7 +151,7 @@ export default function GymGallery({
<span className="absolute top-1.5 left-1.5">
<Badge color="green">
<Star className="w-3 h-3 inline mr-1" />
Okładka
{t('gallery.coverBadge')}
</Badge>
</span>
)}
@@ -160,8 +160,8 @@ export default function GymGallery({
{!isCover && (
<button
type="button"
aria-label="Ustaw jako okładka"
title="Ustaw jako okładka"
aria-label={t('gallery.setCoverAria')}
title={t('gallery.setCoverAria')}
disabled={busy}
onClick={() => void setCover(p)}
className="p-1.5 rounded-[10px] bg-black/40 text-white hover:bg-accent hover:text-accent-ink cursor-pointer disabled:opacity-50"
@@ -171,8 +171,8 @@ export default function GymGallery({
)}
<button
type="button"
aria-label="Usuń zdjęcie"
title="Usuń zdjęcie"
aria-label={t('gallery.removeAria')}
title={t('gallery.removeAria')}
disabled={busy}
onClick={() => setConfirmDelete(p)}
className="p-1.5 rounded-[10px] bg-black/40 text-white hover:bg-danger cursor-pointer disabled:opacity-50"
@@ -195,15 +195,15 @@ export default function GymGallery({
aria-modal="true"
className="relative w-full max-w-sm bg-card border border-line rounded-2xl p-5"
>
<h3 className="mb-2 text-[1.05rem] font-semibold">Usuń zdjęcie</h3>
<p className="text-[0.875rem] text-dim">Czy na pewno chcesz usunąć to zdjęcie?</p>
<h3 className="mb-2 text-[1.05rem] font-semibold">{t('gallery.confirmTitle')}</h3>
<p className="text-[0.875rem] text-dim">{t('gallery.confirmText')}</p>
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3 mt-5">
<Button
variant="secondary"
onClick={() => setConfirmDelete(null)}
className="w-full sm:w-auto"
>
Anuluj
{t('common:cancel')}
</Button>
<Button
variant="danger"
@@ -211,7 +211,7 @@ export default function GymGallery({
disabled={busy}
className="w-full sm:w-auto"
>
Usuń
{t('common:remove')}
</Button>
</div>
</div>

View File

@@ -1,4 +1,5 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useQueryClient } from '@tanstack/react-query';
import { sendGymInvitation, useGymInviteeSearch } from '../../api/queries';
import { Button, ErrorText, Field, Input, Loading, Modal } from '../ui';
@@ -16,6 +17,7 @@ export default function InviteGymModal({
}) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
const [busyId, setBusyId] = useState<string | null>(null);
@@ -31,7 +33,7 @@ export default function InviteGymModal({
queryClient.invalidateQueries({ queryKey: ['gym-invitations'] }),
queryClient.invalidateQueries({ queryKey: ['gyms', 'virtual'] }),
]);
push(`Zaproszono: ${name}`, 'success');
push(t('invite.toastOk', { name }), 'success');
} catch (e) {
push((e as Error).message, 'error');
} finally {
@@ -40,28 +42,33 @@ export default function InviteGymModal({
};
return (
<Modal open={open} onClose={onClose} title={`Zaproś usera: ${gym.name}`}>
<Modal open={open} onClose={onClose} title={t('invite.title', { name: gym.name })}>
<div className="flex gap-3">
<Field label="Imię">
<Field label={t('invite.firstNameLabel')}>
<Input
value={firstName}
onChange={(e) => setFirstName(e.target.value)}
placeholder="np. Jan"
placeholder={t('invite.firstNamePh')}
/>
</Field>
<Field label="Nazwisko">
<Field label={t('invite.lastNameLabel')}>
<Input
value={lastName}
onChange={(e) => setLastName(e.target.value)}
placeholder="np. Kowalski"
placeholder={t('invite.lastNamePh')}
/>
</Field>
</div>
{searching && isLoading && <Loading />}
{searching && error && <ErrorText>Błąd: {(error as Error).message}</ErrorText>}
{searching && error && (
<ErrorText>
{t('common:errorPrefix')}
{(error as Error).message}
</ErrorText>
)}
{searching && !isLoading && !error && (data?.users ?? []).length === 0 && (
<p className="text-dim text-[0.9rem]">Brak użytkowników o podanych danych.</p>
<p className="text-dim text-[0.9rem]">{t('invite.empty')}</p>
)}
<div className="space-y-2">
{(data?.users ?? []).map((u) => {
@@ -81,7 +88,7 @@ export default function InviteGymModal({
disabled={busyId === u.id}
onClick={() => void invite(u.id, name)}
>
{busyId === u.id ? 'Zapraszanie…' : 'Zaproś'}
{busyId === u.id ? t('invite.busy') : t('invite.submit')}
</Button>
</div>
);

View File

@@ -1,4 +1,5 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useQueryClient } from '@tanstack/react-query';
import { joinGym, useAllGyms, useGyms } from '../../api/queries';
import type { Gym } from '../../api/types';
@@ -12,6 +13,7 @@ import { useToast } from '../toast';
export default function JoinGymModal({ open, onClose }: { open: boolean; onClose: () => void }) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const [query, setQuery] = useState('');
const [busyId, setBusyId] = useState<string | null>(null);
@@ -33,7 +35,7 @@ export default function JoinGymModal({ open, onClose }: { open: boolean; onClose
queryClient.invalidateQueries({ queryKey: ['gyms'] }),
queryClient.invalidateQueries({ queryKey: ['gyms', 'all'] }),
]);
push(`Dołączono do siłowni: ${g.name}`, 'success');
push(t('join.toastOk', { name: g.name }), 'success');
} catch (e) {
push((e as Error).message, 'error');
} finally {
@@ -42,23 +44,26 @@ export default function JoinGymModal({ open, onClose }: { open: boolean; onClose
};
return (
<Modal open={open} onClose={onClose} title="Dołącz do siłowni" handle>
<Modal open={open} onClose={onClose} title={t('join.title')} handle>
<Input
type="search"
placeholder="Szukaj siłowni…"
aria-label="Szukaj siłowni do dołączenia"
placeholder={t('join.searchPh')}
aria-label={t('join.searchAria')}
value={query}
onChange={(e) => setQuery(e.target.value)}
/>
<div className="mt-3 max-h-[50vh] space-y-2 overflow-y-auto pr-1">
{isLoading && <Loading />}
{error && <ErrorText>Błąd: {(error as Error).message}</ErrorText>}
{error && (
<ErrorText>
{t('common:errorPrefix')}
{(error as Error).message}
</ErrorText>
)}
{!isLoading && !error && filtered.length === 0 && (
<p className="py-6 text-center text-dim text-[0.9rem]">
{q
? 'Brak wyników dla podanego zapytania.'
: 'Brak siłowni do dołączenia — należysz już do wszystkich.'}
{q ? t('join.emptyQuery') : t('join.emptyAll')}
</p>
)}
{filtered.map((g) => (
@@ -69,7 +74,7 @@ export default function JoinGymModal({ open, onClose }: { open: boolean; onClose
<div className="min-w-0">
<strong className="text-[0.95rem]">{g.name}</strong>
<div className="text-dim text-[0.8rem]">
{g.location || '—'} · {g.equipment.length} urządzeń
{g.location || '—'} · {t('common:counters.devices', { count: g.equipment.length })}
</div>
</div>
<Button
@@ -78,7 +83,7 @@ export default function JoinGymModal({ open, onClose }: { open: boolean; onClose
disabled={busyId === g.id}
onClick={() => void join(g)}
>
{busyId === g.id ? 'Dołączanie…' : 'Dołącz'}
{busyId === g.id ? t('join.busy') : t('join.submit')}
</Button>
</div>
))}

View File

@@ -15,6 +15,7 @@ import plPlans from './locales/pl/plans.json';
import plDashboard from './locales/pl/dashboard.json';
import plGyms from './locales/pl/gyms.json';
import plMessages from './locales/pl/messages.json';
import plInvitations from './locales/pl/invitations.json';
import plFeed from './locales/pl/feed.json';
import plProfile from './locales/pl/profile.json';
import plTrainees from './locales/pl/trainees.json';
@@ -27,6 +28,7 @@ import enPlans from './locales/en/plans.json';
import enDashboard from './locales/en/dashboard.json';
import enGyms from './locales/en/gyms.json';
import enMessages from './locales/en/messages.json';
import enInvitations from './locales/en/invitations.json';
import enFeed from './locales/en/feed.json';
import enProfile from './locales/en/profile.json';
import enTrainees from './locales/en/trainees.json';
@@ -41,6 +43,7 @@ export const NAMESPACES = [
'dashboard',
'gyms',
'messages',
'invitations',
'feed',
'profile',
'trainees',
@@ -58,6 +61,7 @@ const resources = {
dashboard: plDashboard,
gyms: plGyms,
messages: plMessages,
invitations: plInvitations,
feed: plFeed,
profile: plProfile,
trainees: plTrainees,
@@ -72,6 +76,7 @@ const resources = {
dashboard: enDashboard,
gyms: enGyms,
messages: enMessages,
invitations: enInvitations,
feed: enFeed,
profile: enProfile,
trainees: enTrainees,

View File

@@ -1,8 +1,11 @@
{
"appName": "FitOS",
"errorPrefix": "Error: ",
"cancel": "Cancel",
"confirm": "Confirm",
"save": "Save",
"saving": "Saving…",
"edit": "Edit",
"close": "Close",
"closeNotification": "Close notification",
"clear": "Clear",
@@ -16,6 +19,8 @@
"toggleLanguage": "Change language",
"ok": "OK",
"remove": "Remove",
"yes": "yes",
"no": "no",
"loading": "Loading…",
"back": "Back",
"searchShort": "Search…",
@@ -81,7 +86,9 @@
"weeks_other": "{{count}} weeks",
"setCount_one": "{{count}} set",
"setCount_other": "{{count}} sets",
"weeksShort": "{{count}} wk"
"weeksShort": "{{count}} wk",
"devices_one": "{{count}} device",
"devices_other": "{{count}} devices"
},
"muscles": {
"chest": "Chest",

View File

@@ -1 +1,16 @@
{}
{
"markAll": "Mark all read",
"markAllToast": "Everything marked as read",
"emptyTitle": "No news",
"emptyDesc": "Plans from your trainer and gym announcements will appear here.",
"loadOlder": "Load older",
"loading": "Loading…",
"itemType": {
"planFromTrainer": "Plan from trainer",
"sharedPlan": "Shared plan",
"gymDeleted": "Deleted gym",
"announcement": "Announcement",
"hoursChange": "Hours change",
"exception": "Schedule exception"
}
}

View File

@@ -1 +1,240 @@
{}
{
"upload": {
"maxFiles": "Maximum {{count}} files",
"badType": "Unsupported file type: {{name}} (allowed: {{types}})",
"tooBig": "File {{name}} is larger than 5 MB"
},
"spec": {
"upToKg": "up to {{v}} kg",
"fromKg": "from {{v}} kg",
"upToKmh": "up to {{v}} km/h",
"inclineUpTo": "incline up to {{v}}%",
"minKg": "Min. load (kg)",
"maxKg": "Max. load (kg)",
"maxLoadKg": "Maximum load (kg)",
"maxSpeed": "Max. speed (km/h)",
"maxIncline": "Max. incline (%)"
},
"sections": {
"savedToast": "Changes saved",
"nameLabel": "Name",
"locationLabel": "Location",
"capacityLabel": "Capacity (people)",
"privateEdit": "Private (hidden from others — accessible only by invitation)"
},
"photo": {
"addBtn": "Add photos",
"formatsHint": "JPG, PNG or WebP · max 5 MB",
"maxToast": "Maximum {{count}} photos per device",
"formatsToast": "Allowed formats: JPG, PNG, WebP",
"sizeToast": "Maximum photo size is 5 MB",
"removeFileAria": "Remove {{name}}"
},
"equipment": {
"inStock": "In stock ({{count}})",
"empty": "No equipment — add the first item from the catalog below.",
"qtyAria": "Quantity: {{name}}",
"editAria": "Edit {{name}}",
"removeAria": "Remove {{name}}",
"editTitle": "Editing: {{name}}",
"closeEditAria": "Close editor",
"itemParams": "Item parameters",
"photosCount": "Photos ({{n}}/{{max}})",
"addPhotosLabel": "Add device photos",
"restoreCatalog": "Restore catalog spec",
"restoreToast": "Catalog spec restored",
"addTitle": "Add device from catalog",
"addAria": "Add device",
"chooseDevice": "Choose device…",
"onStock": " (in stock: {{count}})",
"qtyLabel": "Quantity",
"addBtn": "Add",
"adding": "Adding…",
"paramsLabel": "Parameters",
"addPhotosSwitch": "Add photos to this item (optional)",
"photosLabel": "Device photos",
"specRangeError": "Provide the load range (min and max in kg).",
"specMaxLoadError": "Provide the maximum load (kg).",
"specCardioError": "Provide device parameters (speed or incline).",
"specEditError": "Provide parameters or restore the catalog spec.",
"addedPartialToast": "Device added, but photos upload failed",
"addedToast": "Equipment added",
"photosFailToast": "Failed to upload photos",
"removedToast": "Removed: {{name}}"
},
"hours": {
"closed": "closed"
},
"detail": {
"back": "Back",
"notFound": "Gym not found.",
"photoMore": "+{{count}} more",
"noEquipment": "No equipment.",
"photosAria": "Photos: {{name}}",
"places": "{{count}} places",
"chipVirtual": "Virtual",
"chipPrivate": "Private",
"galleryTitle": "Photo gallery",
"equipmentTitle": "Equipment",
"equipmentDesc": "Machines and devices available at this gym.",
"hoursTitle": "Opening hours",
"exceptionsLabel": "Exceptions",
"dataTitle": "Details",
"dataKind": "Type",
"dataPrivate": "Private",
"dataCapacity": "Capacity",
"dataStreet": "Street",
"dataPostalCity": "Postal code and city",
"dataCountry": "Country",
"dataLocation": "Location",
"groupEdit": "Editing",
"groupGallery": "Gallery",
"groupEquipment": "Equipment",
"groupAnnouncements": "Announcements",
"groupInvites": "Invitations",
"actionInfo": "Information",
"actionInvite": "Invite user",
"actionWithdrawClaim": "Withdraw request",
"actionClaimVerify": "Submit verification request",
"actionDelete": "Delete gym",
"claimWithdrawnToast": "Request withdrawn",
"modalInfo": "Information",
"modalGallery": "Manage gallery",
"modalEquipment": "Manage equipment",
"modalAnnouncements": "Announcements",
"exceptionsTitle": "Schedule exceptions",
"exceptionsDesc": "One-off changes for a specific day (closure or different hours).",
"deleteDesc": "Delete the gym? Memberships will be removed, users' plans will be kept."
},
"exceptions": {
"removedToast": "Exception removed",
"empty": "No exceptions.",
"addedToast": "Exception added",
"addTitle": "Add exception — date and day mode",
"dateAria": "Exception date",
"closedMode": "Closed",
"hoursMode": "Other hours",
"fromAria": "From time",
"toAria": "To time"
},
"announcements": {
"toastPublished": "Announcement published",
"toastRemoved": "Announcement removed",
"composerTitle": "New announcement — it will reach all gym members",
"titlePh": "Title (e.g. Air conditioning failure)",
"titleAria": "Announcement title",
"bodyPh": "Announcement body…",
"bodyAria": "Announcement body",
"publish": "Publish",
"publishing": "Publishing…",
"empty": "No announcements.",
"systemBadge": "System"
},
"invites": {
"desc": "A private gym is hidden — invite specific users.",
"empty": "No invitations sent.",
"withdraw": "Withdraw",
"toastWithdrawn": "Invitation withdrawn"
},
"page": {
"open": "Open →",
"members": "{{count}} members",
"ratingTitle": "Percentage of “recommend” votes",
"voteTitle": "Does this virtual gym reflect the real one well?",
"voteUpAria": "Recommend: {{name}}",
"voteDownAria": "Do not recommend: {{name}}",
"claimPending": "Request is pending verification",
"rejected": "Rejected",
"resubmit": "Submit again",
"sentInvites": "Sent invitations",
"tabMine": "My gyms",
"tabVirtual": "Virtual",
"virtualHeading": "Virtual gyms",
"emptyQueryTitle": "No results",
"emptyMineTitle": "No gyms",
"emptyMineDesc": "You are not a member of any gym. Create the first one or join an existing one.",
"emptyVirtualTitle": "No virtual gyms",
"emptyVirtualDesc": "Check back here to rate how well real gyms are reflected."
},
"claim": {
"toastOk": "Request submitted",
"titleVerify": "Verification request: {{name}}",
"titleNew": "New gym request",
"gymNameLabel": "Gym name",
"gymNamePh": "e.g. Iron Temple",
"locationLabel": "Location",
"locationPh": "e.g. 5 Długa St, Warsaw",
"availabilityLabel": "Availability",
"capacityLabel": "Capacity (people)",
"capacityPh": "e.g. 50",
"descLabel": "Description (why this gym deserves verification / creation)",
"descPh": "Short description",
"addressLabel": "Full gym address (optional — overrides location)",
"addressPh": "e.g. 5 Długa St, 00-050 Warsaw",
"companyLabel": "Company name",
"companyPh": "e.g. Fit Sp. z o.o.",
"nipLabel": "Tax ID (10 digits)",
"nipPh": "e.g. 1234567890",
"phoneLabel": "Phone",
"phonePh": "e.g. +48 600 000 000",
"emailLabel": "E-mail",
"emailPh": "e.g. contact@fitos.pl",
"docsLabel": "Documents (optional, up to {{count}} JPG/PNG/PDF files, max 5 MB each)",
"docsAria": "Documents",
"removeFileAria": "Remove {{name}}",
"submit": "Submit request",
"sending": "Sending…"
},
"create": {
"toastOk": "Gym created",
"title": "Create gym",
"nameLabel": "Name",
"namePh": "e.g. Iron Temple",
"kindLabel": "Type",
"kindVirtual": "Virtual",
"kindReal": "Real",
"privateCheck": "Private (hidden from others)",
"locationLabel": "Location",
"locationPh": "e.g. Warsaw",
"availabilityLabel": "Availability",
"capacityLabel": "Capacity (people)",
"capacityPh": "e.g. 50",
"submit": "Create",
"busy": "Creating…"
},
"gallery": {
"toastAdded": "Photos added",
"toastRemoved": "Photo removed",
"toastCover": "Cover set",
"hint": "Gym photos. The first photo (lowest order) is the cover.",
"addBtn": "Add photos",
"addAria": "Add photos",
"empty": "No photos.",
"coverBadge": "Cover",
"setCoverAria": "Set as cover",
"removeAria": "Remove photo",
"confirmTitle": "Remove photo",
"confirmText": "Are you sure you want to remove this photo?"
},
"invite": {
"toastOk": "Invited: {{name}}",
"title": "Invite user: {{name}}",
"firstNameLabel": "First name",
"firstNamePh": "e.g. John",
"lastNameLabel": "Last name",
"lastNamePh": "e.g. Smith",
"empty": "No users with these details.",
"submit": "Invite",
"busy": "Inviting…"
},
"join": {
"toastOk": "Joined gym: {{name}}",
"title": "Join gym",
"searchPh": "Search gyms…",
"searchAria": "Search gyms to join",
"emptyQuery": "No results for the given query.",
"emptyAll": "No gyms to join — you are already a member of all of them.",
"submit": "Join",
"busy": "Joining…"
}
}

View File

@@ -0,0 +1,24 @@
{
"expiryOverdue": "expired",
"expiryToday": "expires today",
"expiryTomorrow": "expires tomorrow",
"expiryInDays_one": "expires in {{count}} day",
"expiryInDays_other": "expires in {{count}} days",
"received": "Received",
"sent": "Sent",
"decline": "Decline",
"accept": "Accept",
"withdraw": "Withdraw",
"toastAccepted": "Invitation accepted",
"toastDeclined": "Invitation declined",
"toastWithdrawn": "Invitation withdrawn",
"badgeGym": "Gym",
"invitedBy": "invited by: {{name}}",
"toPerson": "to: {{name}}",
"scopeIn": "Incoming",
"scopeOut": "Outgoing",
"filterAria": "Filter invitations",
"emptyTitle": "No active invitations",
"emptyDesc": "Invitations for collaboration (trainer ↔ trainee) and to private gyms will appear here.",
"searchNoResults": "No results for the given query."
}

View File

@@ -1 +1,43 @@
{}
{
"sortPrefix": "Sort: ",
"sort": {
"none": "None",
"unread": "Unread",
"name": "Name"
},
"groupByRole": "Group by role",
"roleTrainees": "Trainees",
"roleTrainers": "Trainers",
"youPrefix": "You: ",
"noMessageRow": "No messages",
"emptyTitle": "No conversations",
"emptyDesc": "A conversation appears once you have an active relationship with a trainer.",
"searchNoResults": "No results for the given query.",
"composerPlaceholder": "Write a message…",
"composerAria": "Message body",
"attachResult": "Attach result",
"removeAttachmentAria": "Remove attachment",
"send": "Send",
"attachEmpty": "No completed sessions to attach.",
"sessionLabel": "Session",
"chooseOption": "— choose —",
"exerciseLabel": "Exercise (optional)",
"exerciseAria": "Exercise",
"wholeSession": "Whole session",
"addAttachment": "Add attachment",
"attachHint": "The attachment will appear above the message field — you can write the body later.",
"openTraineePanel": "Open trainee panel",
"emptyThread": "No messages — write the first one.",
"attachOpenHint": "Click to open history",
"attachSessionResult": "Session result",
"attachSet": "Set {{n}}",
"attachSetsFrac": "{{done}}/{{total}} sets",
"ctx": {
"traineeWorkout": "Trainee workout",
"killstreak": "Killstreak",
"lastSession": "Last session",
"nextWorkout": "Next workout",
"yourWorkouts": "Your workouts",
"daysSep": " days · "
}
}

View File

@@ -1,8 +1,11 @@
{
"appName": "FitOS",
"errorPrefix": "Błąd: ",
"cancel": "Anuluj",
"confirm": "Potwierdź",
"save": "Zapisz",
"saving": "Zapisywanie…",
"edit": "Edytuj",
"close": "Zamknij",
"closeNotification": "Zamknij powiadomienie",
"clear": "Wyczyść",
@@ -16,6 +19,8 @@
"toggleLanguage": "Zmień język",
"ok": "OK",
"remove": "Usuń",
"yes": "tak",
"no": "nie",
"loading": "Ładowanie…",
"back": "Wstecz",
"searchShort": "Szukaj…",
@@ -88,7 +93,11 @@
"setCount_few": "{{count}} serii",
"setCount_many": "{{count}} serii",
"setCount_other": "{{count}} serii",
"weeksShort": "{{count}} tyg."
"weeksShort": "{{count}} tyg.",
"devices_one": "{{count}} urządzenie",
"devices_few": "{{count}} urządzenia",
"devices_many": "{{count}} urządzeń",
"devices_other": "{{count}} urządzeń"
},
"muscles": {
"chest": "Klatka",

View File

@@ -1 +1,16 @@
{}
{
"markAll": "Oznacz wszystkie",
"markAllToast": "Wszystko oznaczone jako przeczytane",
"emptyTitle": "Brak aktualności",
"emptyDesc": "Tu pojawią się plany od trenera i ogłoszenia siłowni.",
"loadOlder": "Wczytaj starsze",
"loading": "Wczytywanie…",
"itemType": {
"planFromTrainer": "Plan od trenera",
"sharedPlan": "Udostępniony plan",
"gymDeleted": "Usunięta siłownia",
"announcement": "Ogłoszenie",
"hoursChange": "Zmiana godzin",
"exception": "Wyjątek w godzinach"
}
}

View File

@@ -1 +1,240 @@
{}
{
"upload": {
"maxFiles": "Maksymalnie {{count}} plików",
"badType": "Nieobsługiwany typ pliku: {{name}} (dozwolone: {{types}})",
"tooBig": "Plik {{name}} jest większy niż 5 MB"
},
"spec": {
"upToKg": "do {{v}} kg",
"fromKg": "od {{v}} kg",
"upToKmh": "do {{v}} km/h",
"inclineUpTo": "nachylenie do {{v}}%",
"minKg": "Min. obciążenie (kg)",
"maxKg": "Max. obciążenie (kg)",
"maxLoadKg": "Maksymalne obciążenie (kg)",
"maxSpeed": "Maks. prędkość (km/h)",
"maxIncline": "Maks. nachylenie (%)"
},
"sections": {
"savedToast": "Zapisano zmiany",
"nameLabel": "Nazwa",
"locationLabel": "Lokalizacja",
"capacityLabel": "Pojemność (osób)",
"privateEdit": "Prywatna (ukryta przed innymi — dostęp tylko po zaproszeniu)"
},
"photo": {
"addBtn": "Dodaj zdjęcia",
"formatsHint": "JPG, PNG lub WebP · maks. 5 MB",
"maxToast": "Maksymalnie {{count}} zdjęć na urządzenie",
"formatsToast": "Dozwolone formaty: JPG, PNG, WebP",
"sizeToast": "Maksymalny rozmiar zdjęcia to 5 MB",
"removeFileAria": "Usuń {{name}}"
},
"equipment": {
"inStock": "Pozycje na stanie ({{count}})",
"empty": "Brak urządzeń — dodaj pierwsze z katalogu poniżej.",
"qtyAria": "Ilość: {{name}}",
"editAria": "Edytuj {{name}}",
"removeAria": "Usuń {{name}}",
"editTitle": "Edycja: {{name}}",
"closeEditAria": "Zamknij edycję",
"itemParams": "Parametry pozycji",
"photosCount": "Zdjęcia ({{n}}/{{max}})",
"addPhotosLabel": "Dodaj zdjęcia urządzenia",
"restoreCatalog": "Przywróć specyfikację katalogu",
"restoreToast": "Przywrócono specyfikację katalogu",
"addTitle": "Dodaj urządzenie z katalogu",
"addAria": "Dodaj urządzenie",
"chooseDevice": "Wybierz urządzenie…",
"onStock": " (na stanie: {{count}})",
"qtyLabel": "Ilość",
"addBtn": "Dodaj",
"adding": "Dodawanie…",
"paramsLabel": "Parametry",
"addPhotosSwitch": "Dodaj zdjęcia do tej pozycji (opcjonalnie)",
"photosLabel": "Zdjęcia urządzenia",
"specRangeError": "Podaj zakres obciążeń (min i max w kg).",
"specMaxLoadError": "Podaj maksymalne obciążenie (kg).",
"specCardioError": "Podaj parametry urządzenia (prędkość lub nachylenie).",
"specEditError": "Podaj parametry lub przywróć specyfikację katalogu.",
"addedPartialToast": "Urządzenie dodane, ale nie udało się wgrać zdjęć",
"addedToast": "Sprzęt dodany",
"photosFailToast": "Nie udało się wgrać zdjęć",
"removedToast": "Usunięto: {{name}}"
},
"hours": {
"closed": "zamknięte"
},
"detail": {
"back": "Wstecz",
"notFound": "Nie znaleziono siłowni.",
"photoMore": "+{{count}} zdjęć",
"noEquipment": "Brak urządzeń.",
"photosAria": "Zdjęcia: {{name}}",
"places": "{{count}} miejsc",
"chipVirtual": "Wirtualna",
"chipPrivate": "Prywatna",
"galleryTitle": "Galeria zdjęć",
"equipmentTitle": "Urządzenia",
"equipmentDesc": "Maszyny i urządzenia dostępne w tej siłowni.",
"hoursTitle": "Godziny otwarcia",
"exceptionsLabel": "Wyjątki",
"dataTitle": "Dane",
"dataKind": "Rodzaj",
"dataPrivate": "Prywatna",
"dataCapacity": "Pojemność",
"dataStreet": "Ulica",
"dataPostalCity": "Kod i miasto",
"dataCountry": "Kraj",
"dataLocation": "Lokalizacja",
"groupEdit": "Edycja",
"groupGallery": "Galeria",
"groupEquipment": "Urządzenia",
"groupAnnouncements": "Ogłoszenia",
"groupInvites": "Zaproszenia",
"actionInfo": "Informacje",
"actionInvite": "Zaproś usera",
"actionWithdrawClaim": "Wycofaj wniosek",
"actionClaimVerify": "Złóż wniosek o weryfikację",
"actionDelete": "Usuń siłownię",
"claimWithdrawnToast": "Wniosek wycofany",
"modalInfo": "Informacje",
"modalGallery": "Zarządzaj galerią",
"modalEquipment": "Zarządzaj urządzeniami",
"modalAnnouncements": "Ogłoszenia",
"exceptionsTitle": "Wyjątki w harmonogramie",
"exceptionsDesc": "Jednorazowe zmiany na konkretny dzień (zamknięcie lub inne godziny).",
"deleteDesc": "Usunąć siłownię? Członkostwa zostaną usunięte, plany użytkowników zachowane."
},
"exceptions": {
"removedToast": "Wyjątek usunięty",
"empty": "Brak wyjątków.",
"addedToast": "Wyjątek dodany",
"addTitle": "Dodaj wyjątek — data i tryb dnia",
"dateAria": "Data wyjątku",
"closedMode": "Zamknięte",
"hoursMode": "Inne godziny",
"fromAria": "Od godziny",
"toAria": "Do godziny"
},
"announcements": {
"toastPublished": "Ogłoszenie opublikowane",
"toastRemoved": "Ogłoszenie usunięte",
"composerTitle": "Nowe ogłoszenie — trafi do wszystkich członków siłowni",
"titlePh": "Tytuł (np. Awarida klimatyzacji)",
"titleAria": "Tytuł ogłoszenia",
"bodyPh": "Treść ogłoszenia…",
"bodyAria": "Treść ogłoszenia",
"publish": "Opublikuj",
"publishing": "Publikowanie…",
"empty": "Brak ogłoszeń.",
"systemBadge": "Systemowe"
},
"invites": {
"desc": "Prywatna siłownia jest ukryta — zapraszaj określonych userów.",
"empty": "Brak wysłanych zaproszeń.",
"withdraw": "Wycofaj",
"toastWithdrawn": "Zaproszenie wycofane"
},
"page": {
"open": "Otwórz →",
"members": "{{count}} członków",
"ratingTitle": "Odsetek głosów „polecam”",
"voteTitle": "Czy ta wirtualna siłownia dobrze oddaje prawdziwą?",
"voteUpAria": "Polecam: {{name}}",
"voteDownAria": "Nie polecam: {{name}}",
"claimPending": "Wniosek oczekuje na weryfikację",
"rejected": "Odrzucono",
"resubmit": "Złóż ponownie",
"sentInvites": "Wysłane zaproszenia",
"tabMine": "Moje siłownie",
"tabVirtual": "Wirtualne",
"virtualHeading": "Wirtualne siłownie",
"emptyQueryTitle": "Brak wyników",
"emptyMineTitle": "Brak siłowni",
"emptyMineDesc": "Nie należysz do żadnej siłowni. Utwórz pierwszą lub dołącz do istniejącej.",
"emptyVirtualTitle": "Brak wirtualnych siłowni",
"emptyVirtualDesc": "Zaglądaj tu, by oceniać odwzorowanie prawdziwych siłowni."
},
"claim": {
"toastOk": "Wniosek złożony",
"titleVerify": "Wniosek o weryfikację: {{name}}",
"titleNew": "Nowy wniosek o siłownię",
"gymNameLabel": "Nazwa siłowni",
"gymNamePh": "np. Żelazna Świątynia",
"locationLabel": "Lokalizacja",
"locationPh": "np. ul. Długa 5, Warszawa",
"availabilityLabel": "Dostępność",
"capacityLabel": "Pojemność (osób)",
"capacityPh": "np. 50",
"descLabel": "Opis (dlaczego ta siłownia zasługuje na weryfikację / utworzenie)",
"descPh": "Krótki opis",
"addressLabel": "Pełny adres siłowni (opcjonalnie — nadpisze lokalizację)",
"addressPh": "np. ul. Długa 5, 00-050 Warszawa",
"companyLabel": "Nazwa firmy",
"companyPh": "np. Fit Sp. z o.o.",
"nipLabel": "NIP (10 cyfr)",
"nipPh": "np. 1234567890",
"phoneLabel": "Telefon",
"phonePh": "np. +48 600 000 000",
"emailLabel": "E-mail",
"emailPh": "np. kontakt@fitos.pl",
"docsLabel": "Dokumenty (opcjonalnie, do {{count}} plików JPG/PNG/PDF, maks. 5 MB każdy)",
"docsAria": "Dokumenty",
"removeFileAria": "Usuń {{name}}",
"submit": "Złóż wniosek",
"sending": "Wysyłanie…"
},
"create": {
"toastOk": "Siłownia utworzona",
"title": "Stwórz siłownię",
"nameLabel": "Nazwa",
"namePh": "np. Żelazna Świątynia",
"kindLabel": "Typ",
"kindVirtual": "Wirtualna",
"kindReal": "Realna",
"privateCheck": "Prywatna (ukryta przed innymi)",
"locationLabel": "Lokalizacja",
"locationPh": "np. Warszawa",
"availabilityLabel": "Dostępność",
"capacityLabel": "Pojemność (osób)",
"capacityPh": "np. 50",
"submit": "Utwórz",
"busy": "Utwierdanie…"
},
"gallery": {
"toastAdded": "Dodano zdjęcia",
"toastRemoved": "Usunięto zdjęcie",
"toastCover": "Ustawiono okładkę",
"hint": "Zdjęcia siłowni. Pierwsze zdjęcie (najmniejsza kolejność) jest okładką.",
"addBtn": "Dodaj zdjęcia",
"addAria": "Dodaj zdjęcia",
"empty": "Brak zdjęć.",
"coverBadge": "Okładka",
"setCoverAria": "Ustaw jako okładka",
"removeAria": "Usuń zdjęcie",
"confirmTitle": "Usuń zdjęcie",
"confirmText": "Czy na pewno chcesz usunąć to zdjęcie?"
},
"invite": {
"toastOk": "Zaproszono: {{name}}",
"title": "Zaproś usera: {{name}}",
"firstNameLabel": "Imię",
"firstNamePh": "np. Jan",
"lastNameLabel": "Nazwisko",
"lastNamePh": "np. Kowalski",
"empty": "Brak użytkowników o podanych danych.",
"submit": "Zaproś",
"busy": "Zapraszanie…"
},
"join": {
"toastOk": "Dołączono do siłowni: {{name}}",
"title": "Dołącz do siłowni",
"searchPh": "Szukaj siłowni…",
"searchAria": "Szukaj siłowni do dołączenia",
"emptyQuery": "Brak wyników dla podanego zapytania.",
"emptyAll": "Brak siłowni do dołączenia — należysz już do wszystkich.",
"submit": "Dołącz",
"busy": "Dołączanie…"
}
}

View File

@@ -0,0 +1,23 @@
{
"expiryOverdue": "po terminie",
"expiryToday": "wygasa dziś",
"expiryTomorrow": "wygasa jutro",
"expiryInDays": "wygasa za {{count}} dni",
"received": "Otrzymane",
"sent": "Wysłane",
"decline": "Odrzuć",
"accept": "Przyjmij",
"withdraw": "Wycofaj",
"toastAccepted": "Zaproszenie przyjęte",
"toastDeclined": "Zaproszenie odrzucone",
"toastWithdrawn": "Zaproszenie wycofane",
"badgeGym": "Siłownia",
"invitedBy": "zaprosił: {{name}}",
"toPerson": "do: {{name}}",
"scopeIn": "Przychodzące",
"scopeOut": "Wychodzące",
"filterAria": "Filtruj zaproszenia",
"emptyTitle": "Brak aktywnych zaproszeń",
"emptyDesc": "Zaproszenia do współpracy (trener ↔ podopieczny) i do prywatnych siłowni pojawią się tutaj.",
"searchNoResults": "Brak wyników dla podanego zapytania."
}

View File

@@ -1 +1,43 @@
{}
{
"sortPrefix": "Sortuj: ",
"sort": {
"none": "Brak",
"unread": "Nieprzeczytane",
"name": "Nazwa"
},
"groupByRole": "Grupuj wg roli",
"roleTrainees": "Podopieczni",
"roleTrainers": "Trenerzy",
"youPrefix": "Ty: ",
"noMessageRow": "Brak wiadomości",
"emptyTitle": "Brak rozmów",
"emptyDesc": "Rozmowa pojawi się po nawiązaniu aktywnej relacji z trenerem.",
"searchNoResults": "Brak wyników dla podanego zapytania.",
"composerPlaceholder": "Napisz wiadomość…",
"composerAria": "Treść wiadomości",
"attachResult": "Załącz wynik",
"removeAttachmentAria": "Usuń załącznik",
"send": "Wyślij",
"attachEmpty": "Brak ukończonych sesji do załączenia.",
"sessionLabel": "Sesja",
"chooseOption": "— wybierz —",
"exerciseLabel": "Ćwiczenie (opcjonalnie)",
"exerciseAria": "Ćwiczenie",
"wholeSession": "Cała sesja",
"addAttachment": "Dodaj załącznik",
"attachHint": "Załącznik pojawi się nad polem wiadomości — treść możesz dopisać później.",
"openTraineePanel": "Otwórz panel podopiecznego",
"emptyThread": "Brak wiadomości — napisz pierwszą.",
"attachOpenHint": "Kliknij, aby otworzyć historię",
"attachSessionResult": "Wynik sesji",
"attachSet": "Seria {{n}}",
"attachSetsFrac": "{{done}}/{{total}} serii",
"ctx": {
"traineeWorkout": "Trening podopiecznego",
"killstreak": "Killstreak",
"lastSession": "Ostatnia sesja",
"nextWorkout": "Następny trening",
"yourWorkouts": "Twoje treningi",
"daysSep": " dni · "
}
}

View File

@@ -1,18 +1,7 @@
import i18n from '../i18n';
import type { Equipment, EquipmentKind, EquipmentSpec, GymEquipment } from '../api/types';
import { localizedName } from './localizedName';
export const EQUIPMENT_KIND_LABELS: Record<EquipmentKind, string> = {
DUMBBELL: 'Hantle',
KETTLEBELL: 'Kettlebell',
BARBELL: 'Sztanga',
CABLE: 'Wyciąg',
MACHINE: 'Maszyna',
BENCH: 'Ławka',
CARDIO: 'Cardio',
BODYWEIGHT: 'Masa ciała',
OTHER: 'Inne',
};
function fmtKg(value: number): string {
return Number.isInteger(value) ? String(value) : value.toFixed(1).replace(/\.0$/, '');
}
@@ -34,12 +23,14 @@ export function formatEquipmentSpec(spec: EquipmentSpec | null | undefined): str
? `${fmtKg(spec.minKg)} kg`
: `${fmtKg(spec.minKg)}–${fmtKg(spec.maxKg)} kg`,
);
} else if (spec.maxKg != null) parts.push(`do ${fmtKg(spec.maxKg)} kg`);
else parts.push(`od ${fmtKg(spec.minKg!)} kg`);
} else if (spec.maxKg != null) parts.push(i18n.t('gyms:spec.upToKg', { v: fmtKg(spec.maxKg) }));
else parts.push(i18n.t('gyms:spec.fromKg', { v: fmtKg(spec.minKg!) }));
}
if (spec.maxLoadKg != null) parts.push(`do ${fmtKg(spec.maxLoadKg)} kg`);
if (spec.maxSpeedKmh != null) parts.push(`do ${fmtKg(spec.maxSpeedKmh)} km/h`);
if (spec.maxInclinePct != null) parts.push(`nachylenie do ${fmtKg(spec.maxInclinePct)}%`);
if (spec.maxLoadKg != null) parts.push(i18n.t('gyms:spec.upToKg', { v: fmtKg(spec.maxLoadKg) }));
if (spec.maxSpeedKmh != null)
parts.push(i18n.t('gyms:spec.upToKmh', { v: fmtKg(spec.maxSpeedKmh) }));
if (spec.maxInclinePct != null)
parts.push(i18n.t('gyms:spec.inclineUpTo', { v: fmtKg(spec.maxInclinePct) }));
return parts.length ? parts.join(', ') : null;
}
@@ -90,12 +81,12 @@ export function specFromFields(
if (LOAD_RANGE_KINDS.includes(kind)) {
const minKg = parseNum(f.minKg);
const maxKg = parseNum(f.maxKg);
if (minKg == null || maxKg == null) return { error: 'Podaj zakres obciążeń (min i max w kg).' };
if (minKg == null || maxKg == null) return { error: i18n.t('gyms:equipment.specRangeError') };
return { spec: { minKg, maxKg } };
}
if (MAX_LOAD_KINDS.includes(kind)) {
const maxLoadKg = parseNum(f.maxLoadKg);
if (maxLoadKg == null) return { error: 'Podaj maksymalne obciążenie (kg).' };
if (maxLoadKg == null) return { error: i18n.t('gyms:equipment.specMaxLoadError') };
return { spec: { maxLoadKg } };
}
if (kind === 'CARDIO') {

View File

@@ -1,4 +1,5 @@
import { useEffect, useState, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { useQueryClient } from '@tanstack/react-query';
import { ArrowDownLeft, ArrowUpRight, Mail } from 'lucide-react';
import {
@@ -29,15 +30,16 @@ function daysLeft(expiresAt: string): number {
}
function ExpiryChip({ expiresAt }: { expiresAt: string }) {
const { t } = useTranslation('invitations');
const left = daysLeft(expiresAt);
const label =
left < 0
? 'po terminie'
? t('expiryOverdue')
: left === 0
? 'wygasa dziś'
? t('expiryToday')
: left === 1
? 'wygasa jutro'
: `wygasa za ${left} dni`;
? t('expiryTomorrow')
: t('expiryInDays', { count: left });
return (
<span
className={`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[0.7rem] font-bold ${
@@ -72,6 +74,7 @@ function InvitationRow({
onDecline: () => void;
onWithdraw: () => void;
}) {
const { t } = useTranslation('invitations');
return (
<div
data-slot="list-row"
@@ -80,7 +83,7 @@ function InvitationRow({
<div className="relative shrink-0">
<Avatar name={avatarName} size={38} />
<span
title={direction === 'received' ? 'Otrzymane' : 'Wysłane'}
title={direction === 'received' ? t('received') : t('sent')}
className={`absolute -bottom-1 -right-1 grid h-[18px] w-[18px] place-items-center rounded-full border-2 border-card ${
direction === 'received' ? 'bg-info/15 text-info' : 'bg-dim/15 text-dim'
}`}
@@ -106,15 +109,15 @@ function InvitationRow({
{direction === 'received' ? (
<>
<Button size="sm" variant="secondary" onClick={onDecline}>
Odrzuć
{t('decline')}
</Button>
<Button size="sm" onClick={onAccept}>
Przyjmij
{t('accept')}
</Button>
</>
) : (
<Button size="sm" variant="secondary" onClick={onWithdraw}>
Wycofaj
{t('withdraw')}
</Button>
)}
</div>
@@ -125,6 +128,7 @@ function InvitationRow({
function GymInvitationRow({ invitation }: { invitation: GymInvitation }) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('invitations');
const act = async (kind: 'accept' | 'decline' | 'withdraw') => {
try {
@@ -138,10 +142,10 @@ function GymInvitationRow({ invitation }: { invitation: GymInvitation }) {
]);
push(
kind === 'accept'
? 'Zaproszenie przyjęte'
? t('toastAccepted')
: kind === 'decline'
? 'Zaproszenie odrzucone'
: 'Zaproszenie wycofane',
? t('toastDeclined')
: t('toastWithdrawn'),
'success',
);
} catch (e) {
@@ -158,11 +162,13 @@ function GymInvitationRow({ invitation }: { invitation: GymInvitation }) {
<InvitationRow
title={invitation.gym.name}
avatarName={invitation.gym.name}
badge={<Badge color="blue">Siłownia</Badge>}
badge={<Badge color="blue">{t('badgeGym')}</Badge>}
meta={
<>
{invitation.gym.location ? `${invitation.gym.location} · ` : ''}
{invitation.direction === 'received' ? `zaprosił: ${personName}` : `do: ${personName}`}
{invitation.direction === 'received'
? t('invitedBy', { name: personName })
: t('toPerson', { name: personName })}
</>
}
expiresAt={invitation.expiresAt}
@@ -177,6 +183,7 @@ function GymInvitationRow({ invitation }: { invitation: GymInvitation }) {
function CoachingInvitationRow({ invitation }: { invitation: Invitation }) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('invitations');
const other = invitation.other;
const name = other ? displayName(other) : '—';
@@ -192,10 +199,10 @@ function CoachingInvitationRow({ invitation }: { invitation: Invitation }) {
]);
push(
kind === 'accept'
? 'Zaproszenie przyjęte'
? t('toastAccepted')
: kind === 'decline'
? 'Zaproszenie odrzucone'
: 'Zaproszenie wycofane',
? t('toastDeclined')
: t('toastWithdrawn'),
'success',
);
} catch (e) {
@@ -207,7 +214,7 @@ function CoachingInvitationRow({ invitation }: { invitation: Invitation }) {
<InvitationRow
title={name}
avatarName={name}
badge={<Badge color="gray">Trener</Badge>}
badge={<Badge color="gray">{t('nav:roleTrainer')}</Badge>}
meta={<>{other ? `${other.email}${other.phone ? ` · ${other.phone}` : ''}` : ''}</>}
expiresAt={invitation.expiresAt}
direction={invitation.direction}
@@ -219,6 +226,7 @@ function CoachingInvitationRow({ invitation }: { invitation: Invitation }) {
}
export default function Invitations() {
const { t } = useTranslation('invitations');
const { data, isLoading, error } = useInvitations();
const { data: gymData, isLoading: gymLoading, error: gymError } = useGymInvitations();
const [scope, setScope] = useState<'all' | 'in' | 'out'>('all');
@@ -233,7 +241,7 @@ export default function Invitations() {
// Wyszukiwarka w top menu ma sens dopiero przy więcej niż jednym zaproszeniu.
useTopbar({
title: 'Zaproszenia',
title: t('nav:invitations'),
search: all.length > 1 ? 'invitations' : undefined,
});
@@ -270,15 +278,15 @@ export default function Invitations() {
/* Filtr zakresu (front-end): wszystkie / przychodzące / wychodzące. */
const scopes: { id: 'all' | 'in' | 'out'; label: string; count: number }[] = [
{ id: 'all', label: 'Wszystkie', count: all.length },
{ id: 'all', label: t('common:all'), count: all.length },
{
id: 'in',
label: 'Przychodzące',
label: t('scopeIn'),
count: all.filter((i) => i.data.direction === 'received').length,
},
{
id: 'out',
label: 'Wychodzące',
label: t('scopeOut'),
count: all.filter((i) => i.data.direction === 'sent').length,
},
];
@@ -291,19 +299,25 @@ export default function Invitations() {
<Skeleton className="h-24" />
</div>
)}
{error && <ErrorText>Błąd: {(error as Error).message}</ErrorText>}
{gymError && <ErrorText>Błąd: {(gymError as Error).message}</ErrorText>}
{error && (
<ErrorText>
{t('common:errorPrefix')}
{(error as Error).message}
</ErrorText>
)}
{gymError && (
<ErrorText>
{t('common:errorPrefix')}
{(gymError as Error).message}
</ErrorText>
)}
{!loading && !error && !gymError && all.length === 0 && (
<Card>
<EmptyState
icon={Mail}
title="Brak aktywnych zaproszeń"
description="Zaproszenia do współpracy (trener ↔ podopieczny) i do prywatnych siłowni pojawią się tutaj."
/>
<EmptyState icon={Mail} title={t('emptyTitle')} description={t('emptyDesc')} />
</Card>
)}
{!loading && !error && !gymError && all.length > 0 && (
<div className="mb-4 flex flex-wrap gap-1.5" role="group" aria-label="Filtruj zaproszenia">
<div className="mb-4 flex flex-wrap gap-1.5" role="group" aria-label={t('filterAria')}>
{scopes.map((s) => (
<button
key={s.id}
@@ -324,13 +338,13 @@ export default function Invitations() {
)}
{!loading && !error && !gymError && all.length > 0 && filtered.length === 0 && (
<Card>
<p className="text-dim">Brak wyników dla podanego zapytania.</p>
<p className="text-dim">{t('searchNoResults')}</p>
</Card>
)}
{scope !== 'out' && received.length > 0 && (
<section className="mb-5">
<H2 className="mb-3">Otrzymane</H2>
<H2 className="mb-3">{t('received')}</H2>
<Card>
<div className="divide-y divide-line">{received.map(renderRow)}</div>
</Card>
@@ -339,7 +353,7 @@ export default function Invitations() {
{scope !== 'in' && sent.length > 0 && (
<section>
<H2 className="mb-3">Wysłane</H2>
<H2 className="mb-3">{t('sent')}</H2>
<Card>
<div className="divide-y divide-line">{sent.map(renderRow)}</div>
</Card>

View File

@@ -1,3 +1,4 @@
import { useTranslation } from 'react-i18next';
import { useQueryClient } from '@tanstack/react-query';
import { Megaphone } from 'lucide-react';
import { markFeedAllRead, useFeed } from '../../api/queries';
@@ -7,7 +8,8 @@ import { useToast } from '../../components/toast';
import { useTopbar } from '../../topbar';
export default function Announcements() {
useTopbar({ title: 'Aktualności' });
const { t } = useTranslation('feed');
useTopbar({ title: t('nav:announcements') });
const queryClient = useQueryClient();
const { push } = useToast();
const { data, isLoading, error, hasNextPage, isFetchingNextPage, fetchNextPage } = useFeed(20);
@@ -17,14 +19,20 @@ export default function Announcements() {
try {
await markFeedAllRead();
await queryClient.invalidateQueries({ queryKey: ['feed'] });
push('Wszystko oznaczone jako przeczytane', 'success');
push(t('markAllToast'), 'success');
} catch (err) {
push((err as Error).message, 'error');
}
};
if (isLoading) return <Loading />;
if (error) return <ErrorText>Błąd: {(error as Error).message}</ErrorText>;
if (error)
return (
<ErrorText>
{t('common:errorPrefix')}
{(error as Error).message}
</ErrorText>
);
return (
<>
@@ -32,16 +40,12 @@ export default function Announcements() {
{items.some((i) => !i.read) && (
<div className="mb-3 flex justify-end">
<Button variant="secondary" size="sm" type="button" onClick={() => void markAll()}>
Oznacz wszystkie
{t('markAll')}
</Button>
</div>
)}
{items.length === 0 ? (
<EmptyState
icon={Megaphone}
title="Brak aktualności"
description="Tu pojawią się plany od trenera i ogłoszenia siłowni."
/>
<EmptyState icon={Megaphone} title={t('emptyTitle')} description={t('emptyDesc')} />
) : (
<div className="-mx-2">
{items.map((item) => (
@@ -57,7 +61,7 @@ export default function Announcements() {
disabled={isFetchingNextPage}
onClick={() => void fetchNextPage()}
>
{isFetchingNextPage ? 'Wczytywanie…' : 'Wczytaj starsze'}
{isFetchingNextPage ? t('loading') : t('loadOlder')}
</Button>
</div>
)}

View File

@@ -28,7 +28,7 @@ import {
withdrawGymInvitation,
} from '../../api/queries';
import type { Gym, GymEquipment, GymException } from '../../api/types';
import { fmtDateTime } from '../../lib/format';
import { fmtDate, fmtDateTime } from '../../lib/format';
import { localizedName } from '../../lib/localizedName';
import { formatGymEquipment } from '../../lib/equipment';
import {
@@ -49,7 +49,7 @@ 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 } from '../../lib/availability';
import { normalizeAvailability, TIME_SLOTS, dayFull } from '../../lib/availability';
import ClaimModal from '../../components/gyms/ClaimModal';
import InviteGymModal from '../../components/gyms/InviteGymModal';
import GymGallery from '../../components/gyms/GymGallery';
@@ -57,11 +57,11 @@ import { EquipmentSection, GymEditForm } from './GymSections';
/* Lista godzin otwarcia: wiersz na dzień (czytelna w wąskiej kolumnie), „dziś” wyróżnione. */
function HoursList({ gym }: { gym: Gym }) {
const { t } = useTranslation('gyms');
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';
r ? `${r.start}–${r.end}` : t('hours.closed');
return (
<div className="flex flex-col gap-1">
{availability.map((day, i) => (
@@ -72,10 +72,10 @@ function HoursList({ gym }: { gym: Gym }) {
}`}
>
<span className={`flex items-center gap-2 ${day ? 'font-semibold' : 'text-dim/70'}`}>
{DOWS[i]}
{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">
dziś
{t('common:fmt.today')}
</span>
)}
</span>
@@ -90,9 +90,10 @@ function HoursList({ gym }: { gym: Gym }) {
/* Mozaika galerii (read-only): pierwsze zdjęcie duże, reszta siatką, „+N” na końcu. */
function GalleryMosaic({ gym }: { gym: Gym & { photos: { id: string; url: string }[] } }) {
const { t } = useTranslation('gyms');
const photos = gym.photos;
if (photos.length === 0) {
return <p className="text-[0.875rem] text-dim">Brak zdjęć.</p>;
return <p className="text-[0.875rem] text-dim">{t('gallery.empty')}</p>;
}
const [first, ...rest] = photos;
return (
@@ -110,7 +111,7 @@ function GalleryMosaic({ gym }: { gym: Gym & { photos: { id: string; url: string
))}
{rest.length > 3 && (
<div className="grid place-items-center rounded-[10px] border border-line bg-input text-[0.8rem] font-extrabold text-accent-text">
+{rest.length - 3} zdjęć
{t('detail.photoMore', { count: rest.length - 3 })}
</div>
)}
</div>
@@ -121,8 +122,9 @@ function GalleryMosaic({ gym }: { gym: Gym & { photos: { id: string; url: string
function EquipmentTiles({ gym }: { gym: Gym }) {
const [preview, setPreview] = useState<GymEquipment | null>(null);
const { i18n } = useTranslation();
const { t } = useTranslation('gyms');
if (gym.equipment.length === 0) {
return <p className="text-[0.875rem] text-dim">Brak urządzeń.</p>;
return <p className="text-[0.875rem] text-dim">{t('detail.noEquipment')}</p>;
}
const photos = preview?.photos ?? [];
return (
@@ -149,7 +151,9 @@ function EquipmentTiles({ gym }: { gym: Gym }) {
key={e.id}
type="button"
onClick={() => setPreview(e)}
aria-label={`Zdjęcia: ${localizedName(e.equipment, i18n.language)}`}
aria-label={t('detail.photosAria', {
name: localizedName(e.equipment, i18n.language),
})}
className="flex cursor-pointer items-center gap-2 rounded-[10px] border border-line bg-card/50 px-3 py-2.5 text-left text-[0.85rem] font-semibold hover:border-accent/55"
>
{content}
@@ -167,7 +171,11 @@ function EquipmentTiles({ gym }: { gym: Gym }) {
<Modal
open={preview != null}
onClose={() => setPreview(null)}
title={preview ? `Zdjęcia: ${localizedName(preview.equipment, i18n.language)}` : ''}
title={
preview
? t('detail.photosAria', { name: localizedName(preview.equipment, i18n.language) })
: ''
}
>
<div className="grid grid-cols-2 gap-2">
{photos.map((p) => (
@@ -188,6 +196,7 @@ function EquipmentTiles({ gym }: { gym: Gym }) {
function ExceptionsList({ gymId, canManage }: { gymId: string; canManage: boolean }) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const { data, isLoading } = useGymExceptions(gymId);
const exceptions: GymException[] = data?.exceptions ?? [];
@@ -195,7 +204,7 @@ function ExceptionsList({ gymId, canManage }: { gymId: string; canManage: boolea
try {
await deleteGymException(gymId, exceptionId);
await queryClient.invalidateQueries({ queryKey: ['gym-exceptions', gymId] });
push('Wyjątek usunięty', 'success');
push(t('exceptions.removedToast'), 'success');
} catch (err) {
push((err as Error).message, 'error');
}
@@ -203,7 +212,7 @@ function ExceptionsList({ gymId, canManage }: { gymId: string; canManage: boolea
if (isLoading) return <Loading />;
if (exceptions.length === 0) {
return <p className="text-[0.875rem] text-dim">Brak wyjątków.</p>;
return <p className="text-[0.875rem] text-dim">{t('exceptions.empty')}</p>;
}
return (
<div className="flex flex-col gap-2">
@@ -213,14 +222,16 @@ function ExceptionsList({ gymId, canManage }: { gymId: string; canManage: boolea
className="flex items-center gap-3 rounded-[10px] border border-dashed border-danger/40 bg-danger/7 px-3 py-2"
>
<span className="font-display text-[0.85rem] font-bold tabular-nums">
{new Date(ex.date).toLocaleDateString('pl-PL')}
{fmtDate(ex.date)}
</span>
<span className="min-w-0 flex-1 truncate text-dim text-[0.8125rem]">
{ex.availability ? `${ex.availability.start}–${ex.availability.end}` : 'zamknięte'}
{ex.availability
? `${ex.availability.start}–${ex.availability.end}`
: t('hours.closed')}
</span>
{canManage && (
<Button variant="danger" size="sm" type="button" onClick={() => void remove(ex.id)}>
Usuń
{t('common:remove')}
</Button>
)}
</div>
@@ -233,6 +244,7 @@ function ExceptionsList({ gymId, canManage }: { gymId: string; canManage: boolea
function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void }) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const [date, setDate] = useState('');
const [closed, setClosed] = useState(true);
const [start, setStart] = useState('18:00');
@@ -244,7 +256,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
try {
await createGymException(gymId, { date, availability: closed ? null : { start, end } });
await queryClient.invalidateQueries({ queryKey: ['gym-exceptions', gymId] });
push('Wyjątek dodany', 'success');
push(t('exceptions.addedToast'), 'success');
setDate('');
onDone();
} catch (err) {
@@ -257,7 +269,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
return (
<div className="rounded-xl border border-line bg-input/40 p-3.5">
<div className="mb-2.5 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Dodaj wyjątek — data i tryb dnia
{t('exceptions.addTitle')}
</div>
{/* wiersz 1: data + tryb; na wąskich ekranach każde przechodzi na pełną szerokość */}
<div className="flex flex-wrap gap-2.5">
@@ -265,7 +277,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
type="date"
value={date}
onChange={(e) => setDate(e.target.value)}
aria-label="Data wyjątku"
aria-label={t('exceptions.dateAria')}
className="w-full min-w-0 sm:w-44 sm:flex-none"
required
/>
@@ -278,7 +290,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
closed ? 'bg-accent text-accent-ink' : 'text-dim hover:text-ink'
}`}
>
Zamknięte
{t('exceptions.closedMode')}
</button>
<button
type="button"
@@ -288,7 +300,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
!closed ? 'bg-accent text-accent-ink' : 'text-dim hover:text-ink'
}`}
>
Inne godziny
{t('exceptions.hoursMode')}
</button>
</div>
</div>
@@ -298,7 +310,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
<Select
value={start}
onChange={(e) => setStart(e.target.value)}
aria-label="Od godziny"
aria-label={t('exceptions.fromAria')}
className="min-w-0 flex-1 sm:flex-none sm:basis-28"
>
{TIME_SLOTS.map((s) => (
@@ -310,7 +322,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
<Select
value={end}
onChange={(e) => setEnd(e.target.value)}
aria-label="Do godziny"
aria-label={t('exceptions.toAria')}
className="min-w-0 flex-1 sm:flex-none sm:basis-28"
>
{TIME_SLOTS.map((s) => (
@@ -325,7 +337,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
disabled={busy || !date}
className="w-full sm:ml-auto sm:w-auto"
>
{busy ? 'Dodawanie…' : 'Dodaj'}
{busy ? t('equipment.adding') : t('equipment.addBtn')}
</Button>
</div>
)}
@@ -337,7 +349,7 @@ function ExceptionAddForm({ gymId, onDone }: { gymId: string; onDone: () => void
disabled={busy || !date}
className="w-full sm:w-auto"
>
{busy ? 'Dodawanie…' : 'Dodaj'}
{busy ? t('equipment.adding') : t('equipment.addBtn')}
</Button>
</div>
)}
@@ -368,6 +380,7 @@ export default function GymDetail() {
const navigate = useNavigate();
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const { data, isLoading, error } = useGymDetail(id);
const { data: claimsData } = useMyGymClaims();
const gym = data?.gym;
@@ -410,7 +423,7 @@ export default function GymDetail() {
queryClient.invalidateQueries({ queryKey: ['gyms', 'claims'] }),
queryClient.invalidateQueries({ queryKey: ['gyms', 'virtual'] }),
]);
push('Wniosek wycofany', 'success');
push(t('detail.claimWithdrawnToast'), 'success');
} catch (e) {
push((e as Error).message, 'error');
} finally {
@@ -424,39 +437,45 @@ export default function GymDetail() {
? [
{
id: 'edit',
label: 'Edycja',
label: t('detail.groupEdit'),
icon: Pencil,
actions: [{ label: 'Informacje', onClick: () => setEditOpen(true) }],
actions: [{ label: t('detail.actionInfo'), onClick: () => setEditOpen(true) }],
},
...(gym.kind === 'REAL'
? [
{
id: 'gallery',
label: 'Galeria',
label: t('detail.groupGallery'),
icon: ImageIcon,
actions: [{ label: 'Galeria', onClick: () => setGalleryOpen(true) }],
actions: [
{ label: t('detail.groupGallery'), onClick: () => setGalleryOpen(true) },
],
} as TopbarCustomGroup,
]
: []),
{
id: 'equipment',
label: 'Urządzenia',
label: t('detail.groupEquipment'),
icon: Wrench,
actions: [{ label: 'Urządzenia', onClick: () => setEquipmentOpen(true) }],
actions: [{ label: t('detail.groupEquipment'), onClick: () => setEquipmentOpen(true) }],
},
{
id: 'announcements',
label: 'Ogłoszenia',
label: t('detail.groupAnnouncements'),
icon: Megaphone,
actions: [{ label: 'Ogłoszenia', onClick: () => setAnnouncementsOpen(true) }],
actions: [
{ label: t('detail.groupAnnouncements'), onClick: () => setAnnouncementsOpen(true) },
],
},
...(gym.kind === 'VIRTUAL' && gym.isPrivate
? [
{
id: 'invite',
label: 'Zaproszenia',
label: t('detail.groupInvites'),
icon: UserPlus,
actions: [{ label: 'Zaproś usera', onClick: () => setInviteOpen(true) }],
actions: [
{ label: t('detail.actionInvite'), onClick: () => setInviteOpen(true) },
],
} as TopbarCustomGroup,
]
: []),
@@ -470,7 +489,7 @@ export default function GymDetail() {
? claim
? ([
{
label: 'Wycofaj wniosek',
label: t('detail.actionWithdrawClaim'),
variant: 'secondary',
disabled: claimBusy,
onClick: () => void withdrawClaim(),
@@ -478,17 +497,21 @@ export default function GymDetail() {
] as TopbarAction[])
: ([
{
label: 'Złóż wniosek o weryfikację',
label: t('detail.actionClaimVerify'),
variant: 'secondary',
onClick: () => setClaimOpen(true),
},
] as TopbarAction[])
: []),
{ label: 'Usuń siłownię', variant: 'danger', onClick: () => setConfirmOpen(true) },
{
label: t('detail.actionDelete'),
variant: 'danger',
onClick: () => setConfirmOpen(true),
},
]
: undefined;
useTopbar({ title: 'Siłownie', back: '/gyms', groups, actions: ownerActions });
useTopbar({ title: t('nav:gyms'), back: '/gyms', groups, actions: ownerActions });
if (isLoading) return <Loading />;
if (error || !gym) {
@@ -496,9 +519,9 @@ export default function GymDetail() {
<>
<Link to="/gyms" className="mb-4 inline-flex items-center gap-2 text-dim hover:text-ink">
<ArrowLeft className="h-4 w-4" />
Wstecz
{t('common:back')}
</Link>
<ErrorText>Nie znaleziono siłowni.</ErrorText>
<ErrorText>{t('detail.notFound')}</ErrorText>
</>
);
}
@@ -550,25 +573,25 @@ export default function GymDetail() {
</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" />
{gym.capacity != null ? `${gym.capacity} miejsc` : '—'}
{gym.capacity != null ? t('detail.places', { count: gym.capacity }) : '—'}
</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">
<Dumbbell className="h-3 w-3" />
{gym.equipment.length} urządzeń
{t('common:counters.devices', { count: gym.equipment.length })}
</span>
{gym.kind === 'VIRTUAL' && (
<span className="rounded-full bg-white/14 px-3 py-1 text-[0.78rem] font-semibold text-white backdrop-blur-sm">
Wirtualna
{t('detail.chipVirtual')}
</span>
)}
{gym.isPrivate && (
<span className="rounded-full bg-white/14 px-3 py-1 text-[0.78rem] font-semibold text-white backdrop-blur-sm">
Prywatna
{t('detail.chipPrivate')}
</span>
)}
{isOwner && (
<span className="rounded-full bg-(image:--btn-grad) px-3 py-1 text-[0.78rem] font-bold text-accent-ink">
Właściciel
{t('common:statuses.gymRole.OWNER')}
</span>
)}
</div>
@@ -588,14 +611,14 @@ export default function GymDetail() {
<div className="flex min-w-0 flex-col gap-4">
{gym.kind === 'REAL' && (
<Card>
<SectionHeader title="Galeria zdjęć" />
<SectionHeader title={t('detail.galleryTitle')} />
<GalleryMosaic gym={gym} />
</Card>
)}
<Card>
<SectionHeader
title="Urządzenia"
description="Maszyny i urządzenia dostępne w tej siłowni."
title={t('detail.equipmentTitle')}
description={t('detail.equipmentDesc')}
/>
<EquipmentTiles gym={gym} />
</Card>
@@ -603,38 +626,38 @@ export default function GymDetail() {
<div className="flex min-w-0 flex-col gap-4">
<Card>
<SectionHeader title="Godziny otwarcia" />
<SectionHeader title={t('detail.hoursTitle')} />
<HoursList gym={gym} />
<div className="mt-4 mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Wyjątki
{t('detail.exceptionsLabel')}
</div>
<ExceptionsList gymId={gym.id} canManage={isOwner} />
</Card>
<Card>
<SectionHeader title="Dane" />
<SectionHeader title={t('detail.dataTitle')} />
<div className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5 text-[0.85rem]">
<span className="text-dim">Rodzaj</span>
<b>{gym.kind === 'REAL' ? 'Realna' : 'Wirtualna'}</b>
<span className="text-dim">Prywatna</span>
<b>{gym.isPrivate ? 'tak' : 'nie'}</b>
<span className="text-dim">Pojemność</span>
<span className="text-dim">{t('detail.dataKind')}</span>
<b>{gym.kind === 'REAL' ? t('create.kindReal') : t('create.kindVirtual')}</b>
<span className="text-dim">{t('detail.dataPrivate')}</span>
<b>{gym.isPrivate ? t('common:yes') : t('common:no')}</b>
<span className="text-dim">{t('detail.dataCapacity')}</span>
<b className="font-display tabular-nums">{gym.capacity ?? '—'}</b>
{gym.addressLine1 || gym.postalCode || gym.city ? (
<>
<span className="text-dim">Ulica</span>
<span className="text-dim">{t('detail.dataStreet')}</span>
<b>{[gym.addressLine1, gym.addressLine2].filter(Boolean).join(', ') || '—'}</b>
<span className="text-dim">Kod i miasto</span>
<span className="text-dim">{t('detail.dataPostalCity')}</span>
<b>{[gym.postalCode, gym.city].filter(Boolean).join(' ') || '—'}</b>
{gym.countryCode && gym.countryCode !== 'PL' && (
<>
<span className="text-dim">Kraj</span>
<span className="text-dim">{t('detail.dataCountry')}</span>
<b>{gym.countryCode}</b>
</>
)}
</>
) : (
<>
<span className="text-dim">Lokalizacja</span>
<span className="text-dim">{t('detail.dataLocation')}</span>
<b>{gym.location ?? '—'}</b>
</>
)}
@@ -649,7 +672,12 @@ export default function GymDetail() {
{/* MODALE właściciela (otwierane z grup menu kontekstowego) */}
{gym && (
<>
<Modal wide open={editOpen} onClose={() => setEditOpen(false)} title="Informacje">
<Modal
wide
open={editOpen}
onClose={() => setEditOpen(false)}
title={t('detail.modalInfo')}
>
<GymEditForm
key={gym.id}
gym={gym}
@@ -660,27 +688,31 @@ export default function GymDetail() {
/>
<div className="mt-6 border-t border-line pt-5">
<SectionHeader
title="Wyjątki w harmonogramie"
description="Jednorazowe zmiany na konkretny dzień (zamknięcie lub inne godziny)."
title={t('detail.exceptionsTitle')}
description={t('detail.exceptionsDesc')}
/>
<ExceptionsBlock gymId={gym.id} canManage={isOwner} />
</div>
</Modal>
<Modal open={galleryOpen} onClose={() => setGalleryOpen(false)} title="Zarządzaj galerią">
<Modal
open={galleryOpen}
onClose={() => setGalleryOpen(false)}
title={t('detail.modalGallery')}
>
<GymGallery gym={gym} canManage={canManage} onChanged={() => {}} />
</Modal>
<Modal
wide
open={equipmentOpen}
onClose={() => setEquipmentOpen(false)}
title="Zarządzaj urządzeniami"
title={t('detail.modalEquipment')}
>
<EquipmentSection key={gym.id} gym={gym} />
</Modal>
<Modal
open={announcementsOpen}
onClose={() => setAnnouncementsOpen(false)}
title="Ogłoszenia"
title={t('detail.modalAnnouncements')}
>
<AnnouncementsSection gymId={gym.id} />
</Modal>
@@ -705,9 +737,9 @@ export default function GymDetail() {
open={confirmOpen}
onClose={() => setConfirmOpen(false)}
onConfirm={remove}
title="Usuń siłownię"
description="Usunąć siłownię? Członkostwa zostaną usunięte, plany użytkowników zachowane."
confirmLabel="Usuń"
title={t('detail.actionDelete')}
description={t('detail.deleteDesc')}
confirmLabel={t('common:remove')}
danger
busy={busy}
/>
@@ -719,6 +751,7 @@ export default function GymDetail() {
function AnnouncementsSection({ gymId }: { gymId: string }) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const { data, isLoading } = useGymAnnouncements(gymId);
const announcements = data?.announcements ?? [];
const [title, setTitle] = useState('');
@@ -737,7 +770,7 @@ function AnnouncementsSection({ gymId }: { gymId: string }) {
try {
await createGymAnnouncement(gymId, { title, body });
await invalidate();
push('Ogłoszenie opublikowane', 'success');
push(t('announcements.toastPublished'), 'success');
setTitle('');
setBody('');
} catch (err) {
@@ -751,7 +784,7 @@ function AnnouncementsSection({ gymId }: { gymId: string }) {
try {
await deleteGymAnnouncement(gymId, id);
await invalidate();
push('Ogłoszenie usunięte', 'success');
push(t('announcements.toastRemoved'), 'success');
} catch (err) {
push((err as Error).message, 'error');
}
@@ -761,20 +794,20 @@ function AnnouncementsSection({ gymId }: { gymId: string }) {
<div>
<div className="rounded-xl border border-line bg-input/40 p-3.5">
<div className="mb-2.5 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Nowe ogłoszenie — trafi do wszystkich członków siłowni
{t('announcements.composerTitle')}
</div>
<Input
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder="Tytuł (np. Awarida klimatyzacji)"
aria-label="Tytuł ogłoszenia"
placeholder={t('announcements.titlePh')}
aria-label={t('announcements.titleAria')}
maxLength={120}
/>
<Textarea
value={body}
onChange={(e) => setBody(e.target.value)}
placeholder="Treść ogłoszenia…"
aria-label="Treść ogłoszenia"
placeholder={t('announcements.bodyPh')}
aria-label={t('announcements.bodyAria')}
maxLength={2000}
rows={3}
className="mt-2.5"
@@ -785,14 +818,14 @@ function AnnouncementsSection({ gymId }: { gymId: string }) {
onClick={() => void add()}
disabled={busy || !title.trim() || !body.trim()}
>
{busy ? 'Publikowanie…' : 'Opublikuj'}
{busy ? t('announcements.publishing') : t('announcements.publish')}
</Button>
</div>
<div className="mt-4">
{isLoading ? (
<Loading />
) : announcements.length === 0 ? (
<p className="text-[0.875rem] text-dim">Brak ogłoszeń.</p>
<p className="text-[0.875rem] text-dim">{t('announcements.empty')}</p>
) : (
<div className="flex flex-col gap-2">
{announcements.map((a) => (
@@ -801,7 +834,7 @@ function AnnouncementsSection({ gymId }: { gymId: string }) {
<span className="min-w-0 flex-1 truncate text-[0.9rem] font-bold">{a.title}</span>
{a.kind !== 'MANUAL' && (
<span className="shrink-0 rounded-full bg-dim/13 px-2 py-0.5 text-[0.65rem] font-extrabold uppercase tracking-wide text-dim">
Systemowe
{t('announcements.systemBadge')}
</span>
)}
<span className="shrink-0 text-[0.72rem] tabular-nums text-dim">
@@ -834,6 +867,7 @@ function AnnouncementsSection({ gymId }: { gymId: string }) {
function GymInvitationsSection({ gym }: { gym: Gym }) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const { data } = useGymInvitations();
const sent = (data?.invitations ?? []).filter(
(i) => i.direction === 'sent' && i.gym.id === gym.id,
@@ -843,7 +877,7 @@ function GymInvitationsSection({ gym }: { gym: Gym }) {
try {
await withdrawGymInvitation(id);
await queryClient.invalidateQueries({ queryKey: ['gym-invitations'] });
push('Zaproszenie wycofane', 'success');
push(t('invites.toastWithdrawn'), 'success');
} catch (e) {
push((e as Error).message, 'error');
}
@@ -851,13 +885,10 @@ function GymInvitationsSection({ gym }: { gym: Gym }) {
return (
<Card>
<SectionHeader
title="Zaproszenia"
description="Prywatna siłownia jest ukryta — zapraszaj określonych userów."
/>
<SectionHeader title={t('detail.groupInvites')} description={t('invites.desc')} />
<div className="divide-y divide-line">
{sent.length === 0 && (
<span className="py-3 text-[0.875rem] text-dim">Brak wysłanych zaproszeń.</span>
<span className="py-3 text-[0.875rem] text-dim">{t('invites.empty')}</span>
)}
{sent.map((inv) => {
const name =
@@ -880,7 +911,7 @@ function GymInvitationsSection({ gym }: { gym: Gym }) {
type="button"
onClick={() => void withdraw(inv.id)}
>
Wycofaj
{t('invites.withdraw')}
</Button>
}
/>

View File

@@ -33,6 +33,7 @@ import { normalizeAvailability } from '../../lib/availability';
/** Formularz edycji danych siłowni (nazwa/adres|lokalizacja/pojemność/prywatność/dostępność). */
export function GymEditForm({ gym, onSaved }: { gym: Gym; onSaved: () => void }) {
const { push } = useToast();
const { t } = useTranslation('gyms');
const isReal = gym.kind === 'REAL';
const [form, setForm] = useState({
name: gym.name,
@@ -70,7 +71,7 @@ export function GymEditForm({ gym, onSaved }: { gym: Gym; onSaved: () => void })
isPrivate: gym.kind === 'VIRTUAL' ? form.isPrivate : undefined,
});
onSaved();
push('Zapisano zmiany', 'success');
push(t('sections.savedToast'), 'success');
} catch (err) {
push((err as Error).message, 'error');
} finally {
@@ -81,7 +82,7 @@ export function GymEditForm({ gym, onSaved }: { gym: Gym; onSaved: () => void })
return (
<form onSubmit={submit}>
<div className="grid grid-cols-1 gap-x-4 sm:grid-cols-2">
<Field label="Nazwa">
<Field label={t('sections.nameLabel')}>
<Input
value={form.name}
onChange={(e) => setForm({ ...form, name: e.target.value })}
@@ -89,14 +90,14 @@ export function GymEditForm({ gym, onSaved }: { gym: Gym; onSaved: () => void })
/>
</Field>
{!isReal && (
<Field label="Lokalizacja">
<Field label={t('sections.locationLabel')}>
<Input
value={form.location}
onChange={(e) => setForm({ ...form, location: e.target.value })}
/>
</Field>
)}
<Field label="Pojemność (osób)">
<Field label={t('sections.capacityLabel')}>
<Input
type="number"
value={form.capacity}
@@ -120,7 +121,7 @@ export function GymEditForm({ gym, onSaved }: { gym: Gym; onSaved: () => void })
onChange={(e) => setForm({ ...form, isPrivate: e.target.checked })}
className="h-4 w-4 accent-accent"
/>
Prywatna (ukryta przed innymi — dostęp tylko po zaproszeniu)
{t('sections.privateEdit')}
</label>
)}
<div className="my-4 border-t border-line" />
@@ -131,7 +132,7 @@ export function GymEditForm({ gym, onSaved }: { gym: Gym; onSaved: () => void })
/>
</div>
<Button type="submit" disabled={busy || !addressOk}>
{busy ? 'Zapisywanie…' : 'Zapisz'}
{busy ? t('common:saving') : t('common:save')}
</Button>
</form>
);
@@ -152,12 +153,13 @@ function PhotoPicker({
label: string;
}) {
const { push } = useToast();
const { t } = useTranslation('gyms');
return (
<div>
<div className="flex flex-wrap items-center gap-2.5">
<label className="inline-flex cursor-pointer items-center gap-1.5 rounded-[10px] border border-line bg-card px-3 py-1.5 text-[0.85rem] font-semibold text-dim transition-colors hover:border-accent/55 hover:text-accent-text">
<ImageIcon className="h-4 w-4" aria-hidden="true" />
Dodaj zdjęcia
{t('photo.addBtn')}
<input
type="file"
multiple
@@ -169,22 +171,22 @@ function PhotoPicker({
e.target.value = '';
if (picked.length === 0) return;
if (files.length + picked.length > MAX_EQUIPMENT_PHOTO_FILES) {
push(`Maksymalnie ${MAX_EQUIPMENT_PHOTO_FILES} zdjęć na urządzenie`, 'error');
push(t('photo.maxToast', { count: MAX_EQUIPMENT_PHOTO_FILES }), 'error');
return;
}
if (picked.some((f) => !EQUIPMENT_PHOTO_TYPES.includes(f.type))) {
push('Dozwolone formaty: JPG, PNG, WebP', 'error');
push(t('photo.formatsToast'), 'error');
return;
}
if (picked.some((f) => f.size > MAX_EQUIPMENT_PHOTO_SIZE)) {
push('Maksymalny rozmiar zdjęcia to 5 MB', 'error');
push(t('photo.sizeToast'), 'error');
return;
}
onChange([...files, ...picked]);
}}
/>
</label>
<span className="text-[0.8125rem] text-dim">JPG, PNG lub WebP · maks. 5 MB</span>
<span className="text-[0.8125rem] text-dim">{t('photo.formatsHint')}</span>
</div>
{files.length > 0 && (
<div className="mt-2 flex flex-wrap gap-2">
@@ -198,7 +200,7 @@ function PhotoPicker({
<button
type="button"
onClick={() => onChange(files.filter((_, j) => j !== i))}
aria-label={`Usuń ${f.name}`}
aria-label={t('photo.removeFileAria', { name: f.name })}
className="absolute -top-1.5 -right-1.5 grid h-5 w-5 cursor-pointer place-items-center rounded-full border border-line bg-card text-danger"
>
<X className="h-3 w-3" aria-hidden="true" />
@@ -221,27 +223,28 @@ function SpecFieldsEditor({
values: SpecFields;
onChange: (patch: Partial<SpecFields>) => void;
}) {
const { t } = useTranslation('gyms');
if (LOAD_RANGE_KINDS.includes(kind)) {
return (
<div className="grid grid-cols-2 gap-x-4 gap-y-2">
<Field label="Min. obciążenie (kg)">
<Field label={t('spec.minKg')}>
<Input
type="number"
min={0}
max={500}
step="any"
aria-label="Min. obciążenie (kg)"
aria-label={t('spec.minKg')}
value={values.minKg}
onChange={(e) => onChange({ minKg: e.target.value })}
/>
</Field>
<Field label="Max. obciążenie (kg)">
<Field label={t('spec.maxKg')}>
<Input
type="number"
min={0}
max={500}
step="any"
aria-label="Max. obciążenie (kg)"
aria-label={t('spec.maxKg')}
value={values.maxKg}
onChange={(e) => onChange({ maxKg: e.target.value })}
/>
@@ -251,13 +254,13 @@ function SpecFieldsEditor({
}
if (MAX_LOAD_KINDS.includes(kind)) {
return (
<Field label="Maksymalne obciążenie (kg)">
<Field label={t('spec.maxLoadKg')}>
<Input
type="number"
min={0}
max={1000}
step="any"
aria-label="Maksymalne obciążenie (kg)"
aria-label={t('spec.maxLoadKg')}
value={values.maxLoadKg}
onChange={(e) => onChange({ maxLoadKg: e.target.value })}
/>
@@ -267,24 +270,24 @@ function SpecFieldsEditor({
if (kind === 'CARDIO') {
return (
<div className="grid grid-cols-2 gap-x-4 gap-y-2">
<Field label="Maks. prędkość (km/h)">
<Field label={t('spec.maxSpeed')}>
<Input
type="number"
min={0}
max={50}
step="any"
aria-label="Maks. prędkość (km/h)"
aria-label={t('spec.maxSpeed')}
value={values.maxSpeedKmh}
onChange={(e) => onChange({ maxSpeedKmh: e.target.value })}
/>
</Field>
<Field label="Maks. nachylenie (%)">
<Field label={t('spec.maxIncline')}>
<Input
type="number"
min={0}
max={40}
step="any"
aria-label="Maks. nachylenie (%)"
aria-label={t('spec.maxIncline')}
value={values.maxInclinePct}
onChange={(e) => onChange({ maxInclinePct: e.target.value })}
/>
@@ -299,6 +302,7 @@ function SpecFieldsEditor({
export function EquipmentSection({ gym }: { gym: Gym }) {
const queryClient = useQueryClient();
const { i18n } = useTranslation();
const { t } = useTranslation('gyms');
const { push } = useToast();
const { data: eqData, isLoading } = useEquipment();
const catalog = eqData?.equipment ?? [];
@@ -350,7 +354,7 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
return;
}
if (result.spec == null) {
push('Podaj parametry urządzenia (prędkość lub nachylenie).', 'error');
push(t('equipment.specCardioError'), 'error');
return;
}
spec = result.spec;
@@ -362,10 +366,10 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
try {
await addEquipmentPhotos(gym.id, instance.id, addFiles);
} catch {
push('Urządzenie dodane, ale nie udało się wgrać zdjęć', 'error');
push(t('equipment.addedPartialToast'), 'error');
}
}
push('Sprzęt dodany', 'success');
push(t('equipment.addedToast'), 'success');
resetAdd();
await invalidate();
} catch (err) {
@@ -389,7 +393,7 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
await removeGymEquipment(gym.id, instanceId);
if (editingId === instanceId) closeEdit();
await invalidate();
push(`Usunięto: ${name}`, 'success');
push(t('equipment.removedToast', { name }), 'success');
} catch (err) {
push((err as Error).message, 'error');
}
@@ -418,7 +422,7 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
return;
}
if (result.spec == null) {
push('Podaj parametry lub przywróć specyfikację katalogu.', 'error');
push(t('equipment.specEditError'), 'error');
return;
}
specBody = result.spec;
@@ -432,10 +436,10 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
try {
await addEquipmentPhotos(gym.id, editing.id, editFiles);
} catch {
push('Nie udało się wgrać zdjęć', 'error');
push(t('equipment.photosFailToast'), 'error');
}
}
push('Zapisano zmiany', 'success');
push(t('sections.savedToast'), 'success');
closeEdit();
await invalidate();
} catch (err) {
@@ -450,7 +454,7 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
setSavingEdit(true);
try {
await updateGymEquipment(gym.id, editing.id, { spec: null });
push('Przywrócono specyfikację katalogu', 'success');
push(t('equipment.restoreToast'), 'success');
closeEdit();
await invalidate();
} catch (err) {
@@ -480,11 +484,11 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
{/* POZYCJE NA STANIE: wiersz = miniatura + nazwa/spec + ilość + akcje */}
<div>
<div className="mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Pozycje na stanie ({gym.equipment.length})
{t('equipment.inStock', { count: gym.equipment.length })}
</div>
{gym.equipment.length === 0 ? (
<div className="rounded-[10px] border border-dashed border-line px-4 py-6 text-center text-[0.875rem] text-dim">
Brak urządzeń — dodaj pierwsze z katalogu poniżej.
{t('equipment.empty')}
</div>
) : (
<div className="flex flex-col gap-2">
@@ -514,7 +518,9 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
min={1}
max={10000}
defaultValue={e.quantity}
aria-label={`Ilość: ${localizedName(e.equipment, i18n.language)}`}
aria-label={t('equipment.qtyAria', {
name: localizedName(e.equipment, i18n.language),
})}
className="w-16 shrink-0 rounded-[10px] border border-line bg-input px-2 py-1 text-center text-[0.875rem] text-ink focus:border-accent-text focus:outline-none"
onBlur={(ev) => {
const value = parseInt(ev.target.value, 10);
@@ -532,16 +538,22 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
size="sm"
variant="secondary"
onClick={() => (editingId === e.id ? closeEdit() : openEdit(e))}
aria-label={`Edytuj ${localizedName(e.equipment, i18n.language)}`}
aria-label={t('equipment.editAria', {
name: localizedName(e.equipment, i18n.language),
})}
className="shrink-0"
>
{editingId === e.id ? 'Zamknij' : 'Edytuj'}
{editingId === e.id ? t('common:close') : t('common:edit')}
</Button>
<button
type="button"
onClick={() => void remove(e.id, localizedName(e.equipment, i18n.language))}
aria-label={`Usuń ${localizedName(e.equipment, i18n.language)}`}
title={`Usuń ${localizedName(e.equipment, i18n.language)}`}
aria-label={t('equipment.removeAria', {
name: localizedName(e.equipment, i18n.language),
})}
title={t('equipment.removeAria', {
name: localizedName(e.equipment, i18n.language),
})}
className="shrink-0 cursor-pointer rounded-lg p-1.5 text-dim transition-colors hover:bg-danger/10 hover:text-danger"
>
<Trash2 className="h-4 w-4" aria-hidden="true" />
@@ -554,12 +566,14 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
<div className="mt-2 rounded-[10px] border border-accent/55 bg-card/50 p-3.5">
<div className="mb-3 flex items-center justify-between gap-2">
<span className="font-display text-[0.95rem] font-bold">
Edycja: {localizedName(editing.equipment, i18n.language)}
{t('equipment.editTitle', {
name: localizedName(editing.equipment, i18n.language),
})}
</span>
<button
type="button"
onClick={closeEdit}
aria-label="Zamknij edycję"
aria-label={t('equipment.closeEditAria')}
className="cursor-pointer p-1 text-dim hover:text-ink"
>
<X className="h-4 w-4" aria-hidden="true" />
@@ -568,7 +582,7 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
{hasSpecFields(editing.equipment.kind) && (
<div className="mb-4">
<div className="mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Parametry pozycji
{t('equipment.itemParams')}
</div>
<SpecFieldsEditor
kind={editing.equipment.kind}
@@ -579,7 +593,10 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
)}
<div className="mb-4">
<div className="mb-1.5 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Zdjęcia ({editing.photos?.length ?? 0}/{MAX_EQUIPMENT_PHOTO_FILES})
{t('equipment.photosCount', {
n: editing.photos?.length ?? 0,
max: MAX_EQUIPMENT_PHOTO_FILES,
})}
</div>
{editing.photos && editing.photos.length > 0 && (
<div className="mb-2 flex flex-wrap gap-2">
@@ -593,7 +610,7 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
<button
type="button"
onClick={() => void removePhoto(editing, p.id)}
aria-label="Usuń zdjęcie"
aria-label={t('gallery.removeAria')}
className="absolute -top-1.5 -right-1.5 grid h-5 w-5 place-items-center rounded-full border border-line bg-card text-danger cursor-pointer"
>
<X className="h-3 w-3" aria-hidden="true" />
@@ -606,13 +623,13 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
<PhotoPicker
files={editFiles}
onChange={setEditFiles}
label="Dodaj zdjęcia urządzenia"
label={t('equipment.addPhotosLabel')}
/>
)}
</div>
<div className="flex flex-wrap items-center gap-2">
<Button size="sm" onClick={saveEdit} disabled={savingEdit}>
{savingEdit ? 'Zapisywanie…' : 'Zapisz'}
{savingEdit ? t('common:saving') : t('common:save')}
</Button>
{editing.spec != null && (
<Button
@@ -621,7 +638,7 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
onClick={restoreCatalogSpec}
disabled={savingEdit}
>
Przywróć specyfikację katalogu
{t('equipment.restoreCatalog')}
</Button>
)}
</div>
@@ -632,28 +649,28 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
{/* DODAWANIE z katalogu: pozycja zawsze z własnymi parametrami i opcjonalnymi zdjęciami */}
<div className="rounded-xl border border-line bg-input/40 p-3.5">
<div className="mb-2.5 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Dodaj urządzenie z katalogu
{t('equipment.addTitle')}
</div>
<div className="flex flex-wrap items-end gap-2.5">
<div className="min-w-0 flex-1 basis-52">
<Select
value={addId}
onChange={(e) => selectAdd(e.target.value)}
aria-label="Dodaj urządzenie"
aria-label={t('equipment.addAria')}
>
<option value="">Wybierz urządzenie…</option>
<option value="">{t('equipment.chooseDevice')}</option>
{catalog.map((e) => {
const qty = totalQty(e.id);
return (
<option key={e.id} value={e.id}>
{localizedName(e, i18n.language)}
{qty > 0 ? ` (na stanie: ${qty})` : ''}
{qty > 0 ? t('equipment.onStock', { count: qty }) : ''}
</option>
);
})}
</Select>
</div>
<Field label="Ilość" className="w-20 shrink-0">
<Field label={t('equipment.qtyLabel')} className="w-20 shrink-0">
<Input
type="number"
size="sm"
@@ -661,11 +678,11 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
max={10000}
value={addQty}
onChange={(e) => setAddQty(e.target.value)}
aria-label="Ilość"
aria-label={t('equipment.qtyLabel')}
/>
</Field>
<Button onClick={add} disabled={!addId || addBusy} className="shrink-0">
{addBusy ? 'Dodawanie…' : 'Dodaj'}
{addBusy ? t('equipment.adding') : t('equipment.addBtn')}
</Button>
</div>
{addItem && (
@@ -673,7 +690,7 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
{hasSpecFields(addItem.kind) && (
<div className="mb-3.5">
<div className="mb-2 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Parametry
{t('equipment.paramsLabel')}
</div>
<SpecFieldsEditor
kind={addItem.kind}
@@ -700,10 +717,14 @@ export function EquipmentSection({ gym }: { gym: Gym }) {
>
{addPhotosOpen && <Check className="h-3 w-3" />}
</span>
Dodaj zdjęcia do tej pozycji (opcjonalnie)
{t('equipment.addPhotosSwitch')}
</button>
{addPhotosOpen && (
<PhotoPicker files={addFiles} onChange={setAddFiles} label="Zdjęcia urządzenia" />
<PhotoPicker
files={addFiles}
onChange={setAddFiles}
label={t('equipment.photosLabel')}
/>
)}
</div>
</div>

View File

@@ -49,10 +49,11 @@ import JoinGymModal from '../../components/gyms/JoinGymModal';
type Tab = 'mine' | 'virtual';
function GymKindBadges({ gym }: { gym: { kind: string; isPrivate: boolean } }) {
const { t } = useTranslation('gyms');
return (
<>
{gym.kind === 'VIRTUAL' && <Badge color="blue">Wirtualna</Badge>}
{gym.isPrivate && <Badge color="gray">Prywatna</Badge>}
{gym.kind === 'VIRTUAL' && <Badge color="blue">{t('detail.chipVirtual')}</Badge>}
{gym.isPrivate && <Badge color="gray">{t('detail.chipPrivate')}</Badge>}
</>
);
}
@@ -78,6 +79,7 @@ function GymCard({
rating?: number | null;
children?: ReactNode;
}) {
const { t } = useTranslation('gyms');
const availability = normalizeAvailability(gym.availability);
const todayIdx = (new Date().getDay() + 6) % 7;
@@ -130,7 +132,7 @@ function GymCard({
</div>
{onClick && (
<span className="absolute bottom-2.5 right-2.5 inline-flex items-center gap-1.5 rounded-full bg-black/35 px-2.5 py-1 text-[0.7rem] font-bold text-white backdrop-blur-sm">
Otwórz →
{t('page.open')}
</span>
)}
</div>
@@ -146,12 +148,14 @@ function GymCard({
<MetaItem icon={MapPin}>{gym.location || '—'}</MetaItem>
<MetaItem icon={Users}>
{memberCount != null
? `${memberCount} członków`
? t('page.members', { count: memberCount })
: gym.capacity != null
? `${gym.capacity} miejsc`
? t('detail.places', { count: gym.capacity })
: '—'}
</MetaItem>
<MetaItem icon={Dumbbell}>{gym.equipment.length} urządzeń</MetaItem>
<MetaItem icon={Dumbbell}>
{t('common:counters.devices', { count: gym.equipment.length })}
</MetaItem>
</div>
<div className="grid grid-cols-7 gap-0.5">
{availability.map((day, i) => (
@@ -179,7 +183,7 @@ function GymCard({
))}
</div>
{rating != null && (
<div className="flex items-center gap-2.5" title="Odsetek głosów „polecam”">
<div className="flex items-center gap-2.5" title={t('page.ratingTitle')}>
<div className="flex h-2 flex-1 overflow-hidden rounded-full bg-danger/50">
<div
className="h-full rounded-full bg-(image:--progress-grad)"
@@ -199,14 +203,12 @@ function GymCard({
/* Głosy „Polecam/Nie polecam” z licznikami (aria-pressed). */
function VoteButtons({ gym, onRate }: { gym: VirtualGym; onRate: (vote: 'UP' | 'DOWN') => void }) {
const { t } = useTranslation('gyms');
return (
<div
className="flex items-center gap-2"
title="Czy ta wirtualna siłownia dobrze oddaje prawdziwą?"
>
<div className="flex items-center gap-2" title={t('page.voteTitle')}>
<button
type="button"
aria-label={`Polecam: ${gym.name}`}
aria-label={t('page.voteUpAria', { name: gym.name })}
aria-pressed={gym.myVote === 'UP'}
onClick={() => onRate('UP')}
className={`inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 py-1.5 text-[0.875rem] font-semibold transition-colors ${
@@ -220,7 +222,7 @@ function VoteButtons({ gym, onRate }: { gym: VirtualGym; onRate: (vote: 'UP' | '
</button>
<button
type="button"
aria-label={`Nie polecam: ${gym.name}`}
aria-label={t('page.voteDownAria', { name: gym.name })}
aria-pressed={gym.myVote === 'DOWN'}
onClick={() => onRate('DOWN')}
className={`inline-flex cursor-pointer items-center gap-1.5 rounded-full border px-2.5 py-1.5 text-[0.875rem] font-semibold transition-colors ${
@@ -254,6 +256,7 @@ function VirtualGymCard({
}) {
const queryClient = useQueryClient();
const { push } = useToast();
const { t } = useTranslation('gyms');
const [claimOpen, setClaimOpen] = useState(false);
const [busy, setBusy] = useState(false);
@@ -278,7 +281,7 @@ function VirtualGymCard({
try {
await joinGym(gym.id);
await invalidate();
push(`Dołączono do siłowni: ${gym.name}`, 'success');
push(t('join.toastOk', { name: gym.name }), 'success');
} catch (e) {
push((e as Error).message, 'error');
} finally {
@@ -292,7 +295,7 @@ function VirtualGymCard({
try {
await withdrawGymClaim(claim.id);
await invalidate();
push('Wniosek wycofany', 'success');
push(t('detail.claimWithdrawnToast'), 'success');
} catch (e) {
push((e as Error).message, 'error');
} finally {
@@ -304,7 +307,7 @@ function VirtualGymCard({
try {
await withdrawGymInvitation(id);
await invalidate();
push('Zaproszenie wycofane', 'success');
push(t('invites.toastWithdrawn'), 'success');
} catch (e) {
push((e as Error).message, 'error');
}
@@ -315,7 +318,9 @@ function VirtualGymCard({
gym={gym}
memberCount={gym.memberCount}
rating={gym.up + gym.down > 0 ? Math.round((gym.up / (gym.up + gym.down)) * 100) : null}
extraBadges={isMember ? <Badge color="green">Członek</Badge> : null}
extraBadges={
isMember ? <Badge color="green">{t('common:statuses.gymRole.MEMBER')}</Badge> : null
}
>
{!gym.isPrivate && (
<div className="flex flex-wrap items-center gap-2">
@@ -326,40 +331,41 @@ function VirtualGymCard({
<div className="flex flex-wrap items-center gap-2">
{!isMember && !gym.isPrivate && (
<Button size="sm" onClick={() => void join()} disabled={busy}>
Dołącz
{t('join.submit')}
</Button>
)}
{gym.isPrivate && isOwner && (
<Button size="sm" variant="secondary" onClick={onInvite}>
Zaproś usera
{t('detail.actionInvite')}
</Button>
)}
{isOwner && !gym.isPrivate && gym.claimStatus === 'PENDING' && (
<>
<span className="text-[0.875rem] text-dim">Wniosek oczekuje na weryfikację</span>
<span className="text-[0.875rem] text-dim">{t('page.claimPending')}</span>
<Button
size="sm"
variant="secondary"
onClick={() => void withdrawClaim()}
disabled={busy}
>
Wycofaj
{t('invites.withdraw')}
</Button>
</>
)}
{isOwner && !gym.isPrivate && gym.claimStatus === 'REJECTED' && (
<>
<span className="text-[0.875rem] text-danger">
Odrzucono{gym.rejectReason ? `: ${gym.rejectReason}` : ''}
{t('page.rejected')}
{gym.rejectReason ? `: ${gym.rejectReason}` : ''}
</span>
<Button size="sm" variant="secondary" onClick={() => setClaimOpen(true)}>
Złóż ponownie
{t('page.resubmit')}
</Button>
</>
)}
{isOwner && !gym.isPrivate && !gym.claimStatus && (
<Button size="sm" variant="secondary" onClick={() => setClaimOpen(true)}>
Złóż wniosek o weryfikację
{t('detail.actionClaimVerify')}
</Button>
)}
{gym.isPrivate && isOwner && (
@@ -375,7 +381,7 @@ function VirtualGymCard({
{gym.isPrivate && isOwner && sentInvitations.length > 0 && (
<div className="mt-3 border-t border-line pt-3">
<div className="mb-1.5 text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
Wysłane zaproszenia
{t('page.sentInvites')}
</div>
<div className="divide-y divide-line">
{sentInvitations.map((inv) => {
@@ -393,7 +399,7 @@ function VirtualGymCard({
variant="ghost"
onClick={() => void withdrawInvitation(inv.id)}
>
Wycofaj
{t('invites.withdraw')}
</Button>
}
/>
@@ -425,12 +431,13 @@ function ClaimStatusInline({
onWithdraw: () => void;
busy: boolean;
}) {
const { t } = useTranslation('gyms');
if (gym.claimStatus === 'PENDING') {
return (
<>
<span className="text-[0.875rem] text-dim">Wniosek oczekuje na weryfikację</span>
<span className="text-[0.875rem] text-dim">{t('page.claimPending')}</span>
<Button size="sm" variant="secondary" onClick={onWithdraw} disabled={busy}>
Wycofaj
{t('invites.withdraw')}
</Button>
</>
);
@@ -439,24 +446,25 @@ function ClaimStatusInline({
return (
<>
<span className="text-[0.875rem] text-danger">
Odrzucono{gym.rejectReason ? `: ${gym.rejectReason}` : ''}
{t('page.rejected')}
{gym.rejectReason ? `: ${gym.rejectReason}` : ''}
</span>
<Button size="sm" variant="secondary" onClick={onResubmit}>
Złóż ponownie
{t('page.resubmit')}
</Button>
</>
);
}
return (
<Button size="sm" variant="secondary" onClick={onResubmit}>
Złóż wniosek o weryfikację
{t('detail.actionClaimVerify')}
</Button>
);
}
export default function Gyms() {
const navigate = useNavigate();
const { t } = useTranslation();
const { t } = useTranslation(['gyms', 'nav']);
// „Moje siłownie” = WSZYSTKIE członkostwa (OWNER/TRAINER/MEMBER) z rolami.
const { data: gymsData, isLoading: gymsLoading, error: gymsError } = useGyms();
const { data: virtualData, isLoading: virtualLoading, error: virtualError } = useVirtualGyms();
@@ -482,11 +490,11 @@ export default function Gyms() {
}, [tab, gymsLoading, myGyms.length]);
useTopbar({
title: 'Siłownie',
title: t('nav:gyms'),
search: 'gyms',
actions: [
{ label: 'Stwórz siłownię', onClick: () => setCreateOpen(true), icon: Plus },
{ label: 'Dołącz', onClick: () => setJoinOpen(true), icon: UserPlus },
{ label: t('create.title'), onClick: () => setCreateOpen(true), icon: Plus },
{ label: t('join.submit'), onClick: () => setJoinOpen(true), icon: UserPlus },
],
});
@@ -506,8 +514,8 @@ export default function Gyms() {
<div className="mb-4">
<Tabs
tabs={[
{ id: 'mine', label: 'Moje siłownie' },
{ id: 'virtual', label: 'Wirtualne' },
{ id: 'mine', label: t('page.tabMine') },
{ id: 'virtual', label: t('page.tabVirtual') },
]}
active={tab ?? 'virtual'}
onChange={(id) => setTab(id as Tab)}
@@ -517,22 +525,23 @@ export default function Gyms() {
{tab === 'mine' && (
<>
{gymsLoading && <Loading />}
{gymsError && <ErrorText>Błąd: {(gymsError as Error).message}</ErrorText>}
{gymsError && (
<ErrorText>
{t('common:errorPrefix')}
{(gymsError as Error).message}
</ErrorText>
)}
{!gymsLoading && !gymsError && filteredMine.length === 0 && (
<Card>
<EmptyState
icon={Building2}
title={q ? 'Brak wyników' : 'Brak siłowni'}
description={
q
? 'Brak wyników dla podanego zapytania.'
: 'Nie należysz do żadnej siłowni. Utwórz pierwszą lub dołącz do istniejącej.'
}
title={q ? t('page.emptyQueryTitle') : t('page.emptyMineTitle')}
description={q ? t('join.emptyQuery') : t('page.emptyMineDesc')}
action={
!q ? (
<Button onClick={() => setCreateOpen(true)}>
<Plus className="h-4 w-4" />
Stwórz siłownię
{t('create.title')}
</Button>
) : undefined
}
@@ -542,7 +551,7 @@ export default function Gyms() {
{filteredMine.length > 0 && (
<>
<div className="mb-3 flex items-center gap-2.5">
<H3 className="mb-0">Moje siłownie</H3>
<H3 className="mb-0">{t('page.tabMine')}</H3>
<Badge color="gray">{filteredMine.length}</Badge>
</div>
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
@@ -554,7 +563,7 @@ export default function Gyms() {
onClick={() => navigate(`/gyms/${g.id}`)}
extraBadges={g.roles.map((r) => (
<Badge key={r} color={GYM_ROLE[r].color}>
{t(GYM_ROLE[r].labelKey)}
{t(`common:${GYM_ROLE[r].labelKey}`)}
</Badge>
))}
/>
@@ -568,24 +577,25 @@ export default function Gyms() {
{tab === 'virtual' && (
<>
{virtualLoading && <Loading />}
{virtualError && <ErrorText>Błąd: {(virtualError as Error).message}</ErrorText>}
{virtualError && (
<ErrorText>
{t('common:errorPrefix')}
{(virtualError as Error).message}
</ErrorText>
)}
{!virtualLoading && !virtualError && filteredVirtual.length === 0 && (
<Card>
<EmptyState
icon={Building2}
title={q ? 'Brak wyników' : 'Brak wirtualnych siłowni'}
description={
q
? 'Brak wyników dla podanego zapytania.'
: 'Zaglądaj tu, by oceniać odwzorowanie prawdziwych siłowni.'
}
title={q ? t('page.emptyQueryTitle') : t('page.emptyVirtualTitle')}
description={q ? t('join.emptyQuery') : t('page.emptyVirtualDesc')}
/>
</Card>
)}
{filteredVirtual.length > 0 && (
<>
<div className="mb-3 flex items-center gap-2.5">
<H3 className="mb-0">Wirtualne siłownie</H3>
<H3 className="mb-0">{t('page.virtualHeading')}</H3>
<Badge color="gray">{filteredVirtual.length}</Badge>
</div>
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">

View File

@@ -76,6 +76,7 @@ function ComposerCard({
busy: boolean;
className?: string;
}) {
const { t } = useTranslation('messages');
return (
<Card className={className}>
{staged && (
@@ -86,7 +87,7 @@ function ComposerCard({
</span>
<button
type="button"
aria-label="Usuń załącznik"
aria-label={t('removeAttachmentAria')}
onClick={onRemoveAttachment}
className="shrink-0 cursor-pointer rounded-md p-1 text-dim transition-colors hover:text-danger"
>
@@ -96,19 +97,19 @@ function ComposerCard({
)}
<Textarea
rows={2}
placeholder="Napisz wiadomość…"
placeholder={t('composerPlaceholder')}
value={body}
onChange={(e) => onBodyChange(e.target.value)}
aria-label="Treść wiadomości"
aria-label={t('composerAria')}
/>
<div className="flex items-center justify-between gap-2 mt-2">
<Button variant="secondary" size="sm" onClick={onAttach} disabled={!hasSessions}>
<Paperclip className="w-4 h-4" />
Załącz wynik
{t('attachResult')}
</Button>
<Button size="sm" onClick={onSend} disabled={busy || !body.trim()}>
<Send className="w-4 h-4" />
Wyślij
{t('send')}
</Button>
</div>
</Card>
@@ -138,19 +139,18 @@ function AttachmentPickerModal({
busy: boolean;
}) {
const { i18n } = useTranslation();
const { t } = useTranslation('messages');
const selectedSession = sessions.find((s) => s.id === sessionId);
return (
<Modal open={open} onClose={onClose} title="Załącz wynik">
{sessions.length === 0 && (
<p className="text-dim mb-3">Brak ukończonych sesji do załączenia.</p>
)}
<Field label="Sesja">
<Modal open={open} onClose={onClose} title={t('attachResult')}>
{sessions.length === 0 && <p className="text-dim mb-3">{t('attachEmpty')}</p>}
<Field label={t('sessionLabel')}>
<Select
value={sessionId}
onChange={(e) => onSessionChange(e.target.value)}
aria-label="Sesja"
aria-label={t('sessionLabel')}
>
<option value="">— wybierz —</option>
<option value="">{t('chooseOption')}</option>
{sessions.map((s) => (
<option key={s.id} value={s.id}>
{s.date ? fmtDate(s.date) : '—'} · {s.plan}
@@ -159,13 +159,13 @@ function AttachmentPickerModal({
</Select>
</Field>
{selectedSession && selectedSession.exercises.length > 0 && (
<Field label="Ćwiczenie (opcjonalnie)">
<Field label={t('exerciseLabel')}>
<Select
value={exerciseId}
onChange={(e) => onExerciseChange(e.target.value)}
aria-label="Ćwiczenie"
aria-label={t('exerciseAria')}
>
<option value="">Cała sesja</option>
<option value="">{t('wholeSession')}</option>
{selectedSession.exercises.map((ex) => (
<option key={ex.id} value={ex.id}>
{localizedName(ex, i18n.language)}
@@ -176,11 +176,9 @@ function AttachmentPickerModal({
)}
<Button className="w-full" onClick={onAttach} disabled={busy || !sessionId}>
<Paperclip className="w-4 h-4" />
Dodaj załącznik
{t('addAttachment')}
</Button>
<p className="mt-2 text-dim text-[0.8125rem]">
Załącznik pojawi się nad polem wiadomości — treść możesz dopisać później.
</p>
<p className="mt-2 text-dim text-[0.8125rem]">{t('attachHint')}</p>
</Modal>
);
}
@@ -188,6 +186,7 @@ function AttachmentPickerModal({
export default function MessageThread() {
const { coachingId = '' } = useParams();
const { i18n } = useTranslation();
const { t } = useTranslation('messages');
const navigate = useNavigate();
const queryClient = useQueryClient();
const { push } = useToast();
@@ -198,13 +197,13 @@ export default function MessageThread() {
/* Trener: mostek do kokpitu treningowego (panel podopiecznego); podopieczny
nie ma panelu trenera — akcja tylko dla roli trainer. */
useTopbar({
title: 'Komunikator',
title: t('nav:messages'),
back: '/messages',
actions:
thread?.role === 'trainer' && thread.other.id
? [
{
label: 'Otwórz panel podopiecznego',
label: t('openTraineePanel'),
icon: UserRound,
to: `/trainees/${thread.other.id}`,
},
@@ -317,9 +316,14 @@ export default function MessageThread() {
{!error && thread && <ThreadContextCard thread={thread} />}
<Card ref={listRef} className="min-h-0 flex-1 overflow-y-auto overscroll-contain">
{error && <ErrorText>Błąd: {(error as Error).message}</ErrorText>}
{error && (
<ErrorText>
{t('common:errorPrefix')}
{(error as Error).message}
</ErrorText>
)}
{!error && (thread?.messages.length ?? 0) === 0 && (
<p className="text-dim">Brak wiadomości — napisz pierwszą.</p>
<p className="text-dim">{t('emptyThread')}</p>
)}
{!error && (
<div className="space-y-2.5">

View File

@@ -1,5 +1,6 @@
import { useEffect, useMemo, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { ArrowUpDown, ChevronDown, MessageSquare, Users } from 'lucide-react';
import { useConversations, useMe } from '../../api/queries';
import { displayName, timeAgo } from '../../lib/format';
@@ -20,20 +21,21 @@ import { useTopbar } from '../../topbar';
/* Opcje sortowania rozmów — komunikacyjne (inne niż metryki treningowe w /trainees) */
const SORT_OPTIONS = [
{ id: 'none', label: 'Brak' },
{ id: 'unread', label: 'Nieprzeczytane' },
{ id: 'name', label: 'Nazwa' },
{ id: 'none', labelKey: 'sort.none' },
{ id: 'unread', labelKey: 'sort.unread' },
{ id: 'name', labelKey: 'sort.name' },
] as const;
type SortKey = (typeof SORT_OPTIONS)[number]['id'];
/* Grupy rozmów wg roli rozmówcy: ja=trener → podopieczni; ja=podopieczny → trenerzy */
const ROLE_GROUPS = [
{ id: 'trainees', label: 'Podopieczni', myRole: 'trainer' as const },
{ id: 'trainers', label: 'Trenerzy', myRole: 'trainee' as const },
{ id: 'trainees', labelKey: 'roleTrainees', myRole: 'trainer' as const },
{ id: 'trainers', labelKey: 'roleTrainers', myRole: 'trainee' as const },
];
export default function Messages() {
const navigate = useNavigate();
const { t } = useTranslation('messages');
const { data, isLoading, error } = useConversations();
const { data: meData } = useMe();
const myId = meData?.user.id;
@@ -47,7 +49,7 @@ export default function Messages() {
const [activeRoleTab, setActiveRoleTab] = useState<string | null>(null);
useTopbar({
title: 'Komunikator',
title: t('nav:messages'),
search: 'messages',
filters: [
/* sortowanie: przycisk „Sortuj: <wartość>” + rozwijany select (kompaktowo w grupie filtrów) */
@@ -65,7 +67,8 @@ export default function Messages() {
)}
>
<ArrowUpDown className="w-4 h-4" />
Sortuj: {SORT_OPTIONS.find((s) => s.id === sortKey)?.label}
{t('sortPrefix')}
{t(SORT_OPTIONS.find((s) => s.id === sortKey)?.labelKey ?? 'sort.none')}
<ChevronDown className={`w-4 h-4 transition-transform ${sortOpen ? 'rotate-180' : ''}`} />
</Button>
{sortOpen && (
@@ -85,7 +88,7 @@ export default function Messages() {
sortKey === s.id ? 'bg-accent/12 text-accent-text' : 'text-ink hover:bg-line/30'
}`}
>
{s.label}
{t(s.labelKey)}
</button>
))}
</div>
@@ -105,7 +108,7 @@ export default function Messages() {
)}
>
<Users className="w-4 h-4" />
Grupuj wg roli
{t('groupByRole')}
</Button>,
],
filterActive: sortKey !== 'none' || groupByRole,
@@ -195,12 +198,12 @@ export default function Messages() {
<span
className={`min-w-0 truncate text-[0.8125rem] ${unread ? 'font-semibold text-ink' : 'text-dim'}`}
>
{mine ? 'Ty: ' : ''}
{mine ? t('youPrefix') : ''}
{c.lastMessage.body}
</span>
) : (
<span className="min-w-0 truncate text-[0.8125rem] italic text-dim/70">
Brak wiadomości
{t('noMessageRow')}
</span>
)}
{unread && (
@@ -218,19 +221,20 @@ export default function Messages() {
return (
<>
{error && <ErrorText>Błąd: {(error as Error).message}</ErrorText>}
{error && (
<ErrorText>
{t('common:errorPrefix')}
{(error as Error).message}
</ErrorText>
)}
{!error && conversations.length === 0 && (
<Card>
<EmptyState
icon={MessageSquare}
title="Brak rozmów"
description="Rozmowa pojawi się po nawiązaniu aktywnej relacji z trenerem."
/>
<EmptyState icon={MessageSquare} title={t('emptyTitle')} description={t('emptyDesc')} />
</Card>
)}
{!error && conversations.length > 0 && filtered.length === 0 && (
<Card>
<p className="text-dim">Brak wyników dla podanego zapytania.</p>
<p className="text-dim">{t('searchNoResults')}</p>
</Card>
)}
{!error &&
@@ -240,14 +244,14 @@ export default function Messages() {
{/* lista ról rozmówców jako zakładki — łatwiej się odnaleźć */}
<div className="mb-4">
<Tabs
tabs={roleGroups.map((g) => ({ id: g.id, label: g.label }))}
tabs={roleGroups.map((g) => ({ id: g.id, label: t(g.labelKey) }))}
active={activeGroup.id}
onChange={setActiveRoleTab}
/>
</div>
<section>
<div className="mb-3 flex items-center gap-2.5">
<H3 className="mb-0">{activeGroup.label}</H3>
<H3 className="mb-0">{t(activeGroup.labelKey)}</H3>
<Badge color="gray">{activeGroup.items.length}</Badge>
</div>
<Card>{renderRows(activeGroup.items)}</Card>

View File

@@ -33,16 +33,16 @@ function ContextSkeleton() {
/* Trener: kontekst treningowy podopiecznego (killstreak, sesje, plan, flagi). */
function TrainerContext({ traineeId }: { traineeId: string }) {
const { t } = useTranslation();
const { t } = useTranslation('messages');
const { data, isLoading } = useTrainee(traineeId);
if (isLoading) return <ContextSkeleton />;
if (!data) return null;
return (
<Card>
<SectionHeader title="Trening podopiecznego" />
<SectionHeader title={t('ctx.traineeWorkout')} />
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 sm:gap-5">
<StatTile
label="Killstreak"
label={t('ctx.killstreak')}
value={
<span className="inline-flex items-center gap-1.5">
<Flame
@@ -53,11 +53,11 @@ function TrainerContext({ traineeId }: { traineeId: string }) {
}
/>
<StatTile
label="Ostatnia sesja"
label={t('ctx.lastSession')}
value={data.lastSessionAt ? fmtDateTime(data.lastSessionAt) : '—'}
/>
<StatTile
label="Następny trening"
label={t('ctx.nextWorkout')}
value={
data.nextTraining
? `${fmtDate(data.nextTraining.date)} · ${data.nextTraining.exercises
@@ -73,7 +73,9 @@ function TrainerContext({ traineeId }: { traineeId: string }) {
<strong className="text-[0.95rem]">{data.activePlan.title}</strong>
{data.progress && (
<Muted className="text-[0.8125rem]">
{data.progress.completed}/{data.progress.total} dni · {data.progress.percent}%
{data.progress.completed}/{data.progress.total}
{t('ctx.daysSep')}
{data.progress.percent}%
</Muted>
)}
</div>
@@ -84,7 +86,7 @@ function TrainerContext({ traineeId }: { traineeId: string }) {
<div className="mt-4 flex flex-wrap gap-1.5">
{data.flags.map((f) => (
<Badge key={f} color={TRAINEE_FLAGS[f].color}>
{t(TRAINEE_FLAGS[f].labelKey)}
{t(`common:${TRAINEE_FLAGS[f].labelKey}`)}
</Badge>
))}
</div>
@@ -95,15 +97,16 @@ function TrainerContext({ traineeId }: { traineeId: string }) {
/* Podopieczny: kontekst własnych treningów w tej relacji (dashboard). */
function TraineeContext() {
const { t } = useTranslation('messages');
const { data, isLoading } = useDashboard();
if (isLoading) return <ContextSkeleton />;
if (!data) return null;
return (
<Card>
<SectionHeader title="Twoje treningi" />
<SectionHeader title={t('ctx.yourWorkouts')} />
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 sm:gap-5">
<StatTile
label="Killstreak"
label={t('ctx.killstreak')}
value={
<span className="inline-flex items-center gap-1.5">
<Flame
@@ -114,7 +117,7 @@ function TraineeContext() {
}
/>
<StatTile
label="Następny trening"
label={t('ctx.nextWorkout')}
value={
data.nextTraining
? `${fmtDate(data.nextTraining.date)} · ${data.nextTraining.exercises
@@ -130,7 +133,9 @@ function TraineeContext() {
<strong className="text-[0.95rem]">{data.activePlan.title}</strong>
{data.progress && (
<Muted className="text-[0.8125rem]">
{data.progress.completed}/{data.progress.total} dni · {data.progress.percent}%
{data.progress.completed}/{data.progress.total}
{t('ctx.daysSep')}
{data.progress.percent}%
</Muted>
)}
</div>