Mobile: '<' w dolnym pasku nawiguje do strony-rodzica (back w useTopbar), zamiast historii przegladarki; deklaruja go podstrony (app+admin)

This commit is contained in:
tisachi
2026-09-05 04:06:23 +02:00
parent 5ec097a2eb
commit d08e2a1f93
21 changed files with 55 additions and 30 deletions

View File

@@ -132,7 +132,7 @@ export default function VerificationsList() {
}
export function VerificationDetail() {
useTopbar({ title: 'Weryfikacje' });
useTopbar({ title: 'Weryfikacje', back: '/verifications' });
const { id } = useParams();
const navigate = useNavigate();
const queryClient = useQueryClient();

View File

@@ -152,6 +152,7 @@ export default function GymDetail() {
// operacje stronicowe w menu kontekstowym (standard topmenu)
useTopbar({
title: 'Siłownie',
back: '/gyms',
actions: [{ label: 'Usuń siłownię', variant: 'danger', onClick: remove }],
});

View File

@@ -8,7 +8,7 @@ import type { Availability } from '../../api/types';
import { useTopbar } from '../../topbar';
export default function GymForm() {
useTopbar({ title: 'Siłownie' });
useTopbar({ title: 'Siłownie', back: '/gyms' });
const navigate = useNavigate();
const [form, setForm] = useState({
name: '',

View File

@@ -467,7 +467,7 @@ function UserEditForm({ user, onSaved }: { user: User; onSaved: () => void }) {
}
export default function UserDetail() {
useTopbar({ title: 'Użytkownicy' });
useTopbar({ title: 'Użytkownicy', back: '/users' });
const { id } = useParams();
const navigate = useNavigate();
const queryClient = useQueryClient();

View File

@@ -5,7 +5,7 @@ import { BackButton, Button, Card, ErrorText, Field, H1, Input, Select } from '.
import { useTopbar } from '../../topbar';
export default function UserForm() {
useTopbar({ title: 'Użytkownicy' });
useTopbar({ title: 'Użytkownicy', back: '/users' });
const navigate = useNavigate();
const [form, setForm] = useState({
email: '',

View File

@@ -72,17 +72,6 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
return (
<header className="sticky top-0 z-30 border-b border-line md:bg-bg/80 md:backdrop-blur-[8px]">
<div className="mx-auto flex max-w-5xl items-center justify-between gap-3 px-4 py-2.5 md:px-8 md:py-3">
{/* telefon: „<” gdy można bezpiecznie wrócić (jest poprzedni wpis historii) */}
{(window.history.state?.idx ?? 0) > 0 && (
<button
type="button"
onClick={() => navigate(-1)}
aria-label="Wstecz"
className="grid h-[34px] w-[34px] flex-none cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:text-ink md:hidden"
>
<ChevronLeft className="h-4 w-4" />
</button>
)}
{onMenuOpen && (
<button
type="button"
@@ -105,6 +94,17 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
>
{/* nawigacja (np. Kalendarz) zawsze widoczna, nie jest grupą */}
{config?.navWidget}
{/* telefon: „<” = wróć do strony-rodzica zadeklarowanej przez podstronę */}
{config?.back && (
<button
type="button"
onClick={() => navigate(config.back!)}
aria-label="Wstecz"
className="grid h-[34px] w-[34px] flex-none cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:text-ink md:hidden"
>
<ChevronLeft className="h-4 w-4" />
</button>
)}
{hasFilters && (
<GroupButton
icon={Filter}

View File

@@ -25,6 +25,12 @@ export interface TopbarAction {
*/
export interface TopbarConfig {
title: string;
/**
* Ścieżka strony-rodzica: na telefonie w dolnym pasku pojawia się „<” (Wstecz)
* nawigujące dokładnie tam (nie jak przycisk historii przeglądarki).
* Tablet/PC bez zmian (przycisk „Wstecz” w treści strony).
*/
back?: string;
/** Wyszukiwarka listy (store list-search) → grupa 🔍. */
search?: SearchableSection;
/** Filtr po dacie (np. selektor miesiąca) → grupa lejka. */

View File

@@ -524,6 +524,7 @@ export default function DayExecution() {
// menu top: akcje sesji (dodawanie ćwiczenia przez modal; ukończenie wymaga serie normowe; porzucenie przez dialog)
useTopbar({
title: 'Dzień treningowy',
back: '/calendar',
// akcje sesji (Ukończ/Porzuć) widoczne na starcie — grupa otwarta domyślnie
defaultOpenGroup: 'actions',
actions: session?.status === 'IN_PROGRESS'

View File

@@ -421,7 +421,7 @@ export default function GymDetail() {
]
: undefined;
useTopbar({ title: 'Siłownie', groups, actions: ownerActions });
useTopbar({ title: 'Siłownie', back: '/gyms', groups, actions: ownerActions });
if (isLoading) return <Loading />;
if (error || !gym) {

View File

@@ -185,7 +185,7 @@ function AttachmentPickerModal({
}
export default function MessageThread() {
useTopbar({ title: 'Komunikator' });
useTopbar({ title: 'Komunikator', back: '/messages' });
const { coachingId = '' } = useParams();
const navigate = useNavigate();
const queryClient = useQueryClient();

View File

@@ -65,6 +65,7 @@ export default function PlanDetail() {
// operacje stronicowe w menu kontekstowym (standard topmenu); WeekPicker + hint zostają w karcie
useTopbar({
title: 'Plany',
back: '/plans',
actions: planData
? planData.status === 'DRAFT'
? [

View File

@@ -35,6 +35,11 @@ export default function PlanEditor() {
: isEdit
? 'Edycja planu'
: 'Nowy plan',
back: isTraineeMode
? `/trainees/${traineeUserId}?tab=plans`
: isEdit
? `/plans/${planIdParam}`
: '/plans',
});
const navigate = useNavigate();
const ownerPlan = usePlan(isTraineeMode ? '' : planIdParam);

View File

@@ -313,6 +313,7 @@ export default function ProfileBodyParameters() {
// menu top: selektor miesiąca (filtr po dacie) + akcja otwierająca modal w treści strony
useTopbar({
title: 'Profil — parametry ciała',
back: '/profile',
dateFilter: <MonthPicker />,
filterActive: month !== '',
actions: [{ label: 'Dodaj pomiar', onClick: () => setAddOpen(true), icon: Plus }],

View File

@@ -33,6 +33,7 @@ export default function ProfileClaims() {
useTopbar({
title: 'Profil — wnioski',
back: '/profile',
actions: [{ label: 'Nowy wniosek o siłownię', icon: Plus, onClick: () => setNewOpen(true) }],
});

View File

@@ -14,6 +14,7 @@ export default function ProfileGyms() {
useTopbar({
title: 'Profil — siłownie',
back: '/profile',
actions: isAdmin
? [{ label: 'Stwórz siłownię', onClick: () => setCreateOpen(true), icon: Plus }]
: undefined,

View File

@@ -7,7 +7,7 @@ import { useToast } from '../../components/toast';
import { useTopbar } from '../../topbar';
export default function ProfileHistory() {
useTopbar({ title: 'Profil — historia' });
useTopbar({ title: 'Profil — historia', back: '/profile' });
const navigate = useNavigate();
const queryClient = useQueryClient();
const { push } = useToast();

View File

@@ -465,6 +465,7 @@ export default function ProfileInfo() {
useTopbar({
title: 'Profil — dane osobowe',
back: '/profile',
actions: editing
? [{ label: 'Zapisz', onClick: () => void saveProfile(), icon: Check }]
: [{ label: 'Edytuj', onClick: () => setEditing(true), variant: 'secondary', icon: Pencil }],

View File

@@ -5,7 +5,7 @@ import { BackButton, Card, ErrorText, Muted, PageHeader, Skeleton } from '../../
import { useTopbar } from '../../topbar';
export default function ProfileProgress() {
useTopbar({ title: 'Profil — postępy' });
useTopbar({ title: 'Profil — postępy', back: '/profile' });
const navigate = useNavigate();
const { data, isLoading, error } = useExerciseProgress();

View File

@@ -100,6 +100,7 @@ export default function TraineeDetail() {
useTopbar({
title: 'Podopieczni',
back: '/trainees',
actions: [
{
label: 'Utwórz plan',

View File

@@ -71,17 +71,6 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
return (
<header className="sticky top-0 z-30 border-b border-line md:bg-bg/80 md:backdrop-blur-[8px]">
<div className="mx-auto flex max-w-5xl items-center justify-between gap-3 px-4 py-2.5 md:px-8 md:py-3">
{/* telefon: „<” gdy można bezpiecznie wrócić (jest poprzedni wpis historii) */}
{(window.history.state?.idx ?? 0) > 0 && (
<button
type="button"
onClick={() => navigate(-1)}
aria-label="Wstecz"
className="grid h-[34px] w-[34px] flex-none cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:text-ink md:hidden"
>
<ChevronLeft className="h-4 w-4" />
</button>
)}
{onMenuOpen && (
<button
type="button"
@@ -104,6 +93,17 @@ export function Topbar({ onMenuOpen }: { onMenuOpen?: () => void }) {
>
{/* nawigacja (np. Kalendarz) zawsze widoczna, nie jest grupą */}
{config?.navWidget}
{/* telefon: „<” = wróć do strony-rodzica zadeklarowanej przez podstronę */}
{config?.back && (
<button
type="button"
onClick={() => navigate(config.back!)}
aria-label="Wstecz"
className="grid h-[34px] w-[34px] flex-none cursor-pointer place-items-center rounded-[10px] border border-line bg-card text-dim shadow-card transition-colors hover:text-ink md:hidden"
>
<ChevronLeft className="h-4 w-4" />
</button>
)}
{hasFilters && (
<GroupButton
icon={Filter}

View File

@@ -34,6 +34,12 @@ export interface TopbarCustomGroup {
*/
export interface TopbarConfig {
title: string;
/**
* Ścieżka strony-rodzica: na telefonie w dolnym pasku pojawia się „<” (Wstecz)
* nawigujące dokładnie tam (nie jak przycisk historii przeglądarki).
* Tablet/PC bez zmian (przycisk „Wstecz” w treści strony).
*/
back?: string;
/** Wyszukiwarka listy (store list-search) → grupa 🔍. */
search?: SearchableSection;
/** Filtr po dacie (np. selektor miesiąca) → grupa lejka. */