Compare commits

..

No commits in common. "6968d26ce6b86ac5d4a7ae899fe9e6f11312c147" and "55a0e62a3a185a86f5a1f584229bc4a7fae65e3c" have entirely different histories.

9 changed files with 138 additions and 225 deletions

View file

@ -23,10 +23,6 @@ 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] =
@ -135,33 +131,15 @@ 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', display: 'flex', gap: 14 }}> <div style={{ flex: '1 1 320px' }}>
<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}`}
@ -190,33 +168,25 @@ 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>}
{m.stats && ( <label style={{ display: 'flex', alignItems: 'center', gap: 10, fontWeight: 700 }}>
<div className="kpis"> <input type="checkbox" checked={!!values.enabled} onChange={(e) => setValues({ ...values, enabled: e.target.checked })} />
{Object.entries(m.stats).map(([k, v]) => ( Module activé
<div key={k} className="kpi"><b>{v ?? '—'}</b><span>{k}</span></div> </label>
))} {m.fields.map((f) => (
</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 })} /> <Field key={f.key} f={f} value={values[f.key]} onChange={(v) => setValues({ ...values, [f.key]: v })} />
))} ))}
{m.stats && (
<div className="row" style={{ gap: 24 }}>
{Object.entries(m.stats).map(([k, v]) => (
<div key={k}>
<div style={{ fontSize: 22, fontWeight: 800 }}>{v ?? '—'}</div>
<div className="muted" style={{ fontSize: 14 }}>{k}</div>
</div>
))}
</div> </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 mod-save${dirty ? ' dirty' : ''}`} style={{ gap: 8, justifyContent: 'flex-end' }}> <div className="row" 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'}
@ -240,18 +210,11 @@ 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 }}>
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, {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,
« Personnaliser » ouvre tous ses textes et réglages. Le dirigeant peut aussi les régler depuis l’app MonEspacePro. et tous ses textes et réglages sont personnalisables. Le dirigeant peut aussi les régler depuis l'app Pro.
</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

@ -40,70 +40,48 @@ export function StaffTab({ storeId }: { storeId: string }) {
} }
} }
async function switchRole(u: StaffUser) {
const next: StaffRole = u.role === 'MANAGER' ? 'EMPLOYEE' : 'MANAGER';
if (!window.confirm(`${u.displayName} devient ${ROLE_LABEL[next]}. Ses sessions ouvertes seront fermées.`)) return;
try {
await api.patch(`${base}/${u.id}`, { role: next });
reload();
} catch (e) {
setError((e as Error).message);
}
}
const active = staff.filter((u) => u.active);
const managers = active.filter((u) => u.role === 'MANAGER').length;
// Actifs d'abord, Dirigeants en tête.
const sorted = [...staff].sort((a, b) => Number(b.active) - Number(a.active) || a.role.localeCompare(b.role) || a.displayName.localeCompare(b.displayName));
return ( return (
<> <>
<div className="row between"> <div className="row between">
<div>
<h2>Employés</h2> <h2>Employés</h2>
<p className="muted" style={{ margin: 0 }}>
{active.length} compte{active.length > 1 ? 's' : ''} actif{active.length > 1 ? 's' : ''} · {managers} dirigeant{managers > 1 ? 's' : ''}
</p>
</div>
<button className="btn" onClick={() => formDialog.current?.showModal()}>+ Nouvel employé</button> <button className="btn" onClick={() => formDialog.current?.showModal()}>+ Nouvel employé</button>
</div> </div>
{error && <div className="alert error" role="alert">{error}</div>} {error && <div className="alert error" role="alert">{error}</div>}
{staff.length > 0 && managers === 0 && (
<div className="alert warn">Aucun Dirigeant actif : personne ne peut configurer le magasin depuis l’app. Créez un compte Dirigeant ou changez le rôle d’un employé.</div>
)}
{staff.length === 0 ? ( <div className="table-wrap">
<section className="card" style={{ textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 12, padding: 40 }}> <div className="table-scroll">
<span className="staff-avatar big" aria-hidden="true">👥</span> <table style={{ minWidth: 720 }}>
<h3 style={{ margin: 0 }}>Aucun compte pour l’instant</h3> <thead>
<p className="muted" style={{ margin: 0, maxWidth: 420 }}>Créez au moins un Dirigeant : il pourra ensuite ajouter lui-même son équipe depuis l’app MonEspacePro.</p> <tr>
<button className="btn" onClick={() => formDialog.current?.showModal()}>Créer le premier compte</button> <th scope="col" style={{ paddingLeft: 24 }}>Nom</th>
</section> <th scope="col">E-mail</th>
) : ( <th scope="col">Rôle</th>
<div className="staff-grid"> <th scope="col">Statut</th>
{sorted.map((u) => ( <th scope="col"><span className="sr-only">Actions</span></th>
<article key={u.id} className={`card staff-card${u.active ? '' : ' off'}`}> </tr>
<div className="row" style={{ gap: 12, flexWrap: 'nowrap' }}> </thead>
<span className={`staff-avatar${u.role === 'MANAGER' ? ' mgr' : ''}`} aria-hidden="true">{u.displayName.charAt(0).toUpperCase()}</span> <tbody>
<div style={{ minWidth: 0 }}> {staff.map((u) => (
<strong style={{ display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{u.displayName}</strong> <tr key={u.id} style={{ opacity: u.active ? 1 : 0.6 }}>
<span className="muted" style={{ fontSize: 14, display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{u.email}</span> <td style={{ paddingLeft: 24, fontWeight: 600 }}>{u.displayName}</td>
</div> <td>{u.email}</td>
</div> <td>{ROLE_LABEL[u.role]}</td>
<div className="row" style={{ gap: 6 }}> <td>{u.active ? <span className="badge ACTIVE">Actif</span> : <span className="badge DRAFT">Désactivé</span>}</td>
<span className={`role-pill${u.role === 'MANAGER' ? ' mgr' : ''}`}>{ROLE_LABEL[u.role]}</span> <td style={{ textAlign: 'right', whiteSpace: 'nowrap' }}>
{u.active ? <span className="badge ACTIVE">Actif</span> : <span className="badge DRAFT">Désactivé</span>} <button className="btn secondary small" onClick={() => reset(u)}>Nouveau mot de passe</button>{' '}
<span className="muted" style={{ fontSize: 13 }}>depuis le {new Date(u.createdAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short', year: 'numeric' })}</span>
</div>
<div className="row" style={{ gap: 8 }}>
<button className="btn secondary small" onClick={() => switchRole(u)}>{u.role === 'MANAGER' ? 'Passer Employé' : 'Passer Dirigeant'}</button>
<button className="btn secondary small" onClick={() => reset(u)}>Nouveau mot de passe</button>
<button className="btn secondary small" onClick={() => toggle(u)}>{u.active ? 'Désactiver' : 'Réactiver'}</button> <button className="btn secondary small" onClick={() => toggle(u)}>{u.active ? 'Désactiver' : 'Réactiver'}</button>
</div> </td>
</article> </tr>
))} ))}
</tbody>
</table>
</div> </div>
{staff.length === 0 && (
<p className="muted" style={{ padding: 24, margin: 0, textAlign: 'center' }}>
Aucun employé. Créez au moins un dirigeant pour que le magasin puisse utiliser l'app Pro.
</p>
)} )}
</div>
<dialog ref={formDialog} aria-labelledby="new-staff-title"> <dialog ref={formDialog} aria-labelledby="new-staff-title">
<NewStaffForm <NewStaffForm

View file

@ -252,31 +252,3 @@ tr.clickable:hover td { background: var(--primary-soft); }
.open-steps li.done { background: var(--ok-bg); color: var(--ok); } .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 { 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; } .copy-line code { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; word-break: break-all; }
/* ── Onglet Employés ── */
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.staff-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.staff-card.off { opacity: .6; }
.staff-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); font-weight: 800; font-size: 18px; display: grid; place-items: center; flex: none; }
.staff-avatar.mgr { background: var(--primary-soft); color: var(--primary); }
.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.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

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