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>
))}