- Admin : /inscription (formule, magasin, mot de passe, paiement Stripe) et /espace (connexion Dirigeant, état de l'abonnement, conception de la carte) - Admin : formule obligatoire à la création d'un magasin, plus d'essai gratuit, lien d'abonnement permanent, titre des campagnes - App Pro : écran Employés (création avec rôle Employé / Dirigeant), Mon compte (mot de passe), titre des campagnes, remise des cadeaux en caisse, accueil avant la conception de la carte - Site : boutons « Choisir » vers l'inscription, avec la périodicité choisie Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
3.7 KiB
TypeScript
80 lines
3.7 KiB
TypeScript
import { useState } from 'react';
|
|
import { Link, useNavigate } from 'react-router-dom';
|
|
import { api, BillingInterval, Plan, PLAN_LABEL, 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 } };
|
|
|
|
export function NewStorePage() {
|
|
const navigate = useNavigate();
|
|
const [plan, setPlan] = useState<Plan>('PRO');
|
|
const [interval, setInterval] = useState<BillingInterval>('MONTH');
|
|
const [created, setCreated] = useState<Created | null>(null);
|
|
|
|
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 }}>
|
|
{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.
|
|
</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 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' }}>
|
|
<button className="btn" onClick={() => navigate(`/magasins/${created.id}/carte`)}>Concevoir la carte</button>
|
|
</div>
|
|
</section>
|
|
</>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<div>
|
|
<Link to="/magasins">← Magasins</Link>
|
|
<h1>Nouveau magasin</h1>
|
|
<p className="muted" style={{ margin: 0 }}>
|
|
À la création, le contact reçoit automatiquement par e-mail le lien de paiement de la formule choisie et ses identifiants Dirigeant.
|
|
</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>
|
|
<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>
|
|
<StoreForm
|
|
initial={EMPTY_STORE}
|
|
submitLabel="Créer le magasin"
|
|
onSubmit={async (v) => {
|
|
setCreated(await api.post<Created>('/api/admin/stores', { ...v, plan, interval }));
|
|
}}
|
|
/>
|
|
</>
|
|
);
|
|
}
|