Admin : onglet Statistiques retravaillé
Période en contrôle segmenté, exports à pictogramme, indicateurs à pictogramme, fréquentation et heures d'affluence côte à côte sur grand écran, meilleurs clients avec rang et podium. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7a926f051e
commit
9adff56acf
7 changed files with 48 additions and 39 deletions
|
|
@ -40,10 +40,10 @@ function Change({ value }: { value: number | null }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Kpi({ label, value, hint, change }: { label: string; value: string; hint?: string; change?: number | null }) {
|
function Kpi({ icon, label, value, hint, change }: { icon: string; label: string; value: string; hint?: string; change?: number | null }) {
|
||||||
return (
|
return (
|
||||||
<div className="card" style={{ padding: 16, display: 'flex', flexDirection: 'column', gap: 4 }}>
|
<div className="card" style={{ padding: 16, display: 'flex', flexDirection: 'column', gap: 4 }}>
|
||||||
<span className="muted" style={{ fontSize: 14 }}>{label}</span>
|
<span className="muted" style={{ fontSize: 14, display: 'flex', gap: 8, alignItems: 'center' }}><span aria-hidden="true">{icon}</span>{label}</span>
|
||||||
<span style={{ fontSize: 26, fontWeight: 800 }}>{value}</span>
|
<span style={{ fontSize: 26, fontWeight: 800 }}>{value}</span>
|
||||||
<span style={{ display: 'flex', gap: 8, alignItems: 'baseline' }}>
|
<span style={{ display: 'flex', gap: 8, alignItems: 'baseline' }}>
|
||||||
{change !== undefined && <Change value={change} />}
|
{change !== undefined && <Change value={change} />}
|
||||||
|
|
@ -139,14 +139,14 @@ export function StatsTab({ storeId, storeSlug }: { storeId: string; storeSlug: s
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="row between" style={{ alignItems: 'center' }}>
|
<div className="row between" style={{ alignItems: 'center' }}>
|
||||||
<div role="group" aria-label="Période" className="row" style={{ gap: 8 }}>
|
<div role="group" aria-label="Période" className="s-seg">
|
||||||
{PERIODS.map(([d, label]) => (
|
{PERIODS.map(([d, label]) => (
|
||||||
<button key={d} type="button" className="chip" aria-pressed={days === d} onClick={() => setDays(d)}>{label}</button>
|
<button key={d} type="button" aria-pressed={days === d} onClick={() => setDays(d)}>{label}</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ gap: 8 }}>
|
<div className="row" style={{ gap: 8 }}>
|
||||||
<button className="btn secondary" disabled={!!busy} onClick={() => download('customers')}>{busy === 'customers' ? 'Export…' : 'Exporter les clients (CSV)'}</button>
|
<button className="btn secondary" disabled={!!busy} onClick={() => download('customers')}>{busy === 'customers' ? 'Export…' : '📇 Clients (CSV)'}</button>
|
||||||
<button className="btn secondary" disabled={!!busy} onClick={() => download('transactions')}>{busy === 'transactions' ? 'Export…' : 'Exporter les opérations (CSV)'}</button>
|
<button className="btn secondary" disabled={!!busy} onClick={() => download('transactions')}>{busy === 'transactions' ? 'Export…' : '🧾 Opérations (CSV)'}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert error" role="alert">{error}</div>}
|
{error && <div className="alert error" role="alert">{error}</div>}
|
||||||
|
|
@ -156,17 +156,18 @@ export function StatsTab({ storeId, storeSlug }: { storeId: string; storeSlug: s
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(190px, 1fr))', gap: 12 }}>
|
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(190px, 1fr))', gap: 12 }}>
|
||||||
<Kpi label="Passages" value={nf(k.visits)} change={k.visitsChange} hint="vs période précédente" />
|
<Kpi icon="🚶" label="Passages" value={nf(k.visits)} change={k.visitsChange} hint="vs période précédente" />
|
||||||
<Kpi label="Nouvelles cartes" value={nf(k.newCards)} change={k.newCardsChange} hint={`${nf(k.cardsTotal)} au total`} />
|
<Kpi icon="🆕" label="Nouvelles cartes" value={nf(k.newCards)} change={k.newCardsChange} hint={`${nf(k.cardsTotal)} au total`} />
|
||||||
<Kpi label="Clients actifs" value={nf(k.activeCustomers)} hint={`${k.visitsPerCustomer.toLocaleString('fr-FR')} passage(s) par client`} />
|
<Kpi icon="👥" label="Clients actifs" value={nf(k.activeCustomers)} hint={`${k.visitsPerCustomer.toLocaleString('fr-FR')} passage(s) par client`} />
|
||||||
<Kpi label="Clients fidèles" value={k.returningRate === null ? '—' : `${k.returningRate.toLocaleString('fr-FR')} %`} hint="venus au moins 2 fois" />
|
<Kpi icon="🔁" label="Clients fidèles" value={k.returningRate === null ? '—' : `${k.returningRate.toLocaleString('fr-FR')} %`} hint="venus au moins 2 fois" />
|
||||||
{data.pointsMode === 'AMOUNT' && (
|
{data.pointsMode === 'AMOUNT' && (
|
||||||
<Kpi label="Achats enregistrés" value={euros(k.revenueCents)} hint={k.averageBasketCents === null ? undefined : `panier moyen ${euros(k.averageBasketCents)}`} />
|
<Kpi icon="💶" label="Achats enregistrés" value={euros(k.revenueCents)} hint={k.averageBasketCents === null ? undefined : `panier moyen ${euros(k.averageBasketCents)}`} />
|
||||||
)}
|
)}
|
||||||
<Kpi label="Récompenses" value={nf(k.rewardsRedeemed)} hint={`${nf(k.pointsGiven)} ${unit} distribués`} />
|
<Kpi icon="🎁" label="Récompenses" value={nf(k.rewardsRedeemed)} hint={`${nf(k.pointsGiven)} ${unit} distribués`} />
|
||||||
<Kpi label="Cartes dans Apple Wallet" value={k.appleWalletRate === null ? '—' : `${k.appleWalletRate.toLocaleString('fr-FR')} %`} hint="iPhone joignables" />
|
<Kpi icon="📱" label="Cartes dans Apple Wallet" value={k.appleWalletRate === null ? '—' : `${k.appleWalletRate.toLocaleString('fr-FR')} %`} hint="iPhone joignables" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="stats-pair">
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<h2>Fréquentation</h2>
|
<h2>Fréquentation</h2>
|
||||||
<p className="muted" style={{ marginTop: 0, fontSize: 14 }}>
|
<p className="muted" style={{ marginTop: 0, fontSize: 14 }}>
|
||||||
|
|
@ -182,6 +183,7 @@ export function StatsTab({ storeId, storeSlug }: { storeId: string; storeSlug: s
|
||||||
<p className="muted" style={{ marginTop: 0 }}>{data.busiest ? `Créneau le plus fréquenté : ${data.busiest}.` : 'Pas encore de passage sur la période.'}</p>
|
<p className="muted" style={{ marginTop: 0 }}>{data.busiest ? `Créneau le plus fréquenté : ${data.busiest}.` : 'Pas encore de passage sur la période.'}</p>
|
||||||
<Heatmap heat={data.heatmap} />
|
<Heatmap heat={data.heatmap} />
|
||||||
</section>
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<h2>Meilleurs clients</h2>
|
<h2>Meilleurs clients</h2>
|
||||||
|
|
@ -192,6 +194,7 @@ export function StatsTab({ storeId, storeSlug }: { storeId: string; storeSlug: s
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th scope="col" style={{ width: 56 }}>Rang</th>
|
||||||
<th scope="col">Client</th>
|
<th scope="col">Client</th>
|
||||||
<th scope="col" className="num">Passages</th>
|
<th scope="col" className="num">Passages</th>
|
||||||
{data.pointsMode === 'AMOUNT' && <th scope="col" className="num">Achats</th>}
|
{data.pointsMode === 'AMOUNT' && <th scope="col" className="num">Achats</th>}
|
||||||
|
|
@ -201,7 +204,8 @@ export function StatsTab({ storeId, storeSlug }: { storeId: string; storeSlug: s
|
||||||
<tbody>
|
<tbody>
|
||||||
{data.top.map((t, i) => (
|
{data.top.map((t, i) => (
|
||||||
<tr key={i}>
|
<tr key={i}>
|
||||||
<td>{t.firstName}</td>
|
<td><span className={`rank${i < 3 ? ' top' : ''}`}>{['🥇', '🥈', '🥉'][i] ?? i + 1}</span></td>
|
||||||
|
<td style={{ fontWeight: 600 }}>{t.firstName}</td>
|
||||||
<td className="num">{t.visits}</td>
|
<td className="num">{t.visits}</td>
|
||||||
{data.pointsMode === 'AMOUNT' && <td className="num">{euros(t.amountCents)}</td>}
|
{data.pointsMode === 'AMOUNT' && <td className="num">{euros(t.amountCents)}</td>}
|
||||||
<td className="num">{t.balance}</td>
|
<td className="num">{t.balance}</td>
|
||||||
|
|
|
||||||
|
|
@ -280,3 +280,8 @@ tr.clickable:hover td { background: var(--primary-soft); }
|
||||||
.switch input:checked + span::after { transform: translateX(22px); }
|
.switch input:checked + span::after { transform: translateX(22px); }
|
||||||
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
|
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
|
||||||
.switch input:disabled + span { opacity: .5; }
|
.switch input:disabled + span { opacity: .5; }
|
||||||
|
|
||||||
|
/* ── Onglet Statistiques ── */
|
||||||
|
.stats-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
|
||||||
|
.rank { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--text-3); }
|
||||||
|
.rank.top { background: var(--warn-bg); font-size: 17px; }
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -8,8 +8,8 @@
|
||||||
<title>Affichette — MonEspacePro</title>
|
<title>Affichette — MonEspacePro</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<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" />
|
<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-Ck55rr7u.js"></script>
|
<script type="module" crossorigin src="/assets/espace/index-CWiD3xSy.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.css">
|
<link rel="stylesheet" crossorigin href="/assets/espace/index-DGLmXErW.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
<title>Mon espace — MonEspacePro</title>
|
<title>Mon espace — MonEspacePro</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<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" />
|
<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-Ck55rr7u.js"></script>
|
<script type="module" crossorigin src="/assets/espace/index-CWiD3xSy.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.css">
|
<link rel="stylesheet" crossorigin href="/assets/espace/index-DGLmXErW.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
<title>Créer mon programme de fidélité — MonEspacePro</title>
|
<title>Créer mon programme de fidélité — MonEspacePro</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<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" />
|
<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-Ck55rr7u.js"></script>
|
<script type="module" crossorigin src="/assets/espace/index-CWiD3xSy.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.css">
|
<link rel="stylesheet" crossorigin href="/assets/espace/index-DGLmXErW.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue