Admin : onglet Facturation retravaillé
Chiffres clés (formule, montant, prochain prélèvement ou fin, total facturé et impayés), lien de paiement permanent à copier, titre de section pour les factures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6968d26ce6
commit
7a926f051e
5 changed files with 55 additions and 24 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { api, BillingInterval, downloadFile, Plan, SubscriptionStatus } from '../api';
|
||||
import { api, BillingInterval, downloadFile, Plan, PLAN_LABEL, SubscriptionStatus } from '../api';
|
||||
|
||||
interface CatalogEntry {
|
||||
plan: Plan;
|
||||
|
|
@ -79,11 +79,34 @@ export function BillingTab({ storeId, contactEmail, onChange }: { storeId: strin
|
|||
const chosenPlan = plan ?? sub?.plan ?? 'PRO';
|
||||
const chosenInterval = interval ?? sub?.interval ?? 'MONTH';
|
||||
|
||||
const paidTotal = data.invoices.filter((i) => i.paidAt).reduce((n, i) => n + i.amountCents, 0);
|
||||
const unpaid = data.invoices.filter((i) => !i.paidAt).length;
|
||||
|
||||
return (
|
||||
<>
|
||||
{data.testMode && <div className="alert warn">Stripe est en mode test : aucun paiement réel n'est encaissé (carte de test 4242 4242 4242 4242).</div>}
|
||||
{error && <div className="alert error" role="alert">{error}</div>}
|
||||
|
||||
{/* Chiffres clés de l'abonnement */}
|
||||
<div className="kpis">
|
||||
<div className={`kpi${current ? ' ok' : ''}`}>
|
||||
<b>{current ? current.name : '—'}</b>
|
||||
<span>{current ? `formule ${sub!.interval === 'YEAR' ? 'annuelle' : 'mensuelle'}` : sub?.status === 'INCOMPLETE' ? `en attente · ${PLAN_LABEL[sub.plan]} choisie` : 'aucune formule'}</span>
|
||||
</div>
|
||||
<div className="kpi">
|
||||
<b>{current ? euros(current.priceCents[sub!.interval]) : '—'}</b>
|
||||
<span>{current ? `par ${sub!.interval === 'YEAR' ? 'an' : 'mois'}` : 'montant'}</span>
|
||||
</div>
|
||||
<div className={`kpi${sub?.cancelAtPeriodEnd ? ' warn' : ''}`}>
|
||||
<b style={{ fontSize: 20, lineHeight: '34px' }}>{sub?.currentPeriodEnd && sub.status === 'ACTIVE' ? day(sub.currentPeriodEnd) : '—'}</b>
|
||||
<span>{sub?.cancelAtPeriodEnd ? 'fin de l’abonnement' : 'prochain prélèvement'}</span>
|
||||
</div>
|
||||
<div className={`kpi${unpaid ? ' err' : ''}`}>
|
||||
<b>{euros(paidTotal)}</b>
|
||||
<span>{data.invoices.length} facture{data.invoices.length > 1 ? 's' : ''}{unpaid ? ` · ${unpaid} impayée${unpaid > 1 ? 's' : ''}` : ' · tout est réglé'}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section className="card" style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
<div className="row between">
|
||||
<div>
|
||||
|
|
@ -153,9 +176,13 @@ export function BillingTab({ storeId, contactEmail, onChange }: { storeId: strin
|
|||
</label>
|
||||
))}
|
||||
</div>
|
||||
<div className="copy-line" style={{ flexWrap: 'wrap' }}>
|
||||
<span className="muted">Lien de paiement permanent :</span>
|
||||
<code>{data.subscribeUrl}</code>
|
||||
<button type="button" className="btn secondary small" onClick={() => navigator.clipboard?.writeText(data.subscribeUrl)}>Copier</button>
|
||||
</div>
|
||||
<p className="muted" style={{ margin: 0, fontSize: 14 }}>
|
||||
Lien permanent (il ne périme pas) : <a href={data.subscribeUrl} target="_blank" rel="noreferrer" style={{ wordBreak: 'break-all' }}>{data.subscribeUrl}</a>.
|
||||
Le commerçant pourra saisir un code promo sur la page de paiement (codes à créer dans Stripe → Coupons).
|
||||
Il ne périme pas. Le commerçant peut saisir un code promo sur la page de paiement (codes à créer dans Stripe → Coupons).
|
||||
</p>
|
||||
<div className="row" style={{ gap: 8 }}>
|
||||
<button className="btn" disabled={busy} onClick={() => run("Lien d'abonnement", `/api/admin/stores/${storeId}/billing/checkout-link`, { plan: chosenPlan, interval: chosenInterval, sendEmail: true })}>
|
||||
|
|
@ -175,6 +202,10 @@ export function BillingTab({ storeId, contactEmail, onChange }: { storeId: strin
|
|||
</div>
|
||||
)}
|
||||
|
||||
<div className="row between" style={{ marginTop: 8 }}>
|
||||
<h2>Factures</h2>
|
||||
<span className="muted" style={{ fontSize: 14 }}>Émises et envoyées automatiquement à chaque paiement.</span>
|
||||
</div>
|
||||
<div className="table-wrap">
|
||||
<div className="table-scroll">
|
||||
<table style={{ minWidth: 720 }}>
|
||||
|
|
|
|||
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-Cx3ijWuE.js"></script>
|
||||
<script type="module" crossorigin src="/assets/espace/index-Ck55rr7u.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.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-Cx3ijWuE.js"></script>
|
||||
<script type="module" crossorigin src="/assets/espace/index-Ck55rr7u.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.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-Cx3ijWuE.js"></script>
|
||||
<script type="module" crossorigin src="/assets/espace/index-Ck55rr7u.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/espace/index-DVd76xPZ.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue