Admin : onglet Modules retravaillé

Chiffres clés (activés, disponibles, sur mesure), pictogramme par module,
interrupteur d'activation en un clic, chiffres du module en tuiles, réglages
et messages regroupés, barre d'enregistrement fixe signalant les
modifications non enregistrées.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tony AVERTY 2026-10-07 15:19:27 +02:00
parent 5119d0ea24
commit 6968d26ce6
7 changed files with 100 additions and 45 deletions

View file

@ -23,6 +23,10 @@ export interface ModuleInfo {
stats?: Record<string, number | string | null> | null; stats?: Record<string, number | string | null> | null;
} }
/** Pictogramme de chaque module (même que dans l'app). */
const ICON: Record<string, string> = { campaigns: '📣', reminders: '⏰', birthday: '🎂', reviews: '⭐', referral: '🤝', stats: '📊', whiteLabel: '🏷️' };
const isMessage = (f: FieldDef) => f.type === 'text' || f.type === 'textarea';
/** Origine du module pour ce magasin. */ /** Origine du module pour ce magasin. */
function Origin({ m }: { m: ModuleInfo }) { function Origin({ m }: { m: ModuleInfo }) {
const [label, tone] = const [label, tone] =
@ -131,15 +135,33 @@ function ModulePanel({ storeId, storeName, initial, onChanged }: { storeId: stri
return ( return (
<section className="card" style={{ display: 'flex', flexDirection: 'column', gap: 14 }}> <section className="card" style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
<div className="row between" style={{ alignItems: 'flex-start', gap: 12 }}> <div className="row between" style={{ alignItems: 'flex-start', gap: 12 }}>
<div style={{ flex: '1 1 320px' }}> <div style={{ flex: '1 1 320px', display: 'flex', gap: 14 }}>
<span className={`mod-ic${m.available && m.config.enabled ? ' on' : ''}`} aria-hidden="true">{ICON[m.id] ?? '🧩'}</span>
<div>
<div className="row" style={{ gap: 10, alignItems: 'center' }}> <div className="row" style={{ gap: 10, alignItems: 'center' }}>
<h2 style={{ margin: 0 }}>{m.name}</h2> <h2 style={{ margin: 0 }}>{m.name}</h2>
<Origin m={m} /> <Origin m={m} />
{m.available && <span className={`badge ${m.config.enabled ? 'ACTIVE' : 'DRAFT'}`}>{m.config.enabled ? 'Activé' : 'Désactivé'}</span>}
</div> </div>
<p className="muted" style={{ margin: '6px 0 0' }}>{m.description}</p> <p className="muted" style={{ margin: '6px 0 0' }}>{m.description}</p>
</div> </div>
</div>
<div className="row" style={{ gap: 8 }}> <div className="row" style={{ gap: 8 }}>
{/* Interrupteur : active ou désactive sans ouvrir les réglages */}
{m.available && (
<label className="switch" title={m.config.enabled ? 'Désactiver le module' : 'Activer le module'}>
<input
type="checkbox"
checked={m.config.enabled}
disabled={busy}
onChange={(e) => {
const enabled = e.target.checked;
run(() => api.put<ModuleInfo>(base, { enabled }), enabled ? 'Module activé.' : 'Module désactivé.');
}}
/>
<span aria-hidden="true" />
<span className="sr-only">Module activé</span>
</label>
)}
<label className="sr-only" htmlFor={`ov-${m.id}`}>Disponibilité du module</label> <label className="sr-only" htmlFor={`ov-${m.id}`}>Disponibilité du module</label>
<select <select
id={`ov-${m.id}`} id={`ov-${m.id}`}
@ -168,25 +190,33 @@ function ModulePanel({ storeId, storeName, initial, onChanged }: { storeId: stri
{open && ( {open && (
<> <>
{!m.available && <div className="alert warn">Module non disponible pour ce magasin : ajoutez-le sur mesure ou changez de formule pour l'activer. Vous pouvez déjà préparer ses réglages.</div>} {!m.available && <div className="alert warn">Module non disponible pour ce magasin : ajoutez-le sur mesure ou changez de formule pour l'activer. Vous pouvez déjà préparer ses réglages.</div>}
<label style={{ display: 'flex', alignItems: 'center', gap: 10, fontWeight: 700 }}>
<input type="checkbox" checked={!!values.enabled} onChange={(e) => setValues({ ...values, enabled: e.target.checked })} />
Module activé
</label>
{m.fields.map((f) => (
<Field key={f.key} f={f} value={values[f.key]} onChange={(v) => setValues({ ...values, [f.key]: v })} />
))}
{m.stats && ( {m.stats && (
<div className="row" style={{ gap: 24 }}> <div className="kpis">
{Object.entries(m.stats).map(([k, v]) => ( {Object.entries(m.stats).map(([k, v]) => (
<div key={k}> <div key={k} className="kpi"><b>{v ?? '—'}</b><span>{k}</span></div>
<div style={{ fontSize: 22, fontWeight: 800 }}>{v ?? '—'}</div>
<div className="muted" style={{ fontSize: 14 }}>{k}</div>
</div>
))} ))}
</div> </div>
)} )}
{(
[
['Réglages', m.fields.filter((f) => !isMessage(f)), 'mod-grid'],
['Messages', m.fields.filter(isMessage), 'mod-stack'],
] as const
).map(([title, fields, layout]) =>
fields.length ? (
<fieldset key={title} className="mod-group">
<legend>{title}</legend>
<div className={layout}>
{fields.map((f) => (
<Field key={f.key} f={f} value={values[f.key]} onChange={(v) => setValues({ ...values, [f.key]: v })} />
))}
</div>
</fieldset>
) : null,
)}
{m.id === 'stats' && <Link to="../statistiques">Voir les statistiques du magasin →</Link>} {m.id === 'stats' && <Link to="../statistiques">Voir les statistiques du magasin →</Link>}
<div className="row" style={{ gap: 8, justifyContent: 'flex-end' }}> <div className={`row mod-save${dirty ? ' dirty' : ''}`} style={{ gap: 8, justifyContent: 'flex-end' }}>
{dirty && <span className="muted" style={{ marginRight: 'auto', fontSize: 14 }}>Modifications non enregistrées</span>}
{dirty && <button type="button" className="btn secondary" disabled={busy} onClick={() => setValues(m.config)}>Annuler</button>} {dirty && <button type="button" className="btn secondary" disabled={busy} onClick={() => setValues(m.config)}>Annuler</button>}
<button type="button" className="btn" disabled={busy || !dirty} onClick={() => run(() => api.put<ModuleInfo>(base, values), 'Réglages enregistrés.')}> <button type="button" className="btn" disabled={busy || !dirty} onClick={() => run(() => api.put<ModuleInfo>(base, values), 'Réglages enregistrés.')}>
{busy ? 'Enregistrement…' : 'Enregistrer'} {busy ? 'Enregistrement…' : 'Enregistrer'}
@ -210,11 +240,18 @@ export function ModulesTab({ storeId, storeName }: { storeId: string; storeName:
if (!list) return error ? <div className="alert error">{error}</div> : <p className="muted">Chargement…</p>; if (!list) return error ? <div className="alert error">{error}</div> : <p className="muted">Chargement…</p>;
const active = list.filter((m) => m.available && m.config.enabled).length; const active = list.filter((m) => m.available && m.config.enabled).length;
const available = list.filter((m) => m.available).length;
const custom = list.filter((m) => m.override !== null).length;
return ( return (
<> <>
<div className="kpis">
<div className="kpi ok"><b>{active}</b><span>modules activés</span></div>
<div className="kpi"><b>{available} / {list.length}</b><span>disponibles pour ce magasin</span></div>
<div className="kpi"><b>{custom}</b><span>ajout(s) ou retrait(s) sur mesure</span></div>
</div>
<p className="muted" style={{ margin: 0 }}> <p className="muted" style={{ margin: 0 }}>
{active} module(s) actif(s) sur {list.length}. Chaque module est inclus ou non dans la formule ; vous pouvez l'ajouter ou le retirer sur mesure, Chaque module est inclus ou non dans la formule ; vous pouvez l’ajouter ou le retirer sur mesure. L’interrupteur l’active d’un clic,
et tous ses textes et réglages sont personnalisables. Le dirigeant peut aussi les régler depuis l'app Pro. « Personnaliser » ouvre tous ses textes et réglages. Le dirigeant peut aussi les régler depuis l’app MonEspacePro.
</p> </p>
{list.map((m) => ( {list.map((m) => (
<ModulePanel key={m.id} storeId={storeId} storeName={storeName} initial={m} onChanged={load} /> <ModulePanel key={m.id} storeId={storeId} storeName={storeName} initial={m} onChanged={load} />

View file

@ -262,3 +262,21 @@ tr.clickable:hover td { background: var(--primary-soft); }
.staff-avatar.big { width: 64px; height: 64px; font-size: 30px; background: var(--primary-soft); } .staff-avatar.big { width: 64px; height: 64px; font-size: 30px; background: var(--primary-soft); }
.role-pill { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 700; background: var(--surface-2); color: var(--text-2); } .role-pill { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 700; background: var(--surface-2); color: var(--text-2); }
.role-pill.mgr { background: var(--primary-soft); color: var(--primary); } .role-pill.mgr { background: var(--primary-soft); color: var(--primary); }
/* ── Onglet Modules ── */
.mod-ic { width: 48px; height: 48px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; font-size: 24px; flex: none; }
.mod-ic.on { background: var(--primary-soft); }
.mod-group { border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px 18px; margin: 0; }
.mod-group legend { padding: 0 6px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.mod-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 24px; }
.mod-stack { display: flex; flex-direction: column; gap: 16px; }
.mod-save { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 0; border-top: 1px solid transparent; }
.mod-save.dirty { border-top-color: var(--border); }
.switch { position: relative; display: inline-block; width: 52px; height: 30px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span[aria-hidden] { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch span[aria-hidden]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgb(0 0 0 / .25); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + span { opacity: .5; }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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-CCcRvX8Z.js"></script> <script type="module" crossorigin src="/assets/espace/index-Cx3ijWuE.js"></script>
<link rel="stylesheet" crossorigin href="/assets/espace/index-MkZ3X9Gx.css"> <link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.css">
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View file

@ -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-CCcRvX8Z.js"></script> <script type="module" crossorigin src="/assets/espace/index-Cx3ijWuE.js"></script>
<link rel="stylesheet" crossorigin href="/assets/espace/index-MkZ3X9Gx.css"> <link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.css">
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View file

@ -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-CCcRvX8Z.js"></script> <script type="module" crossorigin src="/assets/espace/index-Cx3ijWuE.js"></script>
<link rel="stylesheet" crossorigin href="/assets/espace/index-MkZ3X9Gx.css"> <link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.css">
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>