Back-office retravaillé
Liste : chiffres clés (ouverts, en cours d'ouverture, impayés, cartes clients), lignes entièrement cliquables avec survol. Fiche magasin : en-tête en carte avec initiale, contact, étapes d'ouverture (abonnement payé, carte conçue, programme ouvert) et lien d'inscription à copier. L'API indique si la carte est conçue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0c4fbec544
commit
55a0e62a3a
10 changed files with 80 additions and 34 deletions
|
|
@ -187,6 +187,8 @@ export interface StoreListItem extends Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StoreDetail extends Store {
|
export interface StoreDetail extends Store {
|
||||||
|
/** Carte de fidélité conçue. */
|
||||||
|
hasCard: boolean;
|
||||||
counts: { cards: number; staff: number; transactions: number };
|
counts: { cards: number; staff: number; transactions: number };
|
||||||
subscription: { status: SubscriptionStatus; plan: Plan; stripeSubscriptionId: string | null } | null;
|
subscription: { status: SubscriptionStatus; plan: Plan; stripeSubscriptionId: string | null } | null;
|
||||||
/** Lien encodé dans le QR d'inscription. */
|
/** Lien encodé dans le QR d'inscription. */
|
||||||
|
|
|
||||||
|
|
@ -44,11 +44,13 @@ export function StorePage() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="row between">
|
|
||||||
<div>
|
|
||||||
<Link to="/magasins">← Magasins</Link>
|
<Link to="/magasins">← Magasins</Link>
|
||||||
|
<section className="card store-head">
|
||||||
|
<div className="store-id">
|
||||||
|
<span className="store-avatar" aria-hidden="true">{store.name.charAt(0).toUpperCase()}</span>
|
||||||
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
|
||||||
<div className="row" style={{ gap: 12 }}>
|
<div className="row" style={{ gap: 12 }}>
|
||||||
<h1>{store.name}</h1>
|
<h1 style={{ fontSize: 28, lineHeight: '34px' }}>{store.name}</h1>
|
||||||
<StatusBadge status={store.status} />
|
<StatusBadge status={store.status} />
|
||||||
{store.subscription?.stripeSubscriptionId && store.subscription.status !== 'CANCELED' && (
|
{store.subscription?.stripeSubscriptionId && store.subscription.status !== 'CANCELED' && (
|
||||||
<NavLink to="facturation" className="badge DRAFT" style={{ textDecoration: 'none' }} title="Formule d'abonnement">
|
<NavLink to="facturation" className="badge DRAFT" style={{ textDecoration: 'none' }} title="Formule d'abonnement">
|
||||||
|
|
@ -57,8 +59,15 @@ export function StorePage() {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className="muted" style={{ margin: 0 }}>
|
<p className="muted" style={{ margin: 0 }}>
|
||||||
{store.city} · {store.counts.cards} clients · {store.counts.staff} employés
|
{store.city} · {store.counts.cards} clients · {store.counts.staff} employés · {store.contactName}
|
||||||
</p>
|
</p>
|
||||||
|
{/* Étapes d'ouverture : le magasin s'ouvre seul quand les deux premières sont faites */}
|
||||||
|
<ul className="open-steps" aria-label="Étapes d’ouverture">
|
||||||
|
<li className={store.subscription?.status === 'ACTIVE' ? 'done' : ''}>{store.subscription?.status === 'ACTIVE' ? '✓' : '○'} Abonnement payé</li>
|
||||||
|
<li className={store.hasCard ? 'done' : ''}>{store.hasCard ? '✓' : '○'} Carte conçue</li>
|
||||||
|
<li className={store.status === 'ACTIVE' ? 'done' : ''}>{store.status === 'ACTIVE' ? '✓' : '○'} Programme ouvert</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="row" style={{ gap: 8 }}>
|
<div className="row" style={{ gap: 8 }}>
|
||||||
{(store.status === 'DRAFT' || store.status === 'CLOSED') && (
|
{(store.status === 'DRAFT' || store.status === 'CLOSED') && (
|
||||||
|
|
@ -76,7 +85,12 @@ export function StorePage() {
|
||||||
<button className="btn secondary" onClick={() => changeStatus('CLOSED', 'Fermer ce magasin ?')}>Fermer</button>
|
<button className="btn secondary" onClick={() => changeStatus('CLOSED', 'Fermer ce magasin ?')}>Fermer</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="copy-line" style={{ flexBasis: '100%' }}>
|
||||||
|
<span className="muted">Lien d’inscription :</span>
|
||||||
|
<code>{store.enrollUrl}</code>
|
||||||
|
<button type="button" className="btn secondary small" onClick={() => navigator.clipboard?.writeText(store.enrollUrl).then(() => setNotice('Lien copié.'))}>Copier</button>
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
{store.status === 'SUSPENDED' && (
|
{store.status === 'SUSPENDED' && (
|
||||||
<div className="alert warn" role="status">
|
<div className="alert warn" role="status">
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link, useNavigate } from 'react-router-dom';
|
||||||
import { api, PLAN_LABEL, StoreListItem, StoreStatus } from '../api';
|
import { api, PLAN_LABEL, StoreListItem, StoreStatus } from '../api';
|
||||||
import { STATUS_LABEL, StatusBadge } from '../components/Layout';
|
import { STATUS_LABEL, StatusBadge } from '../components/Layout';
|
||||||
|
|
||||||
|
|
@ -23,6 +23,7 @@ function subscriptionLabel(s: StoreListItem['subscriptionStatus']) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StoresPage() {
|
export function StoresPage() {
|
||||||
|
const navigate = useNavigate();
|
||||||
const [q, setQ] = useState('');
|
const [q, setQ] = useState('');
|
||||||
const [status, setStatus] = useState<StoreStatus | 'ALL'>('ALL');
|
const [status, setStatus] = useState<StoreStatus | 'ALL'>('ALL');
|
||||||
const [data, setData] = useState<{ items: StoreListItem[]; counts: Partial<Record<StoreStatus, number>> } | null>(null);
|
const [data, setData] = useState<{ items: StoreListItem[]; counts: Partial<Record<StoreStatus, number>> } | null>(null);
|
||||||
|
|
@ -44,19 +45,27 @@ export function StoresPage() {
|
||||||
|
|
||||||
const total = data ? Object.values(data.counts).reduce((a, b) => a + (b ?? 0), 0) : 0;
|
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 unpaid = data?.items.filter((s) => s.subscriptionStatus === 'PAST_DUE').length ?? 0;
|
||||||
|
const customers = data?.items.reduce((n, s) => n + s.customers, 0) ?? 0;
|
||||||
|
const pending = data?.counts.DRAFT ?? 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="row between" style={{ alignItems: 'flex-end' }}>
|
<div className="row between" style={{ alignItems: 'flex-end' }}>
|
||||||
<div>
|
<div>
|
||||||
<h1>Magasins</h1>
|
<h1>Magasins</h1>
|
||||||
<p className="muted" style={{ margin: 0 }}>
|
<p className="muted" style={{ margin: 0 }}>{total} magasins inscrits</p>
|
||||||
{total} magasins inscrits · {unpaid} abonnements impayés
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<Link to="/magasins/nouveau" className="btn">+ Nouveau magasin</Link>
|
<Link to="/magasins/nouveau" className="btn">+ Nouveau magasin</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Chiffres clés (liste affichée) */}
|
||||||
|
<div className="kpis">
|
||||||
|
<div className="kpi ok"><b>{data?.counts.ACTIVE ?? '—'}</b><span>magasins ouverts</span></div>
|
||||||
|
<div className={`kpi${pending ? ' warn' : ''}`}><b>{data ? pending : '—'}</b><span>en cours d’ouverture</span></div>
|
||||||
|
<div className={`kpi${unpaid ? ' err' : ''}`}><b>{data ? unpaid : '—'}</b><span>abonnements impayés</span></div>
|
||||||
|
<div className="kpi"><b>{data ? customers.toLocaleString('fr-FR') : '—'}</b><span>cartes clients</span></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div style={{ flex: '1 1 320px', maxWidth: 420 }}>
|
<div style={{ flex: '1 1 320px', maxWidth: 420 }}>
|
||||||
<label htmlFor="search" className="sr-only">Rechercher un magasin</label>
|
<label htmlFor="search" className="sr-only">Rechercher un magasin</label>
|
||||||
|
|
@ -89,7 +98,7 @@ export function StoresPage() {
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{data?.items.map((s) => (
|
{data?.items.map((s) => (
|
||||||
<tr key={s.id}>
|
<tr key={s.id} className="clickable" onClick={() => navigate(`/magasins/${s.id}`)}>
|
||||||
<td style={{ paddingLeft: 24 }}>
|
<td style={{ paddingLeft: 24 }}>
|
||||||
<Link to={`/magasins/${s.id}`} style={{ display: 'inline-flex', alignItems: 'center', gap: 12, color: 'var(--text)', fontWeight: 600, textDecoration: 'none' }}>
|
<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 }}>
|
<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 }}>
|
||||||
|
|
|
||||||
|
|
@ -233,3 +233,22 @@ dialog::backdrop { background: rgb(0 0 0 / 0.45); }
|
||||||
.s-side { position: static; }
|
.s-side { position: static; }
|
||||||
}
|
}
|
||||||
@media (max-width: 520px) { .s-two { grid-template-columns: 1fr; } }
|
@media (max-width: 520px) { .s-two { grid-template-columns: 1fr; } }
|
||||||
|
|
||||||
|
/* ── Back-office : chiffres clés, lignes cliquables, en-tête de fiche ── */
|
||||||
|
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
|
||||||
|
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
|
||||||
|
.kpi b { font-size: 28px; font-weight: 800; line-height: 1.2; }
|
||||||
|
.kpi span { font-size: 14px; color: var(--text-3); }
|
||||||
|
.kpi.ok b { color: var(--ok); }
|
||||||
|
.kpi.warn b { color: var(--warn); }
|
||||||
|
.kpi.err b { color: var(--err); }
|
||||||
|
tr.clickable { cursor: pointer; }
|
||||||
|
tr.clickable:hover td { background: var(--primary-soft); }
|
||||||
|
.store-head { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: space-between; }
|
||||||
|
.store-id { display: flex; gap: 16px; align-items: center; }
|
||||||
|
.store-avatar { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 22px; display: grid; place-items: center; flex: none; }
|
||||||
|
.open-steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
|
||||||
|
.open-steps li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); font-size: 14px; font-weight: 600; }
|
||||||
|
.open-steps li.done { background: var(--ok-bg); color: var(--ok); }
|
||||||
|
.copy-line { display: flex; gap: 8px; align-items: center; font-size: 14px; }
|
||||||
|
.copy-line code { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; word-break: break-all; }
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,15 @@ export class StoresService {
|
||||||
where: { id },
|
where: { id },
|
||||||
include: {
|
include: {
|
||||||
subscription: true,
|
subscription: true,
|
||||||
|
cardDesign: { select: { id: true } },
|
||||||
_count: { select: { cards: true, staff: true, transactions: true } },
|
_count: { select: { cards: true, staff: true, transactions: true } },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!store) throw new NotFoundException('Magasin introuvable');
|
if (!store) throw new NotFoundException('Magasin introuvable');
|
||||||
const { _count, subscription, ...s } = store;
|
const { _count, subscription, cardDesign, ...s } = store;
|
||||||
return {
|
return {
|
||||||
...this.present(s),
|
...this.present(s),
|
||||||
|
hasCard: !!cardDesign,
|
||||||
counts: _count,
|
counts: _count,
|
||||||
subscription,
|
subscription,
|
||||||
enrollUrl: `${this.config.get('webUrl')}/c/${s.slug}`,
|
enrollUrl: `${this.config.get('webUrl')}/c/${s.slug}`,
|
||||||
|
|
|
||||||
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-fxzUSxGt.js"></script>
|
<script type="module" crossorigin src="/assets/espace/index-DOsOn4Cf.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-BTYDwwaq.css">
|
<link rel="stylesheet" crossorigin href="/assets/espace/index-Bj5p9Bgz.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-fxzUSxGt.js"></script>
|
<script type="module" crossorigin src="/assets/espace/index-DOsOn4Cf.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-BTYDwwaq.css">
|
<link rel="stylesheet" crossorigin href="/assets/espace/index-Bj5p9Bgz.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-fxzUSxGt.js"></script>
|
<script type="module" crossorigin src="/assets/espace/index-DOsOn4Cf.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-BTYDwwaq.css">
|
<link rel="stylesheet" crossorigin href="/assets/espace/index-Bj5p9Bgz.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue