Admin : liste des magasins retravaillée

Ville et dirigeant sous le nom, abonnement en pastille (payé, en attente,
impayé, résilié) avec la formule, tri (plus récents, nom, clients), état
vide distinguant « aucun magasin » et « aucun résultat ».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tony AVERTY 2026-10-07 15:27:58 +02:00
parent 0ec3827491
commit ec992beb2d
5 changed files with 71 additions and 34 deletions

View file

@ -15,17 +15,33 @@ function initials(name: string) {
.toUpperCase();
}
function subscriptionLabel(s: StoreListItem['subscriptionStatus']) {
if (s === 'ACTIVE') return <span style={{ color: 'var(--ok)', fontWeight: 600 }}>Actif</span>;
if (s === 'PAST_DUE') return <span style={{ color: 'var(--err)', fontWeight: 600 }}>Impayé</span>;
if (s === 'INCOMPLETE') return <span className="muted">En attente</span>;
return <span className="muted">—</span>;
function Subscription({ s }: { s: StoreListItem }) {
const [label, tone] =
s.subscriptionStatus === 'ACTIVE'
? ['Payé', 'ACTIVE']
: s.subscriptionStatus === 'PAST_DUE'
? ['Impayé', 'CLOSED']
: s.subscriptionStatus === 'INCOMPLETE'
? ['En attente', 'SUSPENDED']
: s.subscriptionStatus === 'CANCELED'
? ['Résilié', 'DRAFT']
: ['Aucun', 'DRAFT'];
return (
<span className="row" style={{ gap: 8, flexWrap: 'nowrap' }}>
<span className={`badge ${tone}`}>{label}</span>
{s.plan && <span className="role-pill mgr">{PLAN_LABEL[s.plan]}</span>}
</span>
);
}
type Sort = 'recent' | 'name' | 'customers';
const SORTS: [Sort, string][] = [['recent', 'Plus récents'], ['name', 'Nom'], ['customers', 'Clients']];
export function StoresPage() {
const navigate = useNavigate();
const [q, setQ] = useState('');
const [status, setStatus] = useState<StoreStatus | 'ALL'>('ALL');
const [sort, setSort] = useState<Sort>('recent');
const [data, setData] = useState<{ items: StoreListItem[]; counts: Partial<Record<StoreStatus, number>> } | null>(null);
const [error, setError] = useState<string | null>(null);
@ -43,6 +59,9 @@ export function StoresPage() {
return () => clearTimeout(t);
}, [q, status]);
const items = [...(data?.items ?? [])].sort((a, b) =>
sort === 'name' ? a.name.localeCompare(b.name) : sort === 'customers' ? b.customers - a.customers : b.createdAt.localeCompare(a.createdAt),
);
const total = data ? Object.values(data.counts).reduce((a, b) => a + (b ?? 0), 0) : 0;
const unpaid = data?.items.filter((s) => s.subscriptionStatus === 'PAST_DUE').length ?? 0;
const customers = data?.items.reduce((n, s) => n + s.customers, 0) ?? 0;
@ -71,7 +90,13 @@ export function StoresPage() {
<label htmlFor="search" className="sr-only">Rechercher un magasin</label>
<input id="search" type="search" className="input" placeholder="Rechercher par nom ou ville" value={q} onChange={(e) => setQ(e.target.value)} />
</div>
<div role="group" aria-label="Filtrer par statut" className="row" style={{ gap: 8 }}>
<label className="row" style={{ gap: 8, marginLeft: 'auto' }}>
<span className="muted" style={{ fontSize: 14 }}>Trier par</span>
<select className="input" style={{ width: 'auto', height: 40 }} value={sort} onChange={(e) => setSort(e.target.value as Sort)}>
{SORTS.map(([k, label]) => <option key={k} value={k}>{label}</option>)}
</select>
</label>
<div role="group" aria-label="Filtrer par statut" className="row" style={{ gap: 8, flexBasis: '100%' }}>
{FILTERS.map((f) => (
<button key={f} type="button" className="chip" aria-pressed={status === f} onClick={() => setStatus(f)}>
{f === 'ALL' ? 'Tous' : STATUS_LABEL[f]}
@ -88,8 +113,7 @@ export function StoresPage() {
<table style={{ minWidth: 860 }}>
<thead>
<tr>
<th scope="col" style={{ paddingLeft: 24 }}>Magasin</th>
<th scope="col">Ville</th>
<th scope="col" style={{ paddingLeft: 24, width: '36%' }}>Magasin</th>
<th scope="col">Statut</th>
<th scope="col" className="num">Clients</th>
<th scope="col">Abonnement</th>
@ -97,20 +121,22 @@ export function StoresPage() {
</tr>
</thead>
<tbody>
{data?.items.map((s) => (
{items.map((s) => (
<tr key={s.id} className="clickable" onClick={() => navigate(`/magasins/${s.id}`)}>
<td style={{ paddingLeft: 24 }}>
<Link to={`/magasins/${s.id}`} style={{ display: 'inline-flex', alignItems: 'center', gap: 12, color: 'var(--text)', fontWeight: 600, textDecoration: 'none' }}>
<span style={{ width: 36, height: 36, borderRadius: 10, background: 'var(--primary-soft)', color: 'var(--primary)', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', fontSize: 13, fontWeight: 800 }}>
{initials(s.name)}
</span>
<span>
{s.name}
<span className="muted" style={{ display: 'block', fontWeight: 400, fontSize: 14 }}>{s.city} · {s.contactName}</span>
</span>
</Link>
</td>
<td>{s.city}</td>
<td><StatusBadge status={s.status} /></td>
<td className="num">{s.customers}</td>
<td>{subscriptionLabel(s.subscriptionStatus)}{s.plan && <span className="muted" style={{ fontSize: 14 }}> · {PLAN_LABEL[s.plan]}</span>}</td>
<td className="num" style={{ fontWeight: 700 }}>{s.customers.toLocaleString('fr-FR')}</td>
<td><Subscription s={s} /></td>
<td className="muted">{new Date(s.createdAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short', year: 'numeric' })}</td>
</tr>
))}
@ -118,9 +144,20 @@ export function StoresPage() {
</table>
</div>
{data && data.items.length === 0 && (
<div style={{ padding: '48px 24px', textAlign: 'center' }}>
<div style={{ padding: '48px 24px', textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 }}>
<span style={{ fontSize: 36 }} aria-hidden="true">🏪</span>
{total === 0 ? (
<>
<strong>Aucun magasin pour l’instant</strong>
<p className="muted" style={{ margin: 0 }}>Les commerçants s’inscrivent seuls depuis la page Tarif ; vous pouvez aussi en créer un ici.</p>
<Link to="/magasins/nouveau" className="btn" style={{ marginTop: 8 }}>Créer un magasin</Link>
</>
) : (
<>
<strong>Aucun magasin trouvé</strong>
<p className="muted" style={{ margin: 0 }}>Essayez un autre nom, une autre ville ou retirez le filtre de statut.</p>
</>
)}
</div>
)}
</div>

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@
<title>Affichette — MonEspacePro</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link href="https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<script type="module" crossorigin src="/assets/espace/index-C1V6PUCU.js"></script>
<script type="module" crossorigin src="/assets/espace/index-X3_Razph.js"></script>
<link rel="stylesheet" crossorigin href="/assets/espace/index-Y3IqSL08.css">
</head>
<body>

View file

@ -8,7 +8,7 @@
<title>Mon espace — MonEspacePro</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link href="https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<script type="module" crossorigin src="/assets/espace/index-C1V6PUCU.js"></script>
<script type="module" crossorigin src="/assets/espace/index-X3_Razph.js"></script>
<link rel="stylesheet" crossorigin href="/assets/espace/index-Y3IqSL08.css">
</head>
<body>

View file

@ -7,7 +7,7 @@
<title>Créer mon programme de fidélité — MonEspacePro</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link href="https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap" rel="stylesheet" />
<script type="module" crossorigin src="/assets/espace/index-C1V6PUCU.js"></script>
<script type="module" crossorigin src="/assets/espace/index-X3_Razph.js"></script>
<link rel="stylesheet" crossorigin href="/assets/espace/index-Y3IqSL08.css">
</head>
<body>