Admin : page Nouveau magasin retravaillée
Formules en cartes avec prix (catalogue de l'API) et sélecteur mensuel / annuel, étapes numérotées, bouton explicite ; après création, récapitulatif de ce qui est parti automatiquement (magasin, compte Dirigeant, lien de paiement) et identifiants à copier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
ec992beb2d
commit
50eeba1a60
5 changed files with 112 additions and 48 deletions
|
|
@ -1,43 +1,88 @@
|
|||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { api, BillingInterval, Plan, PLAN_LABEL, Store, StaffUser } from '../api';
|
||||
import { api, BillingInterval, Plan, PLAN_LABEL, publicApi, Store, StaffUser } from '../api';
|
||||
import { EMPTY_STORE, StoreForm } from '../components/StoreForm';
|
||||
|
||||
type Created = Store & { manager: StaffUser | null; link: { url: string | null; emailedTo: string | null; error?: string } };
|
||||
interface PlanInfo {
|
||||
plan: Plan;
|
||||
name: string;
|
||||
tagline: string;
|
||||
priceCents: Record<BillingInterval, number>;
|
||||
}
|
||||
|
||||
const PLANS: Plan[] = ['ESSENTIEL', 'PRO', 'RESEAU'];
|
||||
const euros = (c: number) => (c / 100).toLocaleString('fr-FR', { style: 'currency', currency: 'EUR', minimumFractionDigits: c % 100 ? 2 : 0 });
|
||||
|
||||
export function NewStorePage() {
|
||||
const navigate = useNavigate();
|
||||
const [plan, setPlan] = useState<Plan>('PRO');
|
||||
const [interval, setInterval] = useState<BillingInterval>('MONTH');
|
||||
const [catalog, setCatalog] = useState<PlanInfo[]>([]);
|
||||
const [created, setCreated] = useState<Created | null>(null);
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
publicApi.get<PlanInfo[]>('/api/public/signup/plans').then(setCatalog).catch(() => undefined);
|
||||
}, []);
|
||||
|
||||
// ── Magasin créé : récapitulatif de ce qui est parti automatiquement ──
|
||||
if (created) {
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<Link to="/magasins">← Magasins</Link>
|
||||
<h1>{created.name} est créé</h1>
|
||||
</div>
|
||||
<section className="card" style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
||||
<Link to="/magasins">← Magasins</Link>
|
||||
<section className="card" style={{ display: 'flex', flexDirection: 'column', gap: 18, maxWidth: 760 }}>
|
||||
<div className="row" style={{ gap: 14, flexWrap: 'nowrap' }}>
|
||||
<span className="store-avatar" aria-hidden="true" style={{ background: 'var(--ok-bg)', color: 'var(--ok)' }}>✓</span>
|
||||
<div>
|
||||
<h1 style={{ fontSize: 28, lineHeight: '34px' }}>{created.name} est créé</h1>
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
Formule {PLAN_LABEL[plan]}, {interval === 'YEAR' ? 'annuelle' : 'mensuelle'} · {created.city}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul className="open-steps" aria-label="Ce qui a été fait">
|
||||
<li className="done">✓ Magasin créé</li>
|
||||
<li className={created.manager ? 'done' : ''}>{created.manager ? '✓' : '○'} Compte Dirigeant</li>
|
||||
<li className={created.link.emailedTo ? 'done' : ''}>{created.link.emailedTo ? '✓' : '○'} Lien de paiement envoyé</li>
|
||||
</ul>
|
||||
|
||||
{created.link.emailedTo ? (
|
||||
<div className="alert ok">
|
||||
Lien de paiement (formule {PLAN_LABEL[plan]}, {interval === 'YEAR' ? 'annuelle' : 'mensuelle'}) envoyé à <strong>{created.link.emailedTo}</strong>
|
||||
{created.manager && ', avec ses identifiants Dirigeant'}. Le magasin s'ouvrira automatiquement dès le paiement validé et la carte conçue.
|
||||
Lien de paiement envoyé à <strong>{created.link.emailedTo}</strong>
|
||||
{created.manager && ', avec ses identifiants Dirigeant'}. Le magasin s’ouvrira automatiquement dès le paiement validé et la carte conçue.
|
||||
</div>
|
||||
) : (
|
||||
<div className="alert warn">Le lien de paiement n'a pas pu être envoyé : {created.link.error}. Renvoyez-le depuis l'onglet Facturation.</div>
|
||||
<div className="alert warn">Le lien de paiement n’a pas pu être envoyé : {created.link.error}. Renvoyez-le depuis l’onglet Facturation.</div>
|
||||
)}
|
||||
|
||||
{created.manager ? (
|
||||
<>
|
||||
<p style={{ margin: 0 }}>
|
||||
Compte Dirigeant : <strong>{created.manager.email}</strong>, mot de passe provisoire :
|
||||
</p>
|
||||
<div className="password-box">{created.manager.provisionalPassword}</div>
|
||||
</>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
<strong>Identifiants du Dirigeant</strong>
|
||||
<div className="copy-line" style={{ flexWrap: 'wrap' }}>
|
||||
<span className="muted">E-mail :</span>
|
||||
<code>{created.manager.email}</code>
|
||||
</div>
|
||||
<div className="copy-line" style={{ flexWrap: 'wrap' }}>
|
||||
<span className="muted">Mot de passe provisoire :</span>
|
||||
<code style={{ fontSize: 18, fontWeight: 800, letterSpacing: 1 }}>{created.manager.provisionalPassword}</code>
|
||||
<button
|
||||
type="button"
|
||||
className="btn secondary small"
|
||||
onClick={() => navigator.clipboard?.writeText(created.manager!.provisionalPassword ?? '').then(() => setCopied(true))}
|
||||
>
|
||||
{copied ? 'Copié ✓' : 'Copier'}
|
||||
</button>
|
||||
</div>
|
||||
<span className="muted" style={{ fontSize: 14 }}>Il ne sera plus affiché ensuite. Il a aussi été envoyé par e-mail avec le lien de paiement.</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="alert warn">Un compte existe déjà avec l'e-mail du contact : créez le Dirigeant à la main dans l'onglet Employés.</div>
|
||||
<div className="alert warn">Un compte existe déjà avec l’e-mail du contact : créez le Dirigeant à la main dans l’onglet Employés.</div>
|
||||
)}
|
||||
<div className="row" style={{ justifyContent: 'flex-end' }}>
|
||||
|
||||
<div className="row" style={{ gap: 8, justifyContent: 'flex-end' }}>
|
||||
<button className="btn secondary" onClick={() => navigate(`/magasins/${created.id}`)}>Ouvrir la fiche</button>
|
||||
<button className="btn" onClick={() => navigate(`/magasins/${created.id}/carte`)}>Concevoir la carte</button>
|
||||
</div>
|
||||
</section>
|
||||
|
|
@ -45,34 +90,53 @@ export function NewStorePage() {
|
|||
);
|
||||
}
|
||||
|
||||
const shown = catalog.length ? catalog : PLANS.map((p) => ({ plan: p, name: PLAN_LABEL[p], tagline: '', priceCents: { MONTH: 0, YEAR: 0 } }));
|
||||
|
||||
// ── Formulaire de création ──
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<Link to="/magasins">← Magasins</Link>
|
||||
<h1>Nouveau magasin</h1>
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
<p className="muted" style={{ margin: 0, maxWidth: 720 }}>
|
||||
À la création, le contact reçoit automatiquement par e-mail le lien de paiement de la formule choisie et ses identifiants Dirigeant.
|
||||
Les commerçants peuvent aussi s’inscrire seuls depuis la page Tarif du site.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<section className="card" style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
<h2>Formule *</h2>
|
||||
<div role="radiogroup" aria-label="Formule" className="row" style={{ gap: 8 }}>
|
||||
{(['ESSENTIEL', 'PRO', 'RESEAU'] as const).map((p) => (
|
||||
<button key={p} type="button" className="chip" role="radio" aria-checked={plan === p} aria-pressed={plan === p} onClick={() => setPlan(p)}>
|
||||
{PLAN_LABEL[p]}
|
||||
</button>
|
||||
<div className="row between">
|
||||
<div className="s-title"><span className="s-num">1</span><h2 style={{ margin: 0 }}>Formule</h2></div>
|
||||
<div role="group" aria-label="Périodicité" className="s-seg">
|
||||
<button type="button" aria-pressed={interval === 'MONTH'} onClick={() => setInterval('MONTH')}>Mensuel</button>
|
||||
<button type="button" aria-pressed={interval === 'YEAR'} onClick={() => setInterval('YEAR')}>Annuel · 2 mois offerts</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="s-plans" role="radiogroup" aria-label="Formule">
|
||||
{shown.map((c) => (
|
||||
<label key={c.plan} className={`s-plan${plan === c.plan ? ' on' : ''}`}>
|
||||
<input type="radio" name="plan" className="sr-only" checked={plan === c.plan} onChange={() => setPlan(c.plan)} />
|
||||
{c.plan === 'PRO' && <span className="s-tag">Conseillée</span>}
|
||||
<strong>{c.name}</strong>
|
||||
{c.priceCents[interval] > 0 && (
|
||||
<span className="s-price">
|
||||
{euros(c.priceCents[interval])}
|
||||
<small> / {interval === 'YEAR' ? 'an' : 'mois'}</small>
|
||||
</span>
|
||||
)}
|
||||
{c.tagline && <span className="muted" style={{ fontSize: 14 }}>{c.tagline}</span>}
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<div role="radiogroup" aria-label="Périodicité" className="row" style={{ gap: 8 }}>
|
||||
<button type="button" className="chip" role="radio" aria-checked={interval === 'MONTH'} aria-pressed={interval === 'MONTH'} onClick={() => setInterval('MONTH')}>Mensuel</button>
|
||||
<button type="button" className="chip" role="radio" aria-checked={interval === 'YEAR'} aria-pressed={interval === 'YEAR'} onClick={() => setInterval('YEAR')}>Annuel — 2 mois offerts</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="s-title"><span className="s-num">2</span><h2 style={{ margin: 0 }}>Le magasin</h2></div>
|
||||
<StoreForm
|
||||
initial={EMPTY_STORE}
|
||||
submitLabel="Créer le magasin"
|
||||
submitLabel={`Créer le magasin et envoyer le lien (${PLAN_LABEL[plan]})`}
|
||||
onSubmit={async (v) => {
|
||||
setCreated(await api.post<Created>('/api/admin/stores', { ...v, plan, interval }));
|
||||
window.scrollTo({ top: 0 });
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -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-X3_Razph.js"></script>
|
||||
<script type="module" crossorigin src="/assets/espace/index-H4FokPx0.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-Y3IqSL08.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -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-X3_Razph.js"></script>
|
||||
<script type="module" crossorigin src="/assets/espace/index-H4FokPx0.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-Y3IqSL08.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -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-X3_Razph.js"></script>
|
||||
<script type="module" crossorigin src="/assets/espace/index-H4FokPx0.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-Y3IqSL08.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue