diff --git a/admin/src/components/Poster.tsx b/admin/src/components/Poster.tsx
index bdd400a..0e378ea 100644
--- a/admin/src/components/Poster.tsx
+++ b/admin/src/components/Poster.tsx
@@ -12,16 +12,24 @@ export interface PosterProps {
backgroundColor: string;
foregroundColor: string;
labelColor: string;
+ /** Récompenses actives, de la moins chère à la plus chère. */
+ rewards?: { label: string; cost: number; active?: boolean }[];
+ pointsMode?: 'AMOUNT' | 'STAMP';
}
/** Dimensions en mm (impression) et tailles de texte, d'après la maquette « Affichette comptoir ». */
const SIZES = {
- A5: { w: 148, h: 210, pad: 12, logo: 14, store: 6, eyebrow: 3.8, title: 10, qr: 66, body: 4.5, small: 4 },
- A6: { w: 105, h: 148, pad: 8, logo: 10, store: 4.5, eyebrow: 3, title: 7, qr: 46, body: 3.4, small: 3.1 },
+ A5: { w: 148, h: 210, pad: 12, logo: 14, store: 6, eyebrow: 3.8, title: 10, qr: 66, qrWithRewards: 50, body: 4.5, small: 4, maxRewards: 4 },
+ A6: { w: 105, h: 148, pad: 8, logo: 10, store: 4.5, eyebrow: 3, title: 7, qr: 46, qrWithRewards: 34, body: 3.4, small: 3.1, maxRewards: 3 },
};
export function Poster(p: PosterProps) {
const s = SIZES[p.format];
+ const rewards = (p.rewards ?? []).filter((r) => r.active !== false && r.label.trim()).sort((a, b) => a.cost - b.cost);
+ const shown = rewards.slice(0, s.maxRewards);
+ const unit = p.pointsMode === 'STAMP' ? 'tampons' : 'points';
+ // Le QR rétrécit pour laisser la place aux récompenses (reste au-dessus de 3 cm, lisible à bout de bras).
+ const qrSize = shown.length ? s.qrWithRewards : s.qr;
const [svg, setSvg] = useState('');
useEffect(() => {
@@ -64,9 +72,42 @@ export function Poster(p: PosterProps) {
+ {shown.length > 0 && (
+
+
+ Vos récompenses
+
+
+ {shown.map((r) => (
+ -
+ {r.label}
+
+ {r.cost} {unit}
+
+
+ ))}
+
+ {rewards.length > shown.length && (
+
et {rewards.length - shown.length} autre(s) à découvrir sur votre carte
+ )}
+
+ )}
Ajoutez-la à Apple Wallet ou Google Wallet.
Gratuit, sans application à télécharger.
diff --git a/admin/src/components/WalletPreview.tsx b/admin/src/components/WalletPreview.tsx
index 63d3924..1ced8cd 100644
--- a/admin/src/components/WalletPreview.tsx
+++ b/admin/src/components/WalletPreview.tsx
@@ -1,6 +1,6 @@
import { CardDesign } from '../api';
-export type PreviewDesign = Omit
& { storeName: string };
+export type PreviewDesign = Omit & { storeName: string; rewards?: CardDesign['rewards'] };
/** QR factice (motif fixe) : l'aperçu ne doit pas laisser croire à un vrai code. */
function FakeQr({ size }: { size: number }) {
@@ -34,6 +34,17 @@ function balanceLabel(d: PreviewDesign) {
return d.pointsMode === 'STAMP' ? { label: 'TAMPONS', value: '7' } : { label: 'POINTS', value: '120' };
}
+/** Même règle que l'API (wallet.types.ts) appliquée au solde fictif de l'aperçu. */
+function nextReward(d: PreviewDesign): string | null {
+ const balance = d.pointsMode === 'STAMP' ? 7 : 120;
+ const rewards = (d.rewards ?? []).filter((r) => r.active !== false && r.label.trim()).sort((a, b) => a.cost - b.cost);
+ if (!rewards.length) return null;
+ const reachable = rewards.filter((r) => r.cost <= balance);
+ if (reachable.length) return `${reachable[reachable.length - 1].label} : disponible !`;
+ const missing = rewards[0].cost - balance;
+ return `${rewards[0].label} : encore ${missing} ${d.pointsMode === 'STAMP' ? 'tampon' : 'point'}${missing > 1 ? 's' : ''}`;
+}
+
/** Approximation fidèle du gabarit Apple « Store Card » (logo, bandeau 1125×432, champ principal, QR). */
export function ApplePreview({ d }: { d: PreviewDesign }) {
const b = balanceLabel(d);
@@ -66,6 +77,12 @@ export function ApplePreview({ d }: { d: PreviewDesign }) {
Camille
+ {nextReward(d) && (
+
+
PROCHAINE RÉCOMPENSE
+
{nextReward(d)}
+
+ )}
@@ -97,6 +114,12 @@ export function GooglePreview({ d }: { d: PreviewDesign }) {
Camille
+ {nextReward(d) && (
+
+
Prochaine récompense
+
{nextReward(d)}
+
+ )}
diff --git a/admin/src/pages/CardWizard.tsx b/admin/src/pages/CardWizard.tsx
index a6e373d..7a444e5 100644
--- a/admin/src/pages/CardWizard.tsx
+++ b/admin/src/pages/CardWizard.tsx
@@ -246,6 +246,8 @@ export function CardWizard({ store, onSaved }: { store: StoreDetail; onSaved: ()
backgroundColor={draft.backgroundColor}
foregroundColor={draft.foregroundColor}
labelColor={draft.labelColor}
+ rewards={draft.rewards}
+ pointsMode={draft.pointsMode}
/>
diff --git a/admin/src/pages/PosterPage.tsx b/admin/src/pages/PosterPage.tsx
index 268b8c2..8a4923c 100644
--- a/admin/src/pages/PosterPage.tsx
+++ b/admin/src/pages/PosterPage.tsx
@@ -52,6 +52,8 @@ export function PosterPage() {
backgroundColor={design.backgroundColor}
foregroundColor={design.foregroundColor}
labelColor={design.labelColor}
+ rewards={design.rewards}
+ pointsMode={design.pointsMode}
/>
{store.enrollUrl}
diff --git a/backend/src/enrollment/pages.ts b/backend/src/enrollment/pages.ts
index 98a1eac..07ab18e 100644
--- a/backend/src/enrollment/pages.ts
+++ b/backend/src/enrollment/pages.ts
@@ -1,5 +1,5 @@
import type { CardDesign, Reward, Store } from '@prisma/client';
-import type { CardWithContext } from '../wallet/wallet.types';
+import { nextRewardText, type CardWithContext } from '../wallet/wallet.types';
/** Pages publiques (clients finaux), rendues côté serveur aux couleurs du magasin. */
@@ -102,6 +102,15 @@ input:focus{outline:2px solid var(--brand);outline-offset:1px}
.pass .row{display:flex;justify-content:space-between;padding:10px 14px 14px}
.pass .qr{background:#fff;margin:0 auto 18px;width:200px;padding:12px;border-radius:12px}
.pass .qr svg{display:block;width:100%;height:auto}
+.rws{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:10px}
+.rw{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:12px 14px;display:flex;flex-direction:column;gap:6px}
+.rw.ok{border-color:var(--brand);border-width:2px}
+.rw-h{display:flex;justify-content:space-between;gap:12px;align-items:baseline}
+.rw-h span{font-size:14px;color:var(--muted);white-space:nowrap}
+.rw.ok .rw-h span{color:var(--ok);font-weight:700}
+.rw-bar{height:8px;border-radius:999px;background:var(--border);overflow:hidden}
+.rw-bar i{display:block;height:100%;background:var(--brand);border-radius:999px}
+.rw small{font-size:13px;color:var(--muted)}
footer{padding:20px;display:flex;flex-direction:column;align-items:center;gap:10px;font-size:13px;color:var(--muted)}
footer nav{display:flex;gap:16px}
footer .powered{display:inline-flex;align-items:center;gap:6px;font-size:12px;text-decoration:none}
@@ -136,10 +145,12 @@ function promises(store: StoreWithDesign) {
? 'Gagnez 1 point par euro dépensé'
: `Gagnez ${Number(d.pointsPerEuro).toLocaleString('fr-FR')} points par euro dépensé`;
const unit = d.pointsMode === 'STAMP' ? 'tampons' : 'points';
- const reward = d.rewards[0];
+ const shown = d.rewards.slice(0, 4);
+ const more = d.rewards.length - shown.length;
return `
${e(rule)}
-${reward ? `
${e(reward.label)} à ${reward.cost} ${unit}
` : ''}
+${shown.map((r) => `
${e(r.label)} à ${r.cost} ${unit}
`).join('\n')}
+${more > 0 ? `
et ${more} autre${more > 1 ? 's' : ''} récompense${more > 1 ? 's' : ''} à découvrir
` : ''}
`;
}
@@ -228,6 +239,27 @@ export function unavailablePage(store: StoreWithDesign) {
);
}
+/** Liste des récompenses avec la progression du client (barre + « encore N »). */
+function rewardsList(rewards: Reward[], balance: number, stamp: boolean) {
+ if (!rewards.length) return '';
+ const unit = (n: number) => (stamp ? (n > 1 ? 'tampons' : 'tampon') : n > 1 ? 'points' : 'point');
+ const items = rewards
+ .map((r) => {
+ const ok = balance >= r.cost;
+ const pct = Math.min(100, Math.round((balance / r.cost) * 100));
+ return `
+${e(r.label)}${ok ? 'Disponible' : `encore ${r.cost - balance} ${unit(r.cost - balance)}`}
+
+${r.cost} ${unit(r.cost)}
+`;
+ })
+ .join('');
+ return ``;
+}
+
export function cardPage(
card: CardWithContext,
opts: { platform: Platform; isNew: boolean; apple: boolean; google: boolean; qrSvg: string },
@@ -261,10 +293,11 @@ export function cardPage(
${t.logo ? `
})
` : ''}
${e(d.programName)}
${t.strip ? `
})
` : ''}
-
Membre
${e(card.customer.firstName)}
Récompense
${e(d.rewards[0]?.label ?? '—')}
+
Membre
${e(card.customer.firstName)}
Prochaine récompense
${e(nextRewardText(card) ?? '—')}
${opts.qrSvg}
Présentez ce QR code au comptoir à chaque passage.
+${rewardsList(d.rewards, card.balance, d.pointsMode === 'STAMP')}
${buttons}
${
diff --git a/backend/src/wallet/apple-pass.service.ts b/backend/src/wallet/apple-pass.service.ts
index 97994b5..63f0ed6 100644
--- a/backend/src/wallet/apple-pass.service.ts
+++ b/backend/src/wallet/apple-pass.service.ts
@@ -5,7 +5,7 @@ import { join } from 'path';
import { Jimp } from 'jimp';
import { PKPass } from 'passkit-generator';
import { UPLOADS_DIR } from '../card-design/card-design.service';
-import { CardWithContext, rewardsText, unitLabel } from './wallet.types';
+import { CardWithContext, nextRewardText, rewardsText, unitLabel } from './wallet.types';
type Certificates = { wwdr: Buffer; signerCert: Buffer; signerKey: Buffer; signerKeyPassphrase?: string };
@@ -38,6 +38,7 @@ export class ApplePassService {
if (!design) throw new ServiceUnavailableException('Carte non conçue');
const unit = unitLabel(card);
+ const nextReward = nextRewardText(card);
const passJson = {
formatVersion: 1,
passTypeIdentifier: this.config.get('apple.passTypeId'),
@@ -58,6 +59,10 @@ export class ApplePassService {
{ key: 'program', label: 'PROGRAMME', value: design.programName },
{ key: 'member', label: 'MEMBRE', value: card.customer.firstName, textAlignment: 'PKTextAlignmentRight' },
],
+ // Face avant : la prochaine récompense ; la notification s'affiche quand elle devient disponible.
+ ...(nextReward && {
+ auxiliaryFields: [{ key: 'next-reward', label: 'PROCHAINE RÉCOMPENSE', value: nextReward, changeMessage: '%@' }],
+ }),
backFields: [
{ key: 'rewards', label: 'Récompenses', value: rewardsText(card) },
{
diff --git a/backend/src/wallet/google-wallet.service.ts b/backend/src/wallet/google-wallet.service.ts
index 7d28a1d..37226df 100644
--- a/backend/src/wallet/google-wallet.service.ts
+++ b/backend/src/wallet/google-wallet.service.ts
@@ -2,7 +2,7 @@ import { Injectable, Logger, ServiceUnavailableException } from '@nestjs/common'
import { ConfigService } from '@nestjs/config';
import { readFileSync } from 'fs';
import { importPKCS8, SignJWT } from 'jose';
-import { CardWithContext, rewardsText, unitLabel } from './wallet.types';
+import { CardWithContext, nextRewardText, rewardsText, unitLabel } from './wallet.types';
type ServiceAccount = { client_email: string; private_key: string };
@@ -71,7 +71,10 @@ export class GoogleWalletService {
accountName: card.customer.firstName,
loyaltyPoints: { label: unitLabel(card), balance: { int: card.balance } },
barcode: { type: 'QR_CODE', value: card.serial },
- textModulesData: [{ id: 'rewards', header: 'Récompenses', body: rewardsText(card) }],
+ textModulesData: [
+ ...(nextRewardText(card) ? [{ id: 'next_reward', header: 'Prochaine récompense', body: nextRewardText(card)! }] : []),
+ { id: 'rewards', header: 'Toutes les récompenses', body: rewardsText(card) },
+ ],
linksModuleData: {
uris: [{ id: 'manage', uri: `${webUrl}/carte/${card.serial}?k=${card.accessKey}`, description: 'Ma carte' }],
},
diff --git a/backend/src/wallet/wallet.types.ts b/backend/src/wallet/wallet.types.ts
index 08a1eff..e1b9514 100644
--- a/backend/src/wallet/wallet.types.ts
+++ b/backend/src/wallet/wallet.types.ts
@@ -14,6 +14,22 @@ export function unitLabel(card: CardWithContext, plural = true) {
return stamp ? 'Tampons' : 'Points';
}
+/**
+ * Prochaine récompense pour la face avant de la carte :
+ * « Café offert : encore 3 tampons », ou « Café offert : disponible ! »
+ * si le client peut déjà l'obtenir (la plus chère accessible).
+ */
+export function nextRewardText(card: CardWithContext): string | null {
+ const rewards = card.store.cardDesign?.rewards ?? [];
+ if (!rewards.length) return null;
+ const stamp = card.store.cardDesign?.pointsMode === 'STAMP';
+ const reachable = rewards.filter((r) => r.cost <= card.balance);
+ if (reachable.length) return `${reachable[reachable.length - 1].label} : disponible !`;
+ const next = rewards[0];
+ const missing = next.cost - card.balance;
+ return `${next.label} : encore ${missing} ${stamp ? (missing > 1 ? 'tampons' : 'tampon') : missing > 1 ? 'points' : 'point'}`;
+}
+
export function rewardsText(card: CardWithContext) {
const unit = card.store.cardDesign?.pointsMode === 'STAMP' ? 'tampons' : 'points';
const rewards = card.store.cardDesign?.rewards ?? [];