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. */