Refaktoryzacja struktury i podział modułów (app/admin/api), konsolidacja testów w test/, komunikator (lista kontaktów, załącznik bez treści), profil podopiecznego (menu kontekstowe, nagłówek, zapamiętywanie zakładki), Tabs: strzałki poza scrollem + scroll-snap do całych zakładek, podniesione limity rate-limit
This commit is contained in:
@@ -3,15 +3,15 @@ import { Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { useAuth } from './store/auth';
|
||||
import Layout from './components/Layout';
|
||||
import Login from './pages/Login';
|
||||
import GymsList from './pages/GymsList';
|
||||
import GymForm from './pages/GymForm';
|
||||
import GymDetail from './pages/GymDetail';
|
||||
import UsersList from './pages/UsersList';
|
||||
import UserForm from './pages/UserForm';
|
||||
import UserDetail from './pages/UserDetail';
|
||||
import FocusAreas from './pages/FocusAreas';
|
||||
import Exercises from './pages/Exercises';
|
||||
import EquipmentCatalog from './pages/Equipment';
|
||||
import GymsList from './pages/gyms/GymsList';
|
||||
import GymForm from './pages/gyms/GymForm';
|
||||
import GymDetail from './pages/gyms/GymDetail';
|
||||
import UsersList from './pages/users/UsersList';
|
||||
import UserForm from './pages/users/UserForm';
|
||||
import UserDetail from './pages/users/UserDetail';
|
||||
import FocusAreas from './pages/catalog/FocusAreas';
|
||||
import Exercises from './pages/catalog/Exercises';
|
||||
import EquipmentCatalog from './pages/catalog/Equipment';
|
||||
import Logs from './pages/Logs';
|
||||
import VerificationsList, { VerificationDetail } from './pages/Verifications';
|
||||
|
||||
|
||||
@@ -5,12 +5,9 @@ import type {
|
||||
SelectHTMLAttributes,
|
||||
TextareaHTMLAttributes,
|
||||
} from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { ArrowLeft, Moon, Sun, X } from 'lucide-react';
|
||||
import { cva } from 'class-variance-authority';
|
||||
import { useTheme } from '../store/theme';
|
||||
import { cn } from '../lib/utils';
|
||||
import { Button as UIButton, buttonVariants } from './ui/button';
|
||||
import { Button as UIButton } from './ui/button';
|
||||
import { Card as UICard } from './ui/card';
|
||||
import { Badge as UIBadge } from './ui/badge';
|
||||
import { Input as UIInput } from './ui/input';
|
||||
@@ -20,14 +17,11 @@ import { Field as UIField } from './ui/field';
|
||||
import { Skeleton as UISkeleton } from './ui/skeleton';
|
||||
import { Progress as UIProgress } from './ui/progress';
|
||||
import { ErrorText as UIErrorText, SuccessText as UISuccessText } from './ui/alert';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from './ui/dialog';
|
||||
|
||||
export * from './ui/typography';
|
||||
export * from './ui/content';
|
||||
export * from './ui/dialogs';
|
||||
export * from './ui/theme-toggle';
|
||||
|
||||
/* Button */
|
||||
export type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';
|
||||
@@ -127,172 +121,7 @@ export function Field({
|
||||
);
|
||||
}
|
||||
|
||||
/* Headings */
|
||||
export function H1({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
return <h1 className={`text-[1.45rem] sm:text-[1.6rem] font-bold tracking-[-0.02em] mb-4 ${className}`.trim()}>{children}</h1>;
|
||||
}
|
||||
|
||||
export function H2({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
return <h2 className={`text-[1.15rem] sm:text-[1.25rem] font-bold tracking-[-0.01em] mb-3 ${className}`.trim()}>{children}</h2>;
|
||||
}
|
||||
|
||||
export function H3({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
return <h3 className={`text-[1.05rem] font-semibold mb-2 ${className}`.trim()}>{children}</h3>;
|
||||
}
|
||||
|
||||
/* Page header: title + optional badge, actions on the right (stacks on mobile) */
|
||||
export function PageHeader({
|
||||
title,
|
||||
badge,
|
||||
actions,
|
||||
}: {
|
||||
title: string;
|
||||
badge?: ReactNode;
|
||||
actions?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-5">
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<H1 className="mb-0">{title}</H1>
|
||||
{badge}
|
||||
</div>
|
||||
{actions}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Back button — ghost, small; `to` renders a Link, `onClick` a plain button */
|
||||
export function BackButton({
|
||||
to,
|
||||
onClick,
|
||||
children = 'Wstecz',
|
||||
className = '',
|
||||
}: {
|
||||
to?: string;
|
||||
onClick?: () => void;
|
||||
children?: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
const cls = cn(buttonVariants({ variant: 'ghost', size: 'sm' }), className);
|
||||
if (to) {
|
||||
return (
|
||||
<Link to={to} className={cls}>
|
||||
<ArrowLeft className="w-4 h-4" />
|
||||
{children}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<button type="button" onClick={onClick} className={cls}>
|
||||
<ArrowLeft className="w-4 h-4" />
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/* Section header: H2 + muted description + optional actions (right) */
|
||||
export function SectionHeader({
|
||||
title,
|
||||
description,
|
||||
actions,
|
||||
className = '',
|
||||
}: {
|
||||
title: ReactNode;
|
||||
description?: ReactNode;
|
||||
actions?: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={`flex flex-wrap items-start justify-between gap-3 mb-3 ${className}`.trim()}>
|
||||
<div className="min-w-0">
|
||||
<H2 className="mb-0.5">{title}</H2>
|
||||
{description && <Muted className="text-[0.875rem]">{description}</Muted>}
|
||||
</div>
|
||||
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Meta item: small icon + muted text */
|
||||
export function MetaItem({
|
||||
icon: Icon,
|
||||
children,
|
||||
className = '',
|
||||
}: {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1.5 text-dim text-[0.875rem] ${className}`.trim()}>
|
||||
<Icon className="w-4 h-4 shrink-0" />
|
||||
<span className="min-w-0 truncate">{children}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/* List row: płaski wiersz (tytuł + meta lewo, akcje prawo); w listach w karcie
|
||||
rodzic używa `divide-y divide-line` (dłuższe) albo `space-y-1` (krótkie). */
|
||||
export function ListRow({
|
||||
title,
|
||||
meta,
|
||||
actions,
|
||||
children,
|
||||
className = '',
|
||||
}: {
|
||||
title: ReactNode;
|
||||
meta?: ReactNode;
|
||||
actions?: ReactNode;
|
||||
children?: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
data-slot="list-row"
|
||||
className={`flex flex-wrap items-center justify-between gap-3 px-2 py-3 rounded-lg transition-colors hover:bg-line/20 ${className}`.trim()}
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-[0.95rem] font-semibold min-w-0 truncate">{title}</div>
|
||||
{meta && <Muted className="text-[0.875rem]">{meta}</Muted>}
|
||||
</div>
|
||||
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Chip: small pill (+ optional remove button) */
|
||||
export function Chip({
|
||||
children,
|
||||
onRemove,
|
||||
removeLabel = 'Usuń',
|
||||
className = '',
|
||||
}: {
|
||||
children: ReactNode;
|
||||
onRemove?: () => void;
|
||||
removeLabel?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<span
|
||||
data-slot="chip"
|
||||
className={`inline-flex items-center gap-1.5 bg-card border border-line rounded-full px-3 py-1 text-[0.8125rem] font-semibold text-dim ${className}`.trim()}
|
||||
>
|
||||
{children}
|
||||
{onRemove && (
|
||||
<button type="button" onClick={onRemove} aria-label={removeLabel} className="text-dim hover:text-danger cursor-pointer">
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/* Text helpers */
|
||||
export function Muted({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
return <span className={`text-dim ${className}`.trim()}>{children}</span>;
|
||||
}
|
||||
|
||||
export function ErrorText({ children }: { children: ReactNode }) {
|
||||
return <UIErrorText>{children}</UIErrorText>;
|
||||
}
|
||||
@@ -301,152 +130,12 @@ export function SuccessText({ children }: { children: ReactNode }) {
|
||||
return <UISuccessText>{children}</UISuccessText>;
|
||||
}
|
||||
|
||||
export function Loading({ children = 'Ładowanie…' }: { children?: ReactNode }) {
|
||||
return <div className="text-dim">{children}</div>;
|
||||
}
|
||||
|
||||
/* Skeleton */
|
||||
export function Skeleton({ className = '' }: { className?: string }) {
|
||||
return <UISkeleton className={className} />;
|
||||
}
|
||||
|
||||
/* Empty state */
|
||||
export function EmptyState({
|
||||
icon: Icon,
|
||||
title,
|
||||
description,
|
||||
action,
|
||||
}: {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
title: string;
|
||||
description?: string;
|
||||
action?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center text-center py-10 px-4">
|
||||
<div className="w-14 h-14 rounded-full bg-accent/10 border border-accent/25 text-accent-text flex items-center justify-center mb-4">
|
||||
<Icon className="w-7 h-7" />
|
||||
</div>
|
||||
<H3 className="mb-1">{title}</H3>
|
||||
{description && <p className="text-dim text-[0.9rem] max-w-sm">{description}</p>}
|
||||
{action && <div className="mt-4">{action}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Progress bar */
|
||||
export function ProgressBar({ percent, className = '' }: { percent: number; className?: string }) {
|
||||
return <UIProgress percent={percent} className={className} />;
|
||||
}
|
||||
|
||||
/* Tabs */
|
||||
export function Tabs({
|
||||
tabs,
|
||||
active,
|
||||
onChange,
|
||||
}: {
|
||||
tabs: { id: string; label: string }[];
|
||||
active: string;
|
||||
onChange: (id: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex gap-1 p-1 bg-input rounded-[10px] border border-line overflow-x-auto">
|
||||
{tabs.map((t) => (
|
||||
<button
|
||||
key={t.id}
|
||||
type="button"
|
||||
onClick={() => onChange(t.id)}
|
||||
className={`px-3.5 py-2 rounded-lg text-[0.9rem] font-semibold whitespace-nowrap cursor-pointer transition-all duration-150 ${
|
||||
active === t.id ? 'bg-card text-ink border border-line shadow-card' : 'border border-transparent text-dim hover:text-ink'
|
||||
}`}
|
||||
>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Modal — Radix Dialog: focus trap, Esc, scroll-lock, aria; bottom-sheet na mobile */
|
||||
export function Modal({
|
||||
open,
|
||||
onClose,
|
||||
title,
|
||||
children,
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
title: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(o) => !o && onClose()}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle asChild>
|
||||
<h3 className="text-[1.05rem] font-semibold">{title}</h3>
|
||||
</DialogTitle>
|
||||
<DialogClose asChild>
|
||||
<button aria-label="Zamknij" className="p-1.5 -m-1.5 text-dim hover:text-ink cursor-pointer">
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</DialogClose>
|
||||
</DialogHeader>
|
||||
<DialogDescription asChild>
|
||||
<span className="sr-only" />
|
||||
</DialogDescription>
|
||||
{children}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
/* Confirm dialog */
|
||||
export function ConfirmDialog({
|
||||
open,
|
||||
onClose,
|
||||
onConfirm,
|
||||
title,
|
||||
description,
|
||||
confirmLabel = 'Potwierdź',
|
||||
danger,
|
||||
busy,
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
onConfirm: () => void;
|
||||
title: string;
|
||||
description: string;
|
||||
confirmLabel?: string;
|
||||
danger?: boolean;
|
||||
busy?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<Modal open={open} onClose={onClose} title={title}>
|
||||
<p className="text-dim text-[0.95rem]">{description}</p>
|
||||
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3 mt-5">
|
||||
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
|
||||
Anuluj
|
||||
</Button>
|
||||
<Button variant={danger ? 'danger' : 'primary'} onClick={onConfirm} disabled={busy} className="w-full sm:w-auto">
|
||||
{confirmLabel}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
/* Theme toggle */
|
||||
export function ThemeToggle({ className = '' }: { className?: string }) {
|
||||
const { theme, toggle } = useTheme();
|
||||
return (
|
||||
<button
|
||||
onClick={toggle}
|
||||
aria-label="Przełącz motyw"
|
||||
title="Przełącz motyw"
|
||||
className={`p-2.5 rounded-full bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
|
||||
>
|
||||
{theme === 'dark' ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
206
admin/src/components/ui/content.tsx
Normal file
206
admin/src/components/ui/content.tsx
Normal file
@@ -0,0 +1,206 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { ArrowLeft, X } from 'lucide-react';
|
||||
import { buttonVariants } from './button';
|
||||
import { H1, H2, H3, Muted } from './typography';
|
||||
import { cn } from '../../lib/utils';
|
||||
|
||||
/* Page header: title + optional badge, actions on the right (stacks on mobile) */
|
||||
export function PageHeader({
|
||||
title,
|
||||
badge,
|
||||
actions,
|
||||
}: {
|
||||
title: string;
|
||||
badge?: ReactNode;
|
||||
actions?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-5">
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<H1 className="mb-0">{title}</H1>
|
||||
{badge}
|
||||
</div>
|
||||
{actions}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Back button — ghost, small; `to` renders a Link, `onClick` a plain button */
|
||||
export function BackButton({
|
||||
to,
|
||||
onClick,
|
||||
children = 'Wstecz',
|
||||
className = '',
|
||||
}: {
|
||||
to?: string;
|
||||
onClick?: () => void;
|
||||
children?: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
const cls = cn(buttonVariants({ variant: 'ghost', size: 'sm' }), className);
|
||||
if (to) {
|
||||
return (
|
||||
<Link to={to} className={cls}>
|
||||
<ArrowLeft className="w-4 h-4" />
|
||||
{children}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<button type="button" onClick={onClick} className={cls}>
|
||||
<ArrowLeft className="w-4 h-4" />
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
/* Section header: H2 + muted description + optional actions (right) */
|
||||
export function SectionHeader({
|
||||
title,
|
||||
description,
|
||||
actions,
|
||||
className = '',
|
||||
}: {
|
||||
title: ReactNode;
|
||||
description?: ReactNode;
|
||||
actions?: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={`flex flex-wrap items-start justify-between gap-3 mb-3 ${className}`.trim()}>
|
||||
<div className="min-w-0">
|
||||
<H2 className="mb-0.5">{title}</H2>
|
||||
{description && <Muted className="text-[0.875rem]">{description}</Muted>}
|
||||
</div>
|
||||
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Meta item: small icon + muted text */
|
||||
export function MetaItem({
|
||||
icon: Icon,
|
||||
children,
|
||||
className = '',
|
||||
}: {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<span className={`inline-flex items-center gap-1.5 text-dim text-[0.875rem] ${className}`.trim()}>
|
||||
<Icon className="w-4 h-4 shrink-0" />
|
||||
<span className="min-w-0 truncate">{children}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/* List row: płaski wiersz (tytuł + meta lewo, akcje prawo); w listach w karcie
|
||||
rodzic używa `divide-y divide-line` (dłuższe) albo `space-y-1` (krótkie). */
|
||||
export function ListRow({
|
||||
title,
|
||||
meta,
|
||||
actions,
|
||||
children,
|
||||
className = '',
|
||||
}: {
|
||||
title: ReactNode;
|
||||
meta?: ReactNode;
|
||||
actions?: ReactNode;
|
||||
children?: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
data-slot="list-row"
|
||||
className={`flex flex-wrap items-center justify-between gap-3 px-2 py-3 rounded-lg transition-colors hover:bg-line/20 ${className}`.trim()}
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="text-[0.95rem] font-semibold min-w-0 truncate">{title}</div>
|
||||
{meta && <Muted className="text-[0.875rem]">{meta}</Muted>}
|
||||
</div>
|
||||
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Chip: small pill (+ optional remove button) */
|
||||
export function Chip({
|
||||
children,
|
||||
onRemove,
|
||||
removeLabel = 'Usuń',
|
||||
className = '',
|
||||
}: {
|
||||
children: ReactNode;
|
||||
onRemove?: () => void;
|
||||
removeLabel?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<span
|
||||
data-slot="chip"
|
||||
className={`inline-flex items-center gap-1.5 bg-card border border-line rounded-full px-3 py-1 text-[0.8125rem] font-semibold text-dim ${className}`.trim()}
|
||||
>
|
||||
{children}
|
||||
{onRemove && (
|
||||
<button type="button" onClick={onRemove} aria-label={removeLabel} className="text-dim hover:text-danger cursor-pointer">
|
||||
<X className="w-3.5 h-3.5" />
|
||||
</button>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
/* Empty state */
|
||||
export function EmptyState({
|
||||
icon: Icon,
|
||||
title,
|
||||
description,
|
||||
action,
|
||||
}: {
|
||||
icon: React.ComponentType<{ className?: string }>;
|
||||
title: string;
|
||||
description?: string;
|
||||
action?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center text-center py-10 px-4">
|
||||
<div className="w-14 h-14 rounded-full bg-accent/10 border border-accent/25 text-accent-text flex items-center justify-center mb-4">
|
||||
<Icon className="w-7 h-7" />
|
||||
</div>
|
||||
<H3 className="mb-1">{title}</H3>
|
||||
{description && <p className="text-dim text-[0.9rem] max-w-sm">{description}</p>}
|
||||
{action && <div className="mt-4">{action}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/* Tabs */
|
||||
export function Tabs({
|
||||
tabs,
|
||||
active,
|
||||
onChange,
|
||||
}: {
|
||||
tabs: { id: string; label: string }[];
|
||||
active: string;
|
||||
onChange: (id: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex gap-1 p-1 bg-input rounded-[10px] border border-line overflow-x-auto">
|
||||
{tabs.map((t) => (
|
||||
<button
|
||||
key={t.id}
|
||||
type="button"
|
||||
onClick={() => onChange(t.id)}
|
||||
className={`px-3.5 py-2 rounded-lg text-[0.9rem] font-semibold whitespace-nowrap cursor-pointer transition-all duration-150 ${
|
||||
active === t.id ? 'bg-card text-ink border border-line shadow-card' : 'border border-transparent text-dim hover:text-ink'
|
||||
}`}
|
||||
>
|
||||
{t.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
80
admin/src/components/ui/dialogs.tsx
Normal file
80
admin/src/components/ui/dialogs.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { X } from 'lucide-react';
|
||||
import { Button } from './button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from './dialog';
|
||||
|
||||
/* Modal — Radix Dialog: focus trap, Esc, scroll-lock, aria; bottom-sheet na mobile */
|
||||
export function Modal({
|
||||
open,
|
||||
onClose,
|
||||
title,
|
||||
children,
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
title: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(o) => !o && onClose()}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle asChild>
|
||||
<h3 className="text-[1.05rem] font-semibold">{title}</h3>
|
||||
</DialogTitle>
|
||||
<DialogClose asChild>
|
||||
<button aria-label="Zamknij" className="p-1.5 -m-1.5 text-dim hover:text-ink cursor-pointer">
|
||||
<X className="w-5 h-5" />
|
||||
</button>
|
||||
</DialogClose>
|
||||
</DialogHeader>
|
||||
<DialogDescription asChild>
|
||||
<span className="sr-only" />
|
||||
</DialogDescription>
|
||||
{children}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
/* Confirm dialog */
|
||||
export function ConfirmDialog({
|
||||
open,
|
||||
onClose,
|
||||
onConfirm,
|
||||
title,
|
||||
description,
|
||||
confirmLabel = 'Potwierdź',
|
||||
danger,
|
||||
busy,
|
||||
}: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
onConfirm: () => void;
|
||||
title: string;
|
||||
description: string;
|
||||
confirmLabel?: string;
|
||||
danger?: boolean;
|
||||
busy?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<Modal open={open} onClose={onClose} title={title}>
|
||||
<p className="text-dim text-[0.95rem]">{description}</p>
|
||||
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3 mt-5">
|
||||
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
|
||||
Anuluj
|
||||
</Button>
|
||||
<Button variant={danger ? 'danger' : 'primary'} onClick={onConfirm} disabled={busy} className="w-full sm:w-auto">
|
||||
{confirmLabel}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
16
admin/src/components/ui/theme-toggle.tsx
Normal file
16
admin/src/components/ui/theme-toggle.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Moon, Sun } from 'lucide-react';
|
||||
import { useTheme } from '../../store/theme';
|
||||
|
||||
export function ThemeToggle({ className = '' }: { className?: string }) {
|
||||
const { theme, toggle } = useTheme();
|
||||
return (
|
||||
<button
|
||||
onClick={toggle}
|
||||
aria-label="Przełącz motyw"
|
||||
title="Przełącz motyw"
|
||||
className={`p-2.5 rounded-full bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
|
||||
>
|
||||
{theme === 'dark' ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
21
admin/src/components/ui/typography.tsx
Normal file
21
admin/src/components/ui/typography.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
export function H1({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
return <h1 className={`text-[1.45rem] sm:text-[1.6rem] font-bold tracking-[-0.02em] mb-4 ${className}`.trim()}>{children}</h1>;
|
||||
}
|
||||
|
||||
export function H2({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
return <h2 className={`text-[1.15rem] sm:text-[1.25rem] font-bold tracking-[-0.01em] mb-3 ${className}`.trim()}>{children}</h2>;
|
||||
}
|
||||
|
||||
export function H3({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
return <h3 className={`text-[1.05rem] font-semibold mb-2 ${className}`.trim()}>{children}</h3>;
|
||||
}
|
||||
|
||||
export function Muted({ className = '', children }: { className?: string; children: ReactNode }) {
|
||||
return <span className={`text-dim ${className}`.trim()}>{children}</span>;
|
||||
}
|
||||
|
||||
export function Loading({ children = 'Ładowanie…' }: { children?: ReactNode }) {
|
||||
return <div className="text-dim">{children}</div>;
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Pencil, Plus, Trash2, Wrench } from 'lucide-react';
|
||||
import { api } from '../api/client';
|
||||
import type { Equipment, EquipmentKind } from '../api/types';
|
||||
import { EQUIPMENT_KIND_LABELS, formatEquipmentSpec } from '../lib/equipment';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { useListSearch } from '../store/list-search';
|
||||
import { api } from '../../api/client';
|
||||
import type { Equipment, EquipmentKind } from '../../api/types';
|
||||
import { EQUIPMENT_KIND_LABELS, formatEquipmentSpec } from '../../lib/equipment';
|
||||
import { useTopbar } from '../../topbar';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
Muted,
|
||||
Select,
|
||||
Textarea,
|
||||
} from '../components/ui';
|
||||
} from '../../components/ui';
|
||||
|
||||
interface FormState {
|
||||
name: string;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Pencil, Plus, Trash2, Dumbbell } from 'lucide-react';
|
||||
import { api } from '../api/client';
|
||||
import type { Equipment, Exercise } from '../api/types';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { useListSearch } from '../store/list-search';
|
||||
import { api } from '../../api/client';
|
||||
import type { Equipment, Exercise } from '../../api/types';
|
||||
import { useTopbar } from '../../topbar';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
Loading,
|
||||
Modal,
|
||||
Muted,
|
||||
} from '../components/ui';
|
||||
} from '../../components/ui';
|
||||
|
||||
interface FormState {
|
||||
name: string;
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Pencil, Plus, Trash2, Target } from 'lucide-react';
|
||||
import { api } from '../api/client';
|
||||
import type { FocusArea } from '../api/types';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { useListSearch } from '../store/list-search';
|
||||
import { api } from '../../api/client';
|
||||
import type { FocusArea } from '../../api/types';
|
||||
import { useTopbar } from '../../topbar';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
Modal,
|
||||
Muted,
|
||||
Textarea,
|
||||
} from '../components/ui';
|
||||
} from '../../components/ui';
|
||||
|
||||
interface FormState {
|
||||
name: string;
|
||||
@@ -2,11 +2,11 @@ import { useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { ImagePlus, Star, X } from 'lucide-react';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { api, getAccessToken } from '../api/client';
|
||||
import { API_BASE } from '../config';
|
||||
import type { Equipment, Gym, GymException, GymPhoto } from '../api/types';
|
||||
import { formatEquipmentSpec, formatGymEquipment } from '../lib/equipment';
|
||||
import { useTopbar } from '../../topbar';
|
||||
import { api, getAccessToken } from '../../api/client';
|
||||
import { API_BASE } from '../../config';
|
||||
import type { Equipment, Gym, GymException, GymPhoto } from '../../api/types';
|
||||
import { formatEquipmentSpec, formatGymEquipment } from '../../lib/equipment';
|
||||
import {
|
||||
BackButton,
|
||||
Badge,
|
||||
@@ -22,9 +22,9 @@ import {
|
||||
SectionHeader,
|
||||
Select,
|
||||
SuccessText,
|
||||
} from '../components/ui';
|
||||
import { AvailabilityEditor } from '../components/AvailabilityEditor';
|
||||
import { formatAvailability, normalizeAvailability, TIME_SLOTS } from '../lib/availability';
|
||||
} from '../../components/ui';
|
||||
import { AvailabilityEditor } from '../../components/AvailabilityEditor';
|
||||
import { formatAvailability, normalizeAvailability, TIME_SLOTS } from '../../lib/availability';
|
||||
|
||||
function InfoItem({ label, children }: { label: string; children: React.ReactNode }) {
|
||||
return (
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { api } from '../api/client';
|
||||
import { BackButton, Button, Card, ErrorText, Field, H1, Input } from '../components/ui';
|
||||
import { AvailabilityEditor } from '../components/AvailabilityEditor';
|
||||
import { emptyAvailability } from '../lib/availability';
|
||||
import type { Availability } from '../api/types';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { api } from '../../api/client';
|
||||
import { BackButton, Button, Card, ErrorText, Field, H1, Input } from '../../components/ui';
|
||||
import { AvailabilityEditor } from '../../components/AvailabilityEditor';
|
||||
import { emptyAvailability } from '../../lib/availability';
|
||||
import type { Availability } from '../../api/types';
|
||||
import { useTopbar } from '../../topbar';
|
||||
|
||||
export default function GymForm() {
|
||||
useTopbar({ title: 'Siłownie' });
|
||||
@@ -2,12 +2,12 @@ import { useEffect } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Clock, MapPin, Plus, Users, Building2, Dumbbell } from 'lucide-react';
|
||||
import { api } from '../api/client';
|
||||
import type { Gym } from '../api/types';
|
||||
import { Badge, Card, EmptyState, ErrorText, Loading, MetaItem } from '../components/ui';
|
||||
import { formatAvailability } from '../lib/availability';
|
||||
import { useListSearch } from '../store/list-search';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { api } from '../../api/client';
|
||||
import type { Gym } from '../../api/types';
|
||||
import { Badge, Card, EmptyState, ErrorText, Loading, MetaItem } from '../../components/ui';
|
||||
import { formatAvailability } from '../../lib/availability';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
import { useTopbar } from '../../topbar';
|
||||
import { gymPhotoSrc } from './GymDetail';
|
||||
|
||||
export default function GymsList() {
|
||||
@@ -2,9 +2,9 @@ import { useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Check, Search, X } from 'lucide-react';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { api } from '../api/client';
|
||||
import type { FocusArea, FocusChain, Gym, GymRole, User } from '../api/types';
|
||||
import { useTopbar } from '../../topbar';
|
||||
import { api } from '../../api/client';
|
||||
import type { FocusArea, FocusChain, Gym, GymRole, User } from '../../api/types';
|
||||
import {
|
||||
BackButton,
|
||||
Badge,
|
||||
@@ -22,11 +22,11 @@ import {
|
||||
SectionHeader,
|
||||
Select,
|
||||
SuccessText,
|
||||
} from '../components/ui';
|
||||
} from '../../components/ui';
|
||||
import { userName } from './UsersList';
|
||||
import { AvailabilityEditor } from '../components/AvailabilityEditor';
|
||||
import { Avatar } from '../components/Avatar';
|
||||
import { formatAvailability, normalizeAvailability } from '../lib/availability';
|
||||
import { AvailabilityEditor } from '../../components/AvailabilityEditor';
|
||||
import { Avatar } from '../../components/Avatar';
|
||||
import { formatAvailability, normalizeAvailability } from '../../lib/availability';
|
||||
|
||||
const ROLE_LABELS: Record<string, string> = {
|
||||
OWNER: 'Właściciel',
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { api } from '../api/client';
|
||||
import { BackButton, Button, Card, ErrorText, Field, H1, Input, Select } from '../components/ui';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { api } from '../../api/client';
|
||||
import { BackButton, Button, Card, ErrorText, Field, H1, Input, Select } from '../../components/ui';
|
||||
import { useTopbar } from '../../topbar';
|
||||
|
||||
export default function UserForm() {
|
||||
useTopbar({ title: 'Użytkownicy' });
|
||||
@@ -2,12 +2,12 @@ import { useEffect } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Plus, Users as UsersIcon } from 'lucide-react';
|
||||
import { api } from '../api/client';
|
||||
import type { User } from '../api/types';
|
||||
import { Badge, Card, EmptyState, ErrorText, ListRow, Loading } from '../components/ui';
|
||||
import { Avatar } from '../components/Avatar';
|
||||
import { useListSearch } from '../store/list-search';
|
||||
import { useTopbar } from '../topbar';
|
||||
import { api } from '../../api/client';
|
||||
import type { User } from '../../api/types';
|
||||
import { Badge, Card, EmptyState, ErrorText, ListRow, Loading } from '../../components/ui';
|
||||
import { Avatar } from '../../components/Avatar';
|
||||
import { useListSearch } from '../../store/list-search';
|
||||
import { useTopbar } from '../../topbar';
|
||||
|
||||
export function userName(u: User) {
|
||||
return u.firstName || u.lastName ? `${u.firstName ?? ''} ${u.lastName ?? ''}`.trim() : u.email;
|
||||
@@ -17,6 +17,5 @@ export function useTopbar(config: TopbarConfig) {
|
||||
useEffect(() => {
|
||||
registerPage(config);
|
||||
return () => registerPage(null);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user