diff --git a/admin/src/api.ts b/admin/src/api.ts index 800f815..7c4cfa1 100644 --- a/admin/src/api.ts +++ b/admin/src/api.ts @@ -226,4 +226,6 @@ export interface StaffUser { active: boolean; createdAt: string; provisionalPassword?: string; + /** Adresse à laquelle le lien de création du mot de passe a été envoyé (null : échec de l’envoi). */ + invitationSentTo?: string | null; } diff --git a/admin/src/pages/StaffTab.tsx b/admin/src/pages/StaffTab.tsx index 7b435ca..9e09962 100644 --- a/admin/src/pages/StaffTab.tsx +++ b/admin/src/pages/StaffTab.tsx @@ -7,18 +7,19 @@ export function StaffTab({ storeId }: { storeId: string }) { const base = `/api/admin/stores/${storeId}/staff`; const [staff, setStaff] = useState([]); const [error, setError] = useState(null); - const [created, setCreated] = useState(null); + const [sent, setSent] = useState<{ name: string; email: string | null; reset: boolean } | null>(null); const formDialog = useRef(null); - const passwordDialog = useRef(null); + const sentDialog = useRef(null); const reload = useCallback(() => { api.get(base).then(setStaff).catch((e) => setError(e.message)); }, [base]); useEffect(reload, [reload]); - function showPassword(user: StaffUser) { - setCreated(user); - passwordDialog.current?.showModal(); + /** Invitation envoyée par e-mail (création ou nouveau mot de passe). */ + function showSent(name: string, email: string | null, reset: boolean) { + setSent({ name, email, reset }); + sentDialog.current?.showModal(); reload(); } @@ -32,9 +33,10 @@ export function StaffTab({ storeId }: { storeId: string }) { } async function reset(u: StaffUser) { - if (!window.confirm(`Générer un nouveau mot de passe pour ${u.displayName} ? Ses sessions seront fermées.`)) return; + if (!window.confirm(`Envoyer à ${u.displayName} (${u.email}) un lien pour choisir un nouveau mot de passe ?`)) return; try { - showPassword(await api.post(`${base}/${u.id}/reset-password`)); + const r = await api.post<{ invitationSentTo: string }>(`${base}/${u.id}/reset-password`); + showSent(u.displayName, r.invitationSentTo, true); } catch (e) { setError((e as Error).message); } @@ -97,7 +99,7 @@ export function StaffTab({ storeId }: { storeId: string }) {
- +
@@ -111,21 +113,25 @@ export function StaffTab({ storeId }: { storeId: string }) { onCancel={() => formDialog.current?.close()} onCreated={(u) => { formDialog.current?.close(); - showPassword(u); + showSent(u.displayName, u.invitationSentTo ?? null, false); }} /> - +
-

Mot de passe provisoire

-

- Communiquez-le à {created?.displayName} ({created?.email}). Il ne sera plus affiché ensuite. -

-
{created?.provisionalPassword}
+

{sent?.email ? (sent.reset ? 'Lien envoyé' : 'Compte créé') : 'Compte créé, e-mail non envoyé'}

+ {sent?.email ? ( +

+ {sent.name} a reçu à {sent.email} un lien pour choisir {sent.reset ? 'un nouveau' : 'son'} mot de passe (valable 7 jours, utilisable une fois). +

+ ) : ( +
+ L’e-mail d’invitation n’a pas pu partir. Utilisez « Envoyer un lien de mot de passe » sur la fiche de {sent?.name} pour réessayer. +
+ )}
- - +
@@ -185,7 +191,7 @@ function NewStaffForm({ base, onCancel, onCreated }: { base: string; onCancel: ( ))} -

Un mot de passe provisoire sera généré à la création.

+

La personne recevra un e-mail pour choisir son mot de passe.

diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 51a055c..74f9aad 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -204,6 +204,10 @@ model Transaction { rejectReason RejectReason? rewardId String? reward Reward? @relation(fields: [rewardId], references: [id]) + /// Annulation (opération ADJUST) : identifiant de l'opération annulée. Unique : une opération ne s'annule qu'une fois. + cancelOf String? @unique + cancelled Transaction? @relation("Cancellation", fields: [cancelOf], references: [id]) + cancelledBy Transaction? @relation("Cancellation") createdAt DateTime @default(now()) @@index([storeId, createdAt]) diff --git a/backend/src/counter/counter.controller.ts b/backend/src/counter/counter.controller.ts index 80b1417..8b01f78 100644 --- a/backend/src/counter/counter.controller.ts +++ b/backend/src/counter/counter.controller.ts @@ -81,6 +81,13 @@ export class CounterController { return this.counter.useGift(ctx(user), serial, giftId); } + /** Annulation d'un crédit ou d'une récompense (erreur de saisie). */ + @Post('transactions/:id/cancel') + @HttpCode(200) + cancel(@CurrentUser() user: JwtPayload, @Param('id') id: string) { + return this.counter.cancel(ctx(user), id); + } + @Get('transactions') history(@CurrentUser() user: JwtPayload, @Query() q: HistoryQuery) { return this.counter.history(ctx(user), q.period ?? 'today', q.cursor); diff --git a/backend/src/counter/counter.service.ts b/backend/src/counter/counter.service.ts index 141e50a..c7d9af0 100644 --- a/backend/src/counter/counter.service.ts +++ b/backend/src/counter/counter.service.ts @@ -1,4 +1,4 @@ -import { BadRequestException, ForbiddenException, HttpException, HttpStatus, Injectable, NotFoundException } from '@nestjs/common'; +import { BadRequestException, ConflictException, ForbiddenException, HttpException, HttpStatus, Injectable, NotFoundException } from '@nestjs/common'; import { Prisma, RejectReason, StaffRole } from '@prisma/client'; import { PrismaService } from '../prisma/prisma.service'; import { CardUpdatesService } from '../wallet/card-updates.service'; @@ -123,10 +123,10 @@ export class CounterService { }); if (updated.count === 0) return null; const { balance } = await tx.loyaltyCard.findUniqueOrThrow({ where: { id: card.id }, select: { balance: true } }); - await tx.transaction.create({ + const op = await tx.transaction.create({ data: { storeId: ctx.storeId, cardId: card.id, staffId: ctx.staffId, type: 'CREDIT', amountCents, points, balanceAfter: balance }, }); - return balance; + return { balance, transactionId: op.id }; }); if (result === null) { @@ -142,7 +142,7 @@ export class CounterService { this.cardUpdates.notify(card.id); // Premier passage d'un filleul : récompenses du parrainage (en arrière-plan). this.referrals.onCredit(card.id); - return { points, balance: result, firstName: card.customer.firstName }; + return { points, balance: result.balance, transactionId: result.transactionId, cancellableUntil: cancelDeadline(new Date()), firstName: card.customer.firstName }; } async redeem(ctx: StaffContext, serial: string, rewardId: string) { @@ -157,10 +157,10 @@ export class CounterService { }); if (updated.count === 0) return null; const { balance } = await tx.loyaltyCard.findUniqueOrThrow({ where: { id: card.id }, select: { balance: true } }); - await tx.transaction.create({ + const op = await tx.transaction.create({ data: { storeId: ctx.storeId, cardId: card.id, staffId: ctx.staffId, type: 'REDEEM', points: -reward.cost, rewardId: reward.id, balanceAfter: balance }, }); - return balance; + return { balance, transactionId: op.id }; }); if (balance === null) { await this.reject(ctx, card, 'INSUFFICIENT_BALANCE'); @@ -169,7 +169,7 @@ export class CounterService { }); } this.cardUpdates.notify(card.id); - return { reward: { id: reward.id, label: reward.label, cost: reward.cost }, balance, firstName: card.customer.firstName }; + return { reward: { id: reward.id, label: reward.label, cost: reward.cost }, balance: balance.balance, transactionId: balance.transactionId, cancellableUntil: cancelDeadline(new Date()), firstName: card.customer.firstName }; } /** Le dirigeant voit tout le magasin ; l'employé, seulement ses opérations. */ @@ -191,11 +191,18 @@ export class CounterService { reward: { select: { label: true } }, staff: { select: { id: true, displayName: true } }, card: { select: { customer: { select: { firstName: true } } } }, + cancelOf: true, + cancelledBy: { select: { createdAt: true, staff: { select: { displayName: true } } } }, }, }); const hasMore = items.length > 50; return { - items: items.slice(0, 50).map(({ card, ...t }) => ({ ...t, customerFirstName: card.customer.firstName })), + items: items.slice(0, 50).map(({ card, cancelledBy, ...t }) => ({ + ...t, + customerFirstName: card.customer.firstName, + cancelled: cancelledBy ? { at: cancelledBy.createdAt, by: cancelledBy.staff.displayName } : null, + cancellable: !cancelledBy && canCancel(ctx, t), + })), nextCursor: hasMore ? items[49].id : null, }; } @@ -203,8 +210,8 @@ export class CounterService { async summary(ctx: StaffContext) { const where = this.scope(ctx, 'today'); const [credits, redeems] = await Promise.all([ - this.prisma.transaction.aggregate({ where: { ...where, type: 'CREDIT' }, _count: true, _sum: { points: true } }), - this.prisma.transaction.count({ where: { ...where, type: 'REDEEM' } }), + this.prisma.transaction.aggregate({ where: { ...where, type: 'CREDIT', ...{ cancelledBy: { is: null } } }, _count: true, _sum: { points: true } }), + this.prisma.transaction.count({ where: { ...where, type: 'REDEEM', ...{ cancelledBy: { is: null } } } }), ]); return { operations: credits._count + redeems, pointsGiven: credits._sum.points ?? 0, rewards: redeems }; } @@ -244,6 +251,67 @@ export class CounterService { })); } + /** + * Annule un crédit ou une récompense (erreur de saisie au comptoir) : une opération ADJUST de sens inverse + * est ajoutée au journal, qui reste immuable. Possible pendant ${CANCEL_WINDOW_MIN} minutes, par l'auteur de + * l'opération ou un Dirigeant, une seule fois, et seulement si le client n'a pas déjà utilisé les points. + */ + async cancel(ctx: StaffContext, transactionId: string) { + const t = await this.prisma.transaction.findUnique({ + where: { id: transactionId }, + include: { cancelledBy: { select: { id: true } }, card: { select: { id: true, customer: { select: { firstName: true } } } } }, + }); + if (!t || t.storeId !== ctx.storeId) throw new NotFoundException('Opération introuvable'); + if (t.type !== 'CREDIT' && t.type !== 'REDEEM') throw new BadRequestException('Seuls un crédit ou une récompense peuvent être annulés.'); + if (t.cancelledBy) throw new ConflictException('Cette opération a déjà été annulée.'); + if (ctx.role !== 'MANAGER' && t.staffId !== ctx.staffId) throw new ForbiddenException('Seul l’auteur de l’opération ou un dirigeant peut l’annuler.'); + if (Date.now() > cancelDeadline(t.createdAt).getTime()) { + throw new BadRequestException(`Une opération ne peut être annulée que pendant ${CANCEL_WINDOW_MIN} minutes. Demandez à votre dirigeant.`); + } + + const delta = -t.points; + // Crédit annulé : si c'était le dernier crédit de la carte, le délai anti-triche repart du précédent, + // pour pouvoir ressaisir aussitôt le bon montant. + let lastCreditAt: Date | null | undefined; + if (t.type === 'CREDIT') { + const later = await this.prisma.transaction.count({ where: { cardId: t.cardId, type: 'CREDIT', createdAt: { gt: t.createdAt }, cancelledBy: { is: null } } }); + if (later === 0) { + const previous = await this.prisma.transaction.findFirst({ + where: { cardId: t.cardId, type: 'CREDIT', createdAt: { lt: t.createdAt }, cancelledBy: { is: null } }, + orderBy: { createdAt: 'desc' }, + select: { createdAt: true }, + }); + lastCreditAt = previous?.createdAt ?? null; + } + } + + let balance: number | null; + try { + balance = await this.prisma.$transaction(async (tx) => { + // Un crédit annulé retire des points : impossible si le client les a déjà dépensés. + const updated = await tx.loyaltyCard.updateMany({ + where: { id: t.cardId, ...(delta < 0 && { balance: { gte: -delta } }) }, + data: { balance: { increment: delta }, ...(lastCreditAt !== undefined && { lastCreditAt }) }, + }); + if (updated.count === 0) return null; + const { balance } = await tx.loyaltyCard.findUniqueOrThrow({ where: { id: t.cardId }, select: { balance: true } }); + await tx.transaction.create({ + data: { storeId: ctx.storeId, cardId: t.cardId, staffId: ctx.staffId, type: 'ADJUST', points: delta, rewardId: t.rewardId, balanceAfter: balance, cancelOf: t.id }, + }); + return balance; + }); + } catch (e) { + // Deux annulations simultanées : la contrainte d'unicité n'en laisse passer qu'une. + if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2002') throw new ConflictException('Cette opération a déjà été annulée.'); + throw e; + } + if (balance === null) { + throw new ConflictException('Le client a déjà utilisé ces points : l’opération ne peut plus être annulée.'); + } + this.cardUpdates.notify(t.cardId); + return { balance, firstName: t.card.customer.firstName }; + } + private async cardOfStore(ctx: StaffContext, serial: string) { const card = await this.prisma.loyaltyCard.findUnique({ where: { serial: serial.trim().toUpperCase() }, @@ -301,3 +369,17 @@ function maskEmail(email: string) { const [user, domain] = email.split('@'); return `${user.slice(0, 2)}•••@${domain ?? ''}`; } + +/** Délai pendant lequel une opération peut être annulée (erreur de saisie). */ +export const CANCEL_WINDOW_MIN = 30; + +function cancelDeadline(createdAt: Date) { + return new Date(createdAt.getTime() + CANCEL_WINDOW_MIN * 60_000); +} + +/** Droit d'annuler (affiché dans l'historique) : crédit ou récompense récent, par son auteur ou un Dirigeant. */ +function canCancel(ctx: StaffContext, t: { type: string; createdAt: Date; staff: { id: string } }) { + if (t.type !== 'CREDIT' && t.type !== 'REDEEM') return false; + if (ctx.role !== 'MANAGER' && t.staff.id !== ctx.staffId) return false; + return Date.now() <= cancelDeadline(t.createdAt).getTime(); +} diff --git a/backend/src/reviews/reviews.service.ts b/backend/src/reviews/reviews.service.ts index ac85c9a..6b83b65 100644 --- a/backend/src/reviews/reviews.service.ts +++ b/backend/src/reviews/reviews.service.ts @@ -112,7 +112,7 @@ export class ReviewsService implements OnModuleInit, OnApplicationBootstrap, OnA if (!recent.length) return 0; const visits = await this.prisma.transaction.groupBy({ by: ['cardId'], - where: { cardId: { in: recent.map((c) => c.id) }, type: 'CREDIT' }, + where: { cardId: { in: recent.map((c) => c.id) }, type: 'CREDIT', ...{ cancelledBy: { is: null } } }, _count: { _all: true }, }); let sent = 0; diff --git a/backend/src/staff/password-setup.controller.ts b/backend/src/staff/password-setup.controller.ts index 16863d8..7d39f0d 100644 --- a/backend/src/staff/password-setup.controller.ts +++ b/backend/src/staff/password-setup.controller.ts @@ -1,10 +1,16 @@ import { Body, Controller, Get, Header, HttpCode, Post, Query } from '@nestjs/common'; +import { IsEmail, MaxLength } from 'class-validator'; import { Throttle } from '@nestjs/throttler'; import { escapeHtml as e } from '../enrollment/pages'; import { PasswordSetupService, SetupOutcome } from './password-setup.service'; const MIN_LENGTH = 10; +class ForgotDto { + @IsEmail({}, { message: 'Adresse e-mail invalide' }) @MaxLength(200) + email!: string; +} + /** * Page publique du lien reçu par e-mail : https://monespacepro.eu/api/public/mot-de-passe?token=… * (le chemin /api/public est déjà transmis à l'API par nginx sur monespacepro.eu). @@ -22,6 +28,14 @@ export class PasswordSetupController { return outcome.ok ? formPage(token, outcome.staff) : problemPage(outcome.reason); } + /** « Mot de passe oublié » (app, écran de connexion) : envoie le lien si le compte existe. */ + @Post('oubli') + @HttpCode(200) + @Throttle({ default: { limit: 5, ttl: 15 * 60_000 } }) + forgot(@Body() dto: ForgotDto) { + return this.setup.requestReset(dto.email); + } + @Post() @HttpCode(200) @Throttle({ default: { limit: 10, ttl: 10 * 60_000 } }) diff --git a/backend/src/staff/password-setup.service.ts b/backend/src/staff/password-setup.service.ts index 4159b84..21d3265 100644 --- a/backend/src/staff/password-setup.service.ts +++ b/backend/src/staff/password-setup.service.ts @@ -46,7 +46,7 @@ export class PasswordSetupService { } /** Envoie le lien au titulaire du compte. `reason` : création du compte ou nouveau mot de passe. */ - async sendInvitation(staffId: string, invitedByName: string, reason: 'invite' | 'reset') { + async sendInvitation(staffId: string, invitedByName: string, reason: 'invite' | 'reset' | 'self') { const staff = await this.prisma.staffUser.findUniqueOrThrow({ where: { id: staffId }, include: { store: { select: { name: true } } } }); const payload: SetupPayload = { sub: staff.id, purpose: 'password-setup', v: staff.tokenVersion }; const token = await this.jwt.signAsync(payload, { secret: this.secret, expiresIn: LINK_TTL }); @@ -56,7 +56,9 @@ export class PasswordSetupService { const subject = invite ? `Votre accès à MonEspacePro — ${staff.store.name}` : `Nouveau mot de passe MonEspacePro — ${staff.store.name}`; const intro = invite ? `${invitedByName} vous a créé un compte ${role} pour « ${staff.store.name} » sur MonEspacePro, l’app qui sert à créditer les cartes de fidélité des clients au comptoir.` - : `${invitedByName} vous envoie un lien pour choisir un nouveau mot de passe pour votre compte ${role} de « ${staff.store.name} ».`; + : reason === 'self' + ? `Vous avez demandé à choisir un nouveau mot de passe pour votre compte ${role} de « ${staff.store.name} ». Votre mot de passe actuel reste valable tant que vous n’en avez pas choisi un nouveau.` + : `${invitedByName} vous envoie un lien pour choisir un nouveau mot de passe pour votre compte ${role} de « ${staff.store.name} ».`; await this.mail.send( staff.email, subject, @@ -80,6 +82,18 @@ export class PasswordSetupService { return { invitationSentTo: staff.email }; } + /** + * « Mot de passe oublié » depuis l'écran de connexion. Même réponse que le compte existe ou non + * (aucune information sur les comptes existants) ; rien n'est envoyé pour un compte désactivé ou supprimé. + */ + async requestReset(email: string) { + const staff = await this.prisma.staffUser.findUnique({ where: { email: email.trim().toLowerCase() }, select: { id: true, active: true, email: true } }); + if (staff && staff.active && !staff.email.endsWith(`@${DELETED_EMAIL_DOMAIN}`)) { + await this.sendInvitation(staff.id, 'MonEspacePro', 'self'); + } + return { ok: true }; + } + /** Vérifie un lien sans le consommer (affichage du formulaire). */ async check(token: string): Promise { let p: SetupPayload; diff --git a/backend/src/staff/staff.controller.ts b/backend/src/staff/staff.controller.ts index ad0fd38..ea3aeb5 100644 --- a/backend/src/staff/staff.controller.ts +++ b/backend/src/staff/staff.controller.ts @@ -1,21 +1,31 @@ -import { Body, Controller, Get, HttpCode, Param, Patch, Post, UseGuards } from '@nestjs/common'; +import { Body, Controller, Get, HttpCode, NotFoundException, Param, Patch, Post, UseGuards } from '@nestjs/common'; import { AdminGuard, JwtAuthGuard } from '../common/guards'; import { CreateStaffDto, UpdateStaffDto } from './dto/staff.dto'; import { StaffService } from './staff.service'; +import { PasswordSetupService } from './password-setup.service'; @Controller('admin/stores/:storeId/staff') @UseGuards(JwtAuthGuard, AdminGuard) export class StaffController { - constructor(private staff: StaffService) {} + constructor( + private staff: StaffService, + private passwordSetup: PasswordSetupService, + ) {} @Get() list(@Param('storeId') storeId: string) { return this.staff.list(storeId); } + /** Le nouveau compte reçoit par e-mail un lien pour choisir son mot de passe (comme depuis l'app). */ @Post() - create(@Param('storeId') storeId: string, @Body() dto: CreateStaffDto) { - return this.staff.create(storeId, dto); + async create(@Param('storeId') storeId: string, @Body() dto: CreateStaffDto) { + const { provisionalPassword: _unused, ...created } = await this.staff.create(storeId, dto); + try { + return { ...created, ...(await this.passwordSetup.sendInvitation(created.id, 'L’équipe MonEspacePro', 'invite')) }; + } catch { + return { ...created, invitationSentTo: null }; + } } @Patch(':id') @@ -25,7 +35,9 @@ export class StaffController { @Post(':id/reset-password') @HttpCode(200) - resetPassword(@Param('storeId') storeId: string, @Param('id') id: string) { - return this.staff.resetPassword(storeId, id); + async resetPassword(@Param('storeId') storeId: string, @Param('id') id: string) { + const member = (await this.staff.list(storeId)).find((m) => m.id === id); + if (!member) throw new NotFoundException('Employé introuvable'); + return this.passwordSetup.sendInvitation(id, 'L’équipe MonEspacePro', 'reset'); } } diff --git a/backend/src/stats/export.service.ts b/backend/src/stats/export.service.ts index 6112584..3fa0f62 100644 --- a/backend/src/stats/export.service.ts +++ b/backend/src/stats/export.service.ts @@ -50,7 +50,7 @@ export class ExportService { }); const totals = await this.prisma.transaction.groupBy({ by: ['cardId'], - where: { storeId, type: 'CREDIT' }, + where: { storeId, type: 'CREDIT', ...{ cancelledBy: { is: null } } }, _count: { _all: true }, _sum: { amountCents: true }, }); diff --git a/backend/src/stats/stats.service.ts b/backend/src/stats/stats.service.ts index 435d62d..5e5c9d7 100644 --- a/backend/src/stats/stats.service.ts +++ b/backend/src/stats/stats.service.ts @@ -60,13 +60,13 @@ export class StatsService { const [txs, cardsTotal, newCards, prevNewCards, prevVisits, appleCards, cardsCreated] = await Promise.all([ this.prisma.transaction.findMany({ - where: { storeId, createdAt: { gte: from }, type: { in: ['CREDIT', 'REDEEM'] } }, + where: { storeId, createdAt: { gte: from }, type: { in: ['CREDIT', 'REDEEM'] }, ...{ cancelledBy: { is: null } } }, select: { cardId: true, type: true, amountCents: true, points: true, createdAt: true }, }), this.prisma.loyaltyCard.count({ where: { storeId } }), this.prisma.loyaltyCard.count({ where: { storeId, createdAt: { gte: from } } }), this.prisma.loyaltyCard.count({ where: { storeId, createdAt: { gte: prevFrom, lt: from } } }), - this.prisma.transaction.count({ where: { storeId, type: 'CREDIT', createdAt: { gte: prevFrom, lt: from } } }), + this.prisma.transaction.count({ where: { storeId, type: 'CREDIT', createdAt: { gte: prevFrom, lt: from }, ...{ cancelledBy: { is: null } } } }), this.prisma.loyaltyCard.count({ where: { storeId, devices: { some: {} } } }), this.prisma.loyaltyCard.findMany({ where: { storeId, createdAt: { gte: from } }, select: { createdAt: true } }), ]); diff --git a/pro/app/account.tsx b/pro/app/account.tsx index 8bd1ba3..d47a73e 100644 --- a/pro/app/account.tsx +++ b/pro/app/account.tsx @@ -1,10 +1,12 @@ import { useState } from 'react'; -import { Alert, Pressable, ScrollView, TextInput, View } from 'react-native'; +import { Alert, Pressable, ScrollView, Switch, TextInput, View } from 'react-native'; import { api, ApiError } from '../src/api'; import { describe } from '../src/errors'; import { useSession } from '../src/session'; import { Banner, Button, Card, T } from '../src/ui'; import { font, useColors } from '../src/theme'; +import { useScanSound } from '../src/prefs'; +import { confirmIdentity } from '../src/biometrics'; /** Mon compte : profil, changement du mot de passe, déconnexion (tous les rôles). */ export default function Account() { @@ -34,6 +36,7 @@ export default function Account() { } const [requested, setRequested] = useState(false); + const [sound, setSound] = useScanSound(); /** Suppression de son compte. Le dernier dirigeant ne peut pas laisser le magasin sans dirigeant : * il envoie alors une demande de suppression du compte et du magasin. */ @@ -43,7 +46,13 @@ export default function Account() { 'Suppression définitive : vous ne pourrez plus vous connecter, et votre nom et votre e-mail sont effacés. Les opérations déjà faites restent dans l’historique du magasin, de façon anonyme.', [ { text: 'Annuler', style: 'cancel' }, - { text: 'Supprimer', style: 'destructive', onPress: remove }, + { + text: 'Supprimer', + style: 'destructive', + onPress: async () => { + if (await confirmIdentity('Supprimer votre compte')) remove(); + }, + }, ], ); } @@ -147,6 +156,15 @@ export default function Account() {
- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/a-propos/index.html b/site/a-propos/index.html index 127a38d..31262d0 100644 --- a/site/a-propos/index.html +++ b/site/a-propos/index.html @@ -153,7 +153,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/abonnement/merci/index.html b/site/abonnement/merci/index.html index a407fbb..22e1587 100644 --- a/site/abonnement/merci/index.html +++ b/site/abonnement/merci/index.html @@ -116,7 +116,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/assets/espace/index-H4FokPx0.js b/site/assets/espace/index-B7T6CQqW.js similarity index 94% rename from site/assets/espace/index-H4FokPx0.js rename to site/assets/espace/index-B7T6CQqW.js index 24d5cb2..04d8be2 100644 --- a/site/assets/espace/index-H4FokPx0.js +++ b/site/assets/espace/index-B7T6CQqW.js @@ -71,6 +71,6 @@ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var iv The chosen QR Code version cannot contain this amount of data. Minimum version required to store current data is: `+s+`. `);const a=jv(t,n,l),o=js.getSymbolSize(t),u=new uv(o);return hv(u,t),gv(u),vv(u,t),ei(u,n,0),t>=7&&yv(u,t),xv(u,a),isNaN(r)&&(r=ia.getBestMask(u,ei.bind(null,u,n))),ia.applyMask(r,u),ei(u,n,r),{modules:u,version:t,errorCorrectionLevel:n,maskPattern:r,segments:l}}Sf.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=Xs.M,l,s;return typeof n<"u"&&(r=Xs.from(n.errorCorrectionLevel,Xs.M),l=Gl.from(n.version),s=ia.from(n.maskPattern),n.toSJISFunc&&js.setToSJISFunction(n.toSJISFunc)),Sv(t,l,r,s)};var If={},mo={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(s){return[s,s]}))),r.length===6&&r.push("F","F");const l=parseInt(r.join(""),16);return{r:l>>24&255,g:l>>16&255,b:l>>8&255,a:l&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const l=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,s=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:s,scale:s?4:a,margin:l,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,l){return l.width&&l.width>=r+l.margin*2?l.width/(r+l.margin*2):l.scale},e.getImageWidth=function(r,l){const s=e.getScale(r,l);return Math.floor((r+l.margin*2)*s)},e.qrToImageData=function(r,l,s){const a=l.modules.size,o=l.modules.data,u=e.getScale(a,s),c=Math.floor((a+s.margin*2)*u),p=s.margin*u,g=[s.color.light,s.color.dark];for(let m=0;m=p&&y>=p&&m"u"&&(!a||!a.getContext)&&(u=a,a=void 0),a||(c=r()),u=t.getOptions(u);const p=t.getImageWidth(s.modules.size,u),g=c.getContext("2d"),m=g.createImageData(p,p);return t.qrToImageData(m.data,s,u),n(g,c,p),g.putImageData(m,0,0),c},e.renderToDataURL=function(s,a,o){let u=o;typeof u>"u"&&(!a||!a.getContext)&&(u=a,a=void 0),u||(u={});const c=e.render(s,a,u),p=u.type||"image/png",g=u.rendererOpts||{};return c.toDataURL(p,g.quality)}})(If);var Ff={};const Nv=mo;function Iu(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function ti(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function Cv(e,t,n){let r="",l=0,s=!1,a=0;for(let o=0;o0&&u>0&&e[o-1]||(r+=s?ti("M",u+n,.5+c+n):ti("m",l,0),l=0,s=!1),u+1':"",c="',p='viewBox="0 0 '+o+" "+o+'"',m=''+u+c+` -`;return typeof r=="function"&&r(null,m),m};const Ev=$g,oa=Sf,Df=If,kv=Ff;function ho(e,t,n,r,l){const s=[].slice.call(arguments,1),a=s.length,o=typeof s[a-1]=="function";if(!o&&!Ev())throw new Error("Callback required as last argument");if(o){if(a<2)throw new Error("Too few arguments provided");a===2?(l=n,n=t,t=r=void 0):a===3&&(t.getContext&&typeof l>"u"?(l=r,r=void 0):(l=r,r=n,n=t,t=void 0))}else{if(a<1)throw new Error("Too few arguments provided");return a===1?(n=t,t=r=void 0):a===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(u,c){try{const p=oa.create(n,r);u(e(p,t,r))}catch(p){c(p)}})}try{const u=oa.create(n,r);l(null,e(u,t,r))}catch(u){l(u)}}Dr.create=oa.create;Dr.toCanvas=ho.bind(null,Df.render);Dr.toDataURL=ho.bind(null,Df.renderToDataURL);Dr.toString=ho.bind(null,function(e,t,n){return kv.render(e,n)});const Pv={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}};function Of(e){const t=Pv[e.format],n=(e.rewards??[]).filter(c=>c.active!==!1&&c.label.trim()).sort((c,p)=>c.cost-p.cost),r=n.slice(0,t.maxRewards),l=e.pointsMode==="STAMP"?"tampons":"points",s=r.length?t.qrWithRewards:t.qr,[a,o]=j.useState("");j.useEffect(()=>{Dr.toString(e.url,{type:"svg",errorCorrectionLevel:"Q",margin:0,color:{dark:"#111111",light:"#FFFFFF"}}).then(o)},[e.url]);const u=c=>`${c}mm`;return i.jsxs("div",{className:"poster",style:{width:u(t.w),height:u(t.h),padding:u(t.pad),boxSizing:"border-box",background:e.backgroundColor,color:e.foregroundColor,fontFamily:"'Figtree', system-ui, sans-serif",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"space-between",textAlign:"center",overflow:"hidden",printColorAdjust:"exact",WebkitPrintColorAdjust:"exact"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:u(3)},children:[e.logoUrl&&i.jsx("img",{src:e.logoUrl,alt:"",style:{width:u(t.logo),height:u(t.logo),objectFit:"contain",borderRadius:u(2.5),background:"#fff"}}),i.jsx("span",{style:{fontSize:u(t.store),fontWeight:700},children:e.storeName})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:u(2.5)},children:[i.jsx("span",{style:{fontSize:u(t.eyebrow),fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:e.labelColor},children:e.programName}),i.jsx("span",{style:{fontSize:u(t.title),lineHeight:1.12,fontWeight:800,letterSpacing:"-0.02em",maxWidth:"92%"},children:"Scannez pour obtenir votre carte de fidélité"})]}),i.jsx("div",{role:"img","aria-label":"QR code d'inscription",style:{background:"#fff",borderRadius:u(3.5),padding:u(4),width:u(s),height:u(s),boxSizing:"content-box"},dangerouslySetInnerHTML:{__html:a}}),r.length>0&&i.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:u(1.6)},children:[i.jsx("span",{style:{fontSize:u(t.small),fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:e.labelColor},children:"Vos récompenses"}),i.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:u(1.2)},children:r.map(c=>i.jsxs("li",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:u(3),padding:`${u(1.4)} ${u(3)}`,borderRadius:u(2.5),background:"rgba(255,255,255,0.12)",fontSize:u(t.body),lineHeight:1.25},children:[i.jsx("span",{style:{fontWeight:700,textAlign:"left"},children:c.label}),i.jsxs("span",{style:{whiteSpace:"nowrap",color:e.labelColor,fontWeight:600},children:[c.cost," ",l]})]},`${c.label}-${c.cost}`))}),n.length>r.length&&i.jsxs("span",{style:{fontSize:u(t.small),color:e.labelColor},children:["et ",n.length-r.length," autre(s) à découvrir sur votre carte"]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:u(1.5)},children:[i.jsx("span",{style:{fontSize:u(t.body),lineHeight:1.4,fontWeight:600},children:"Ajoutez-la à Apple Wallet ou Google Wallet."}),i.jsx("span",{style:{fontSize:u(t.small),lineHeight:1.4,color:e.labelColor},children:"Gratuit, sans application à télécharger."})]})]})}function Uf(e){return new Promise((t,n)=>{const r=URL.createObjectURL(e),l=new Image;l.onload=()=>{URL.revokeObjectURL(r),t(l)},l.onerror=()=>n(new Error("Image illisible")),l.src=r})}function $f(e){return new Promise((t,n)=>e.toBlob(r=>r?t(r):n(new Error("Conversion impossible")),"image/png"))}async function Rv(e){const t=await Uf(e),n=1125,r=432,l=Math.max(n/t.width,r/t.height),s=n/l,a=r/l,o=Object.assign(document.createElement("canvas"),{width:n,height:r});return o.getContext("2d").drawImage(t,(t.width-s)/2,(t.height-a)/2,s,a,0,0,n,r),$f(o)}async function Tv(e){const t=await Uf(e),n=Math.min(1,480/Math.max(t.width,t.height)),r=Object.assign(document.createElement("canvas"),{width:Math.round(t.width*n),height:Math.round(t.height*n)});return r.getContext("2d").drawImage(t,0,0,r.width,r.height),$f(r)}async function Lv(e){const t=new Image;t.crossOrigin="anonymous",t.src=e;try{await t.decode()}catch{return null}const r=Object.assign(document.createElement("canvas"),{width:48,height:48}).getContext("2d");r.drawImage(t,0,0,48,48);let l;try{l=r.getImageData(0,0,48,48).data}catch{return null}const s=new Map;for(let u=0;u235&&p>235&&g>235)continue;const y=`${c>>5}${p>>5}${g>>5}`,x=s.get(y)??{n:0,r:0,g:0,b:0};s.set(y,{n:x.n+1,r:x.r+c,g:x.g+p,b:x.b+g})}const a=[...s.values()].sort((u,c)=>c.n-u.n)[0];if(!a)return null;const o=u=>Math.round(u/a.n).toString(16).padStart(2,"0");return`#${o(a.r)}${o(a.g)}${o(a.b)}`.toUpperCase()}function Fu(e,t){const n=s=>{const[a,o,u]=[1,3,5].map(c=>{const p=parseInt(s.slice(c,c+2),16)/255;return p<=.03928?p/12.92:((p+.055)/1.055)**2.4});return .2126*a+.7152*o+.0722*u},[r,l]=[n(e),n(t)].sort((s,a)=>a-s);return(r+.05)/(l+.05)}const ni=["Identité","Couleurs","Règle de points","Récompenses","Récapitulatif"],Av=[["Ardoise","#1F2937","#FFFFFF","#D1D5DB"],["Émeraude","#0E7A66","#FFFFFF","#CDEDE4"],["Brique","#A64B17","#FFF4E4","#F7D58B"],["Marine","#1E3A5F","#FFFFFF","#BFD3EA"],["Prune","#5B2245","#FFFFFF","#E9C6DA"],["Crème","#FFF8EC","#3B2A1A","#8A6A4A"]],Mv=["Café offert","Viennoiserie offerte","Dessert offert","-10 % sur le prochain achat"];function _v(e){return{programName:`Fidélité ${e.name}`.slice(0,40),backgroundColor:"#1F2937",foregroundColor:"#FFFFFF",labelColor:"#D1D5DB",pointsMode:"AMOUNT",pointsPerEuro:1,rewards:[]}}function Bf({store:e,onSaved:t,base:n=`/api/admin/stores/${e.id}/card-design`,posterHref:r=`/magasins/${e.id}/affichette`,draftNote:l}){const[s,a]=j.useState(0),[o,u]=j.useState(null),[c,p]=j.useState({logoUrl:null,stripUrl:null}),[g,m]=j.useState(!1),[y,x]=j.useState("apple"),[w,S]=j.useState(null),[f,d]=j.useState(!1),[h,v]=j.useState(null);function N(L){const{logoUrl:W,stripUrl:se,...Ae}=L;u(Ae),p({logoUrl:na(W),stripUrl:na(se)}),m(!0)}if(j.useEffect(()=>{O.get(n).then(L=>L?N(L):u(_v(e))).catch(L=>S(L.message))},[n,e]),j.useEffect(()=>{c.logoUrl&&Lv(c.logoUrl).then(v)},[c.logoUrl]),!o)return w?i.jsx("div",{className:"alert error",children:w}):i.jsx("p",{className:"muted",children:"Chargement…"});const E=(L,W)=>u({...o,[L]:W});async function k(){S(null),d(!0);try{const{programName:L,backgroundColor:W,foregroundColor:se,labelColor:Ae,pointsMode:Ze,pointsPerEuro:R}=o,_=o.rewards.map(({id:z,label:H,cost:Z,active:nn})=>({id:z,label:H,cost:Z,active:nn}));return N(await O.put(n,{programName:L,backgroundColor:W,foregroundColor:se,labelColor:Ae,pointsMode:Ze,pointsPerEuro:R,rewards:_})),t(),!0}catch(L){return S(L.message),!1}finally{d(!1)}}async function C(){await k()&&a(L=>Math.min(L+1,ni.length-1))}async function M(L,W){var Ae;const se=(Ae=W.target.files)==null?void 0:Ae[0];if(W.target.value="",!!se&&!(!g&&!await k())){d(!0),S(null);try{const Ze=L==="logo"?await Tv(se):await Rv(se),R=new FormData;R.append("file",Ze,`${L}.png`),N(await O.post(`${n}/images/${L}`,R))}catch(Ze){S(Ze.message)}finally{d(!1)}}}const A={...o,...c,storeName:e.name},U=Fu(o.backgroundColor,o.foregroundColor),Le=Fu(o.backgroundColor,o.labelColor);return i.jsxs("div",{className:"wizard",children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[i.jsx("ol",{className:"steps","aria-label":"Étapes",children:ni.map((L,W)=>i.jsx("li",{children:i.jsxs("button",{type:"button","aria-current":W===s?"step":void 0,className:Wa(W),children:[i.jsx("span",{className:"n",children:WE("programName",L.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("span",{style:{fontWeight:600},children:"Logo"}),i.jsxs("div",{className:"upload-drop",children:[c.logoUrl&&i.jsx("img",{src:c.logoUrl,alt:"Logo actuel"}),i.jsxs("label",{className:"btn secondary small",children:[c.logoUrl?"Remplacer":"Choisir un fichier",i.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",onChange:L=>M("logo",L),disabled:f})]}),i.jsx("span",{className:"hint",children:"PNG carré conseillé, fond transparent."})]})]}),i.jsxs("div",{className:"field",children:[i.jsx("span",{style:{fontWeight:600},children:"Bandeau"}),i.jsxs("div",{className:"upload-drop",children:[c.stripUrl&&i.jsx("img",{src:c.stripUrl,alt:"Bandeau actuel"}),i.jsxs("label",{className:"btn secondary small",children:[c.stripUrl?"Remplacer":"Choisir un fichier",i.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",onChange:L=>M("strip",L),disabled:f})]}),i.jsx("span",{className:"hint",children:"Recadré automatiquement au format Wallet (1125 × 432)."})]})]})]}),s===1&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Couleurs"}),i.jsxs("div",{className:"field",children:[i.jsx("span",{style:{fontWeight:600},children:"Palettes prêtes à l’emploi"}),i.jsx("div",{className:"palettes",children:Av.map(([L,W,se,Ae])=>i.jsxs("button",{type:"button",className:"palette","aria-pressed":o.backgroundColor===W&&o.foregroundColor===se,onClick:()=>u({...o,backgroundColor:W,foregroundColor:se,labelColor:Ae}),children:[i.jsx("span",{style:{background:W,color:se},children:"Aa"}),L]},L))})]}),h&&h!==o.backgroundColor&&i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("span",{style:{width:28,height:28,borderRadius:8,background:h,border:"1px solid var(--border)"}}),i.jsxs("span",{children:["Couleur extraite du logo : ",h]}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>E("backgroundColor",h),children:"Utiliser comme fond"})]}),[["backgroundColor","Fond"],["foregroundColor","Texte"],["labelColor","Libellés"]].map(([L,W])=>i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:L,children:W}),i.jsxs("div",{className:"color-row",children:[i.jsx("input",{type:"color","aria-label":`${W} (sélecteur)`,value:o[L],onChange:se=>E(L,se.target.value.toUpperCase())}),i.jsx("input",{id:L,className:"input",style:{maxWidth:160},value:o[L],pattern:"#[0-9A-Fa-f]{6}",onChange:se=>E(L,se.target.value)})]})]},L)),U<4.5&&i.jsxs("div",{className:"alert warn",children:["Contraste texte/fond insuffisant (",U.toFixed(1),":1, minimum 4,5:1) : le solde sera difficile à lire."]}),Le<3&&i.jsxs("div",{className:"alert warn",children:["Contraste libellés/fond faible (",Le.toFixed(1),":1, minimum conseillé 3:1)."]})]}),s===2&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Règle de points"}),i.jsxs("div",{className:"mode-cards",role:"radiogroup",children:[i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"mode",checked:o.pointsMode==="AMOUNT",onChange:()=>E("pointsMode","AMOUNT")}),i.jsxs("span",{children:[i.jsx("strong",{children:"Points selon le montant"}),i.jsx("br",{}),i.jsx("span",{className:"muted",children:"X points par euro dépensé"})]})]}),i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"mode",checked:o.pointsMode==="STAMP",onChange:()=>E("pointsMode","STAMP")}),i.jsxs("span",{children:[i.jsx("strong",{children:"Tampons"}),i.jsx("br",{}),i.jsx("span",{className:"muted",children:"1 tampon par passage"})]})]})]}),o.pointsMode==="AMOUNT"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"ppe",children:"Points par euro *"}),i.jsx("input",{id:"ppe",className:"input",type:"number",step:"0.01",min:.01,max:100,style:{maxWidth:160},value:o.pointsPerEuro,onChange:L=>E("pointsPerEuro",Number(L.target.value))})]}),i.jsxs("p",{className:"muted",style:{margin:0},children:["Exemple : un panier de 23,50 € = ",i.jsxs("strong",{children:[Math.floor(23.5*o.pointsPerEuro)," points"]})," (arrondi à l'inférieur)."]})]}):i.jsx("p",{className:"muted",style:{margin:0},children:"Chaque passage validé par un employé ajoute un tampon, quel que soit le montant."})]}),s===3&&i.jsx(zv,{rewards:o.rewards,unit:o.pointsMode==="STAMP"?"tampons":"points",onChange:L=>E("rewards",L)}),s===4&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Récapitulatif"}),i.jsxs("ul",{style:{margin:0,paddingLeft:20,lineHeight:1.8},children:[i.jsxs("li",{children:["Programme : ",i.jsx("strong",{children:o.programName})]}),i.jsxs("li",{children:["Règle : ",o.pointsMode==="STAMP"?"1 tampon par passage":`${o.pointsPerEuro} point(s) par euro`]}),i.jsxs("li",{children:["Récompenses : ",o.rewards.filter(L=>L.active!==!1).map(L=>`${L.label} (${L.cost})`).join(", ")||"aucune"]}),i.jsxs("li",{children:["Logo : ",c.logoUrl?"oui":i.jsx("span",{style:{color:"var(--warn)"},children:"manquant"})," · Bandeau : ",c.stripUrl?"oui":"non"]})]}),i.jsx("h3",{style:{margin:"8px 0 0"},children:"Affichette du comptoir"}),i.jsxs("div",{style:{display:"flex",gap:24,flexWrap:"wrap",alignItems:"flex-start"},children:[i.jsx("div",{style:{width:222,height:315,overflow:"hidden",borderRadius:8,boxShadow:"0 4px 16px rgb(0 0 0 / 0.15)"},children:i.jsx("div",{style:{transform:"scale(0.4)",transformOrigin:"top left"},children:i.jsx(Of,{format:"A5",url:e.enrollUrl,storeName:e.name,programName:o.programName,logoUrl:c.logoUrl,backgroundColor:o.backgroundColor,foregroundColor:o.foregroundColor,labelColor:o.labelColor,rewards:o.rewards,pointsMode:o.pointsMode})})}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,flex:"1 1 220px"},children:[i.jsx("p",{style:{margin:0},children:"Le QR mène à la page d'inscription :"}),i.jsx("a",{href:e.enrollUrl,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:e.enrollUrl}),i.jsx(Ee,{to:r,className:"btn secondary",children:"Imprimer l'affichette (A5 / A6)"})]})]}),e.status==="DRAFT"&&(l??i.jsxs("p",{style:{margin:0},children:["Le programme s'ouvre automatiquement dès que l'abonnement est payé. Sinon, utilisez le bouton ",i.jsx("strong",{children:"Activer"})," en haut de la fiche."]}))]}),i.jsxs("div",{className:"row between",children:[i.jsx("button",{type:"button",className:"btn secondary",disabled:s===0,onClick:()=>a(s-1),children:"Précédent"}),sx("apple"),children:"Apple Wallet"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":y==="google",onClick:()=>x("google"),children:"Google Wallet"})]}),y==="apple"?i.jsx(Og,{d:A}):i.jsx(Ug,{d:A}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Aperçu indicatif — QR et solde fictifs."})]})]})}function zv({rewards:e,unit:t,onChange:n}){const r=(l,s)=>n(e.map((a,o)=>o===l?{...a,...s}:a));return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Récompenses"}),e.length===0&&i.jsxs("div",{className:"field",children:[i.jsx("p",{className:"muted",style:{margin:0},children:"Aucune récompense pour l’instant. Ajoutez-en une, ou partez d’une idée :"}),i.jsx("div",{className:"row",style:{gap:8},children:Mv.map(l=>i.jsxs("button",{type:"button",className:"chip",onClick:()=>n([...e,{label:l,cost:10}]),children:["+ ",l]},l))})]}),e.map((l,s)=>i.jsxs("div",{className:"row",style:{alignItems:"flex-end",opacity:l.active===!1?.6:1},children:[i.jsxs("div",{className:"field",style:{flex:"1 1 240px"},children:[i.jsx("label",{htmlFor:`rw-label-${s}`,children:"Libellé"}),i.jsx("input",{id:`rw-label-${s}`,className:"input",maxLength:60,value:l.label,onChange:a=>r(s,{label:a.target.value})})]}),i.jsxs("div",{className:"field",style:{width:140},children:[i.jsxs("label",{htmlFor:`rw-cost-${s}`,children:["Coût (",t,")"]}),i.jsx("input",{id:`rw-cost-${s}`,className:"input",type:"number",min:1,value:l.cost,onChange:a=>r(s,{cost:Number(a.target.value)})})]}),l.active===!1?i.jsx("button",{type:"button",className:"btn secondary",onClick:()=>r(s,{active:!0}),children:"Réactiver"}):i.jsx("button",{type:"button",className:"btn secondary","aria-label":`Retirer ${l.label||"la récompense"}`,onClick:()=>n(e.filter((a,o)=>o!==s)),children:"Retirer"})]},l.id??`new-${s}`)),i.jsx("div",{children:i.jsx("button",{type:"button",className:"btn secondary",disabled:e.length>=20,onClick:()=>n([...e,{label:"",cost:10}]),children:"+ Ajouter une récompense"})})]})}const ua={MANAGER:"Dirigeant",EMPLOYEE:"Employé"};function Iv({storeId:e}){const t=`/api/admin/stores/${e}/staff`,[n,r]=j.useState([]),[l,s]=j.useState(null),[a,o]=j.useState(null),u=j.useRef(null),c=j.useRef(null),p=j.useCallback(()=>{O.get(t).then(r).catch(d=>s(d.message))},[t]);j.useEffect(p,[p]);function g(d){var h;o(d),(h=c.current)==null||h.showModal(),p()}async function m(d){try{await O.patch(`${t}/${d.id}`,{active:!d.active}),p()}catch(h){s(h.message)}}async function y(d){if(window.confirm(`Générer un nouveau mot de passe pour ${d.displayName} ? Ses sessions seront fermées.`))try{g(await O.post(`${t}/${d.id}/reset-password`))}catch(h){s(h.message)}}async function x(d){const h=d.role==="MANAGER"?"EMPLOYEE":"MANAGER";if(window.confirm(`${d.displayName} devient ${ua[h]}. Ses sessions ouvertes seront fermées.`))try{await O.patch(`${t}/${d.id}`,{role:h}),p()}catch(v){s(v.message)}}const w=n.filter(d=>d.active),S=w.filter(d=>d.role==="MANAGER").length,f=[...n].sort((d,h)=>Number(h.active)-Number(d.active)||d.role.localeCompare(h.role)||d.displayName.localeCompare(h.displayName));return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Employés"}),i.jsxs("p",{className:"muted",style:{margin:0},children:[w.length," compte",w.length>1?"s":""," actif",w.length>1?"s":""," · ",S," dirigeant",S>1?"s":""]})]}),i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=u.current)==null?void 0:d.showModal()},children:"+ Nouvel employé"})]}),l&&i.jsx("div",{className:"alert error",role:"alert",children:l}),n.length>0&&S===0&&i.jsx("div",{className:"alert warn",children:"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é."}),n.length===0?i.jsxs("section",{className:"card",style:{textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:40},children:[i.jsx("span",{className:"staff-avatar big","aria-hidden":"true",children:"👥"}),i.jsx("h3",{style:{margin:0},children:"Aucun compte pour l’instant"}),i.jsx("p",{className:"muted",style:{margin:0,maxWidth:420},children:"Créez au moins un Dirigeant : il pourra ensuite ajouter lui-même son équipe depuis l’app MonEspacePro."}),i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=u.current)==null?void 0:d.showModal()},children:"Créer le premier compte"})]}):i.jsx("div",{className:"staff-grid",children:f.map(d=>i.jsxs("article",{className:`card staff-card${d.active?"":" off"}`,children:[i.jsxs("div",{className:"row",style:{gap:12,flexWrap:"nowrap"},children:[i.jsx("span",{className:`staff-avatar${d.role==="MANAGER"?" mgr":""}`,"aria-hidden":"true",children:d.displayName.charAt(0).toUpperCase()}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("strong",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.displayName}),i.jsx("span",{className:"muted",style:{fontSize:14,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.email})]})]}),i.jsxs("div",{className:"row",style:{gap:6},children:[i.jsx("span",{className:`role-pill${d.role==="MANAGER"?" mgr":""}`,children:ua[d.role]}),d.active?i.jsx("span",{className:"badge ACTIVE",children:"Actif"}):i.jsx("span",{className:"badge DRAFT",children:"Désactivé"}),i.jsxs("span",{className:"muted",style:{fontSize:13},children:["depuis le ",new Date(d.createdAt).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"})]})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("button",{className:"btn secondary small",onClick:()=>x(d),children:d.role==="MANAGER"?"Passer Employé":"Passer Dirigeant"}),i.jsx("button",{className:"btn secondary small",onClick:()=>y(d),children:"Nouveau mot de passe"}),i.jsx("button",{className:"btn secondary small",onClick:()=>m(d),children:d.active?"Désactiver":"Réactiver"})]})]},d.id))}),i.jsx("dialog",{ref:u,"aria-labelledby":"new-staff-title",children:i.jsx(Fv,{base:t,onCancel:()=>{var d;return(d=u.current)==null?void 0:d.close()},onCreated:d=>{var h;(h=u.current)==null||h.close(),g(d)}})}),i.jsx("dialog",{ref:c,"aria-labelledby":"pwd-title",children:i.jsxs("div",{className:"dialog-body",children:[i.jsx("h2",{id:"pwd-title",children:"Mot de passe provisoire"}),i.jsxs("p",{style:{margin:0},children:["Communiquez-le à ",i.jsx("strong",{children:a==null?void 0:a.displayName})," (",a==null?void 0:a.email,"). Il ne sera plus affiché ensuite."]}),i.jsx("div",{className:"password-box",children:a==null?void 0:a.provisionalPassword}),i.jsxs("div",{className:"row",style:{justifyContent:"flex-end"},children:[i.jsx("button",{className:"btn secondary",onClick:()=>{var d;return(d=navigator.clipboard)==null?void 0:d.writeText((a==null?void 0:a.provisionalPassword)??"")},children:"Copier"}),i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=c.current)==null?void 0:d.close()},children:"J'ai noté le mot de passe"})]})]})})]})}function Fv({base:e,onCancel:t,onCreated:n}){const[r,l]=j.useState(""),[s,a]=j.useState(""),[o,u]=j.useState("EMPLOYEE"),[c,p]=j.useState(null),[g,m]=j.useState(!1);async function y(x){x.preventDefault(),m(!0),p(null);try{n(await O.post(e,{displayName:r,email:s,role:o})),l(""),a(""),u("EMPLOYEE")}catch(w){p(w.message)}finally{m(!1)}}return i.jsxs("form",{className:"dialog-body",onSubmit:y,children:[i.jsx("h2",{id:"new-staff-title",children:"Nouvel employé"}),c&&i.jsx("div",{className:"alert error",role:"alert",children:c}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"staff-name",children:"Prénom et nom *"}),i.jsx("input",{id:"staff-name",className:"input",required:!0,placeholder:"Prénom Nom",value:r,onChange:x=>l(x.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"staff-email",children:"E-mail *"}),i.jsx("input",{id:"staff-email",className:"input",type:"email",required:!0,placeholder:"prenom@exemple.fr",value:s,onChange:x=>a(x.target.value)})]}),i.jsxs("fieldset",{style:{border:0,padding:0,margin:0},className:"field",children:[i.jsx("legend",{style:{fontWeight:600,marginBottom:6},children:"Rôle *"}),i.jsx("div",{className:"mode-cards",children:["EMPLOYEE","MANAGER"].map(x=>i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"role",checked:o===x,onChange:()=>u(x)}),i.jsxs("span",{children:[i.jsx("strong",{children:ua[x]}),i.jsx("br",{}),i.jsx("span",{className:"muted",style:{fontSize:14},children:x==="MANAGER"?"Toute la configuration : carte, modules, campagnes, employés, statistiques":"Scanne les cartes et crédite les points, voit ses opérations"})]})]},x))})]}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Un mot de passe provisoire sera généré à la création."}),i.jsxs("div",{className:"row",style:{justifyContent:"flex-end"},children:[i.jsx("button",{type:"button",className:"btn secondary",onClick:t,children:"Annuler"}),i.jsx("button",{className:"btn",disabled:g,children:"Créer le compte"})]})]})}const Du={ACTIVE:["Actif","ACTIVE"],INCOMPLETE:["En attente de paiement","DRAFT"],PAST_DUE:["Impayé","SUSPENDED"],CANCELED:["Résilié","CLOSED"]},Dv={multiStore:"Carte commune à plusieurs magasins"},sl=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),ln=e=>new Date(e).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"});function Ov({storeId:e,contactEmail:t,onChange:n}){const[r,l]=j.useState(null),[s,a]=j.useState(null),[o,u]=j.useState(null),[c,p]=j.useState(!1),[g,m]=j.useState(null),[y,x]=j.useState(null),w=j.useCallback(()=>{O.get(`/api/admin/stores/${e}/billing`).then(l).catch(C=>a(C.message))},[e]);j.useEffect(w,[w]);async function S(C,M,A){p(!0),a(null);try{const U=await O.post(M,A);u({...U,label:C}),w(),n()}catch(U){a(U.message)}finally{p(!1)}}if(!r)return s?i.jsx("div",{className:"alert error",children:s}):i.jsx("p",{className:"muted",children:"Chargement…"});const f=r.subscription,d=f&&f.status!=="CANCELED"&&f.hasSubscription?r.catalog.find(C=>C.plan===f.plan):null,h=!d,v=g??(f==null?void 0:f.plan)??"PRO",N=y??(f==null?void 0:f.interval)??"MONTH",E=r.invoices.filter(C=>C.paidAt).reduce((C,M)=>C+M.amountCents,0),k=r.invoices.filter(C=>!C.paidAt).length;return i.jsxs(i.Fragment,{children:[r.testMode&&i.jsx("div",{className:"alert warn",children:"Stripe est en mode test : aucun paiement réel n'est encaissé (carte de test 4242 4242 4242 4242)."}),s&&i.jsx("div",{className:"alert error",role:"alert",children:s}),i.jsxs("div",{className:"kpis",children:[i.jsxs("div",{className:`kpi${d?" ok":""}`,children:[i.jsx("b",{children:d?d.name:"—"}),i.jsx("span",{children:d?`formule ${f.interval==="YEAR"?"annuelle":"mensuelle"}`:(f==null?void 0:f.status)==="INCOMPLETE"?`en attente · ${qe[f.plan]} choisie`:"aucune formule"})]}),i.jsxs("div",{className:"kpi",children:[i.jsx("b",{children:d?sl(d.priceCents[f.interval]):"—"}),i.jsx("span",{children:d?`par ${f.interval==="YEAR"?"an":"mois"}`:"montant"})]}),i.jsxs("div",{className:`kpi${f!=null&&f.cancelAtPeriodEnd?" warn":""}`,children:[i.jsx("b",{style:{fontSize:20,lineHeight:"34px"},children:f!=null&&f.currentPeriodEnd&&f.status==="ACTIVE"?ln(f.currentPeriodEnd):"—"}),i.jsx("span",{children:f!=null&&f.cancelAtPeriodEnd?"fin de l’abonnement":"prochain prélèvement"})]}),i.jsxs("div",{className:`kpi${k?" err":""}`,children:[i.jsx("b",{children:sl(E)}),i.jsxs("span",{children:[r.invoices.length," facture",r.invoices.length>1?"s":"",k?` · ${k} impayée${k>1?"s":""}`:" · tout est réglé"]})]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Abonnement"}),i.jsx("p",{className:"muted",style:{margin:0},children:d?`Formule ${d.name}${f.legacyPrice?" (tarif fondateur)":""} — ${f.interval==="YEAR"?"annuelle":"mensuelle"}`:"Aucune formule souscrite. Sans abonnement actif, le magasin a les droits de la formule Essentiel."})]}),i.jsx("span",{className:`badge ${f?Du[f.status][1]:"DRAFT"}`,children:f?Du[f.status][0]:"Aucun abonnement"})]}),(f==null?void 0:f.cancelAtPeriodEnd)&&f.currentPeriodEnd&&i.jsxs("div",{className:"alert warn",children:["Résiliation demandée : l'abonnement s'arrête le ",i.jsx("strong",{children:ln(f.currentPeriodEnd)}),"."]}),(f==null?void 0:f.currentPeriodEnd)&&f.status==="ACTIVE"&&!f.cancelAtPeriodEnd&&i.jsxs("p",{style:{margin:0},children:["Prochain prélèvement le ",i.jsx("strong",{children:ln(f.currentPeriodEnd)}),"."]}),r.billingSuspended&&i.jsx("div",{className:"alert warn",children:"Magasin suspendu automatiquement pour impayé. Il sera réactivé dès que le paiement passera."}),d&&i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsxs("button",{className:"btn",disabled:c,onClick:()=>S("Espace abonnement",`/api/admin/stores/${e}/billing/portal-link`,{sendEmail:!0}),children:["Envoyer l'espace abonnement à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>S("Espace abonnement",`/api/admin/stores/${e}/billing/portal-link`,{sendEmail:!1}),children:"Ouvrir l'espace abonnement"}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Changer de formule, de moyen de paiement, résilier."})]})]}),h&&i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[i.jsxs("div",{className:"row between",children:[i.jsx("h2",{children:"Choisir une formule"}),i.jsxs("div",{role:"group","aria-label":"Périodicité",className:"row",style:{gap:8},children:[i.jsx("button",{type:"button",className:"chip","aria-pressed":N==="MONTH",onClick:()=>x("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":N==="YEAR",onClick:()=>x("YEAR"),children:"Annuel — 2 mois offerts"})]})]}),i.jsx("div",{className:"mode-cards",role:"radiogroup","aria-label":"Formule",children:r.catalog.map(C=>i.jsxs("label",{className:"mode-card",style:{flexDirection:"column",gap:8},children:[i.jsxs("span",{className:"row",style:{gap:10},children:[i.jsx("input",{type:"radio",name:"plan",checked:v===C.plan,onChange:()=>m(C.plan)}),i.jsx("strong",{style:{fontSize:18},children:C.name}),C.plan==="PRO"&&i.jsx("span",{className:"badge ACTIVE",style:{height:22},children:"Conseillée"})]}),i.jsxs("span",{style:{fontSize:24,fontWeight:800},children:[sl(C.priceCents[N]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",N==="YEAR"?"an":"mois",C.plan==="RESEAU"?" / magasin":""]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:C.tagline}),i.jsxs("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:[i.jsx("li",{children:C.limits.maxStaff?`${C.limits.maxStaff} employés`:"Employés illimités"}),i.jsx("li",{children:"Carte Wallet, points ou tampons, récompenses, mises à jour en direct"}),C.features.map(M=>i.jsx("li",{children:Dv[M]??M},M))]}),i.jsx("span",{style:{fontSize:14,fontWeight:700},children:C.modules.length?`Modules inclus (${C.modules.length})`:"Aucun module inclus"}),C.modules.length>0&&i.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:C.modules.map(M=>i.jsx("li",{title:M.tagline,children:M.name},M.id))})]},C.plan))}),i.jsxs("div",{className:"copy-line",style:{flexWrap:"wrap"},children:[i.jsx("span",{className:"muted",children:"Lien de paiement permanent :"}),i.jsx("code",{children:r.subscribeUrl}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>{var C;return(C=navigator.clipboard)==null?void 0:C.writeText(r.subscribeUrl)},children:"Copier"})]}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Il ne périme pas. Le commerçant peut saisir un code promo sur la page de paiement (codes à créer dans Stripe → Coupons)."}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsxs("button",{className:"btn",disabled:c,onClick:()=>S("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:v,interval:N,sendEmail:!0}),children:["Envoyer le lien à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>S("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:v,interval:N,sendEmail:!1}),children:"Enregistrer la formule sans envoyer"})]})]}),o&&i.jsxs("div",{className:"alert ok",children:[o.label," ",o.emailedTo?i.jsxs(i.Fragment,{children:["envoyé à ",i.jsx("strong",{children:o.emailedTo}),". "]}):"créé. ",i.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:o.url})]}),i.jsxs("div",{className:"row between",style:{marginTop:8},children:[i.jsx("h2",{children:"Factures"}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Émises et envoyées automatiquement à chaque paiement."})]}),i.jsxs("div",{className:"table-wrap",children:[i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{minWidth:720},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",style:{paddingLeft:24},children:"Facture"}),i.jsx("th",{scope:"col",children:"Objet"}),i.jsx("th",{scope:"col",children:"Période"}),i.jsx("th",{scope:"col",className:"num",children:"Montant"}),i.jsx("th",{scope:"col",children:"Statut"}),i.jsx("th",{scope:"col",children:i.jsx("span",{className:"sr-only",children:"PDF"})})]})}),i.jsx("tbody",{children:r.invoices.map(C=>i.jsxs("tr",{children:[i.jsx("td",{style:{paddingLeft:24,fontWeight:600},children:C.number}),i.jsx("td",{style:{fontSize:14},children:C.description.replace("Abonnement MonEspacePro — ","")}),i.jsxs("td",{children:[ln(C.periodStart)," → ",ln(C.periodEnd)]}),i.jsx("td",{className:"num",children:sl(C.amountCents)}),i.jsx("td",{children:C.paidAt?i.jsxs("span",{className:"badge ACTIVE",children:["Payée le ",ln(C.paidAt)]}):i.jsx("span",{className:"badge SUSPENDED",children:"Impayée"})}),i.jsx("td",{style:{textAlign:"right",paddingRight:24},children:i.jsx("button",{className:"btn secondary small",onClick:()=>la(`/api/admin/invoices/${C.id}/pdf`,`${C.number}.pdf`).catch(M=>a(M.message)),children:"PDF"})})]},C.id))})]})}),r.invoices.length===0&&i.jsx("p",{className:"muted",style:{padding:24,margin:0,textAlign:"center"},children:"Aucune facture pour l'instant. Elles sont créées automatiquement à chaque paiement."})]})]})}const Ou=e=>new Date(e).toLocaleString("fr-FR",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"});function Uv({storeId:e,storeName:t}){const[n,r]=j.useState(null),[l,s]=j.useState(""),[a,o]=j.useState(null),[u,c]=j.useState(null),[p,g]=j.useState(null),[m,y]=j.useState(!1),x=j.useCallback(()=>{O.get(`/api/admin/stores/${e}/campaigns`).then(r).catch(d=>c(d.message))},[e]);if(j.useEffect(x,[x]),!n)return u?i.jsx("div",{className:"alert error",children:u}):i.jsx("p",{className:"muted",children:"Chargement…"});const w=l.trim(),S=!n.allowed||!!n.nextAllowedAt;async function f(){if(confirm(`Envoyer ce message aux ${n.audience.cards} cartes de ${t} ? +`;return typeof r=="function"&&r(null,m),m};const Ev=$g,oa=Sf,Df=If,kv=Ff;function ho(e,t,n,r,l){const s=[].slice.call(arguments,1),a=s.length,o=typeof s[a-1]=="function";if(!o&&!Ev())throw new Error("Callback required as last argument");if(o){if(a<2)throw new Error("Too few arguments provided");a===2?(l=n,n=t,t=r=void 0):a===3&&(t.getContext&&typeof l>"u"?(l=r,r=void 0):(l=r,r=n,n=t,t=void 0))}else{if(a<1)throw new Error("Too few arguments provided");return a===1?(n=t,t=r=void 0):a===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(u,c){try{const p=oa.create(n,r);u(e(p,t,r))}catch(p){c(p)}})}try{const u=oa.create(n,r);l(null,e(u,t,r))}catch(u){l(u)}}Dr.create=oa.create;Dr.toCanvas=ho.bind(null,Df.render);Dr.toDataURL=ho.bind(null,Df.renderToDataURL);Dr.toString=ho.bind(null,function(e,t,n){return kv.render(e,n)});const Pv={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}};function Of(e){const t=Pv[e.format],n=(e.rewards??[]).filter(c=>c.active!==!1&&c.label.trim()).sort((c,p)=>c.cost-p.cost),r=n.slice(0,t.maxRewards),l=e.pointsMode==="STAMP"?"tampons":"points",s=r.length?t.qrWithRewards:t.qr,[a,o]=j.useState("");j.useEffect(()=>{Dr.toString(e.url,{type:"svg",errorCorrectionLevel:"Q",margin:0,color:{dark:"#111111",light:"#FFFFFF"}}).then(o)},[e.url]);const u=c=>`${c}mm`;return i.jsxs("div",{className:"poster",style:{width:u(t.w),height:u(t.h),padding:u(t.pad),boxSizing:"border-box",background:e.backgroundColor,color:e.foregroundColor,fontFamily:"'Figtree', system-ui, sans-serif",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"space-between",textAlign:"center",overflow:"hidden",printColorAdjust:"exact",WebkitPrintColorAdjust:"exact"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:u(3)},children:[e.logoUrl&&i.jsx("img",{src:e.logoUrl,alt:"",style:{width:u(t.logo),height:u(t.logo),objectFit:"contain",borderRadius:u(2.5),background:"#fff"}}),i.jsx("span",{style:{fontSize:u(t.store),fontWeight:700},children:e.storeName})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:u(2.5)},children:[i.jsx("span",{style:{fontSize:u(t.eyebrow),fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:e.labelColor},children:e.programName}),i.jsx("span",{style:{fontSize:u(t.title),lineHeight:1.12,fontWeight:800,letterSpacing:"-0.02em",maxWidth:"92%"},children:"Scannez pour obtenir votre carte de fidélité"})]}),i.jsx("div",{role:"img","aria-label":"QR code d'inscription",style:{background:"#fff",borderRadius:u(3.5),padding:u(4),width:u(s),height:u(s),boxSizing:"content-box"},dangerouslySetInnerHTML:{__html:a}}),r.length>0&&i.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:u(1.6)},children:[i.jsx("span",{style:{fontSize:u(t.small),fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:e.labelColor},children:"Vos récompenses"}),i.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:u(1.2)},children:r.map(c=>i.jsxs("li",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:u(3),padding:`${u(1.4)} ${u(3)}`,borderRadius:u(2.5),background:"rgba(255,255,255,0.12)",fontSize:u(t.body),lineHeight:1.25},children:[i.jsx("span",{style:{fontWeight:700,textAlign:"left"},children:c.label}),i.jsxs("span",{style:{whiteSpace:"nowrap",color:e.labelColor,fontWeight:600},children:[c.cost," ",l]})]},`${c.label}-${c.cost}`))}),n.length>r.length&&i.jsxs("span",{style:{fontSize:u(t.small),color:e.labelColor},children:["et ",n.length-r.length," autre(s) à découvrir sur votre carte"]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:u(1.5)},children:[i.jsx("span",{style:{fontSize:u(t.body),lineHeight:1.4,fontWeight:600},children:"Ajoutez-la à Apple Wallet ou Google Wallet."}),i.jsx("span",{style:{fontSize:u(t.small),lineHeight:1.4,color:e.labelColor},children:"Gratuit, sans application à télécharger."})]})]})}function Uf(e){return new Promise((t,n)=>{const r=URL.createObjectURL(e),l=new Image;l.onload=()=>{URL.revokeObjectURL(r),t(l)},l.onerror=()=>n(new Error("Image illisible")),l.src=r})}function $f(e){return new Promise((t,n)=>e.toBlob(r=>r?t(r):n(new Error("Conversion impossible")),"image/png"))}async function Rv(e){const t=await Uf(e),n=1125,r=432,l=Math.max(n/t.width,r/t.height),s=n/l,a=r/l,o=Object.assign(document.createElement("canvas"),{width:n,height:r});return o.getContext("2d").drawImage(t,(t.width-s)/2,(t.height-a)/2,s,a,0,0,n,r),$f(o)}async function Tv(e){const t=await Uf(e),n=Math.min(1,480/Math.max(t.width,t.height)),r=Object.assign(document.createElement("canvas"),{width:Math.round(t.width*n),height:Math.round(t.height*n)});return r.getContext("2d").drawImage(t,0,0,r.width,r.height),$f(r)}async function Lv(e){const t=new Image;t.crossOrigin="anonymous",t.src=e;try{await t.decode()}catch{return null}const r=Object.assign(document.createElement("canvas"),{width:48,height:48}).getContext("2d");r.drawImage(t,0,0,48,48);let l;try{l=r.getImageData(0,0,48,48).data}catch{return null}const s=new Map;for(let u=0;u235&&p>235&&g>235)continue;const y=`${c>>5}${p>>5}${g>>5}`,x=s.get(y)??{n:0,r:0,g:0,b:0};s.set(y,{n:x.n+1,r:x.r+c,g:x.g+p,b:x.b+g})}const a=[...s.values()].sort((u,c)=>c.n-u.n)[0];if(!a)return null;const o=u=>Math.round(u/a.n).toString(16).padStart(2,"0");return`#${o(a.r)}${o(a.g)}${o(a.b)}`.toUpperCase()}function Fu(e,t){const n=s=>{const[a,o,u]=[1,3,5].map(c=>{const p=parseInt(s.slice(c,c+2),16)/255;return p<=.03928?p/12.92:((p+.055)/1.055)**2.4});return .2126*a+.7152*o+.0722*u},[r,l]=[n(e),n(t)].sort((s,a)=>a-s);return(r+.05)/(l+.05)}const ni=["Identité","Couleurs","Règle de points","Récompenses","Récapitulatif"],Av=[["Ardoise","#1F2937","#FFFFFF","#D1D5DB"],["Émeraude","#0E7A66","#FFFFFF","#CDEDE4"],["Brique","#A64B17","#FFF4E4","#F7D58B"],["Marine","#1E3A5F","#FFFFFF","#BFD3EA"],["Prune","#5B2245","#FFFFFF","#E9C6DA"],["Crème","#FFF8EC","#3B2A1A","#8A6A4A"]],Mv=["Café offert","Viennoiserie offerte","Dessert offert","-10 % sur le prochain achat"];function _v(e){return{programName:`Fidélité ${e.name}`.slice(0,40),backgroundColor:"#1F2937",foregroundColor:"#FFFFFF",labelColor:"#D1D5DB",pointsMode:"AMOUNT",pointsPerEuro:1,rewards:[]}}function Bf({store:e,onSaved:t,base:n=`/api/admin/stores/${e.id}/card-design`,posterHref:r=`/magasins/${e.id}/affichette`,draftNote:l}){const[s,a]=j.useState(0),[o,u]=j.useState(null),[c,p]=j.useState({logoUrl:null,stripUrl:null}),[g,m]=j.useState(!1),[y,x]=j.useState("apple"),[w,S]=j.useState(null),[f,d]=j.useState(!1),[h,v]=j.useState(null);function N(L){const{logoUrl:W,stripUrl:se,...Ae}=L;u(Ae),p({logoUrl:na(W),stripUrl:na(se)}),m(!0)}if(j.useEffect(()=>{O.get(n).then(L=>L?N(L):u(_v(e))).catch(L=>S(L.message))},[n,e]),j.useEffect(()=>{c.logoUrl&&Lv(c.logoUrl).then(v)},[c.logoUrl]),!o)return w?i.jsx("div",{className:"alert error",children:w}):i.jsx("p",{className:"muted",children:"Chargement…"});const E=(L,W)=>u({...o,[L]:W});async function k(){S(null),d(!0);try{const{programName:L,backgroundColor:W,foregroundColor:se,labelColor:Ae,pointsMode:Ze,pointsPerEuro:R}=o,_=o.rewards.map(({id:z,label:H,cost:Z,active:nn})=>({id:z,label:H,cost:Z,active:nn}));return N(await O.put(n,{programName:L,backgroundColor:W,foregroundColor:se,labelColor:Ae,pointsMode:Ze,pointsPerEuro:R,rewards:_})),t(),!0}catch(L){return S(L.message),!1}finally{d(!1)}}async function C(){await k()&&a(L=>Math.min(L+1,ni.length-1))}async function M(L,W){var Ae;const se=(Ae=W.target.files)==null?void 0:Ae[0];if(W.target.value="",!!se&&!(!g&&!await k())){d(!0),S(null);try{const Ze=L==="logo"?await Tv(se):await Rv(se),R=new FormData;R.append("file",Ze,`${L}.png`),N(await O.post(`${n}/images/${L}`,R))}catch(Ze){S(Ze.message)}finally{d(!1)}}}const A={...o,...c,storeName:e.name},U=Fu(o.backgroundColor,o.foregroundColor),Le=Fu(o.backgroundColor,o.labelColor);return i.jsxs("div",{className:"wizard",children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[i.jsx("ol",{className:"steps","aria-label":"Étapes",children:ni.map((L,W)=>i.jsx("li",{children:i.jsxs("button",{type:"button","aria-current":W===s?"step":void 0,className:Wa(W),children:[i.jsx("span",{className:"n",children:WE("programName",L.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("span",{style:{fontWeight:600},children:"Logo"}),i.jsxs("div",{className:"upload-drop",children:[c.logoUrl&&i.jsx("img",{src:c.logoUrl,alt:"Logo actuel"}),i.jsxs("label",{className:"btn secondary small",children:[c.logoUrl?"Remplacer":"Choisir un fichier",i.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",onChange:L=>M("logo",L),disabled:f})]}),i.jsx("span",{className:"hint",children:"PNG carré conseillé, fond transparent."})]})]}),i.jsxs("div",{className:"field",children:[i.jsx("span",{style:{fontWeight:600},children:"Bandeau"}),i.jsxs("div",{className:"upload-drop",children:[c.stripUrl&&i.jsx("img",{src:c.stripUrl,alt:"Bandeau actuel"}),i.jsxs("label",{className:"btn secondary small",children:[c.stripUrl?"Remplacer":"Choisir un fichier",i.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",onChange:L=>M("strip",L),disabled:f})]}),i.jsx("span",{className:"hint",children:"Recadré automatiquement au format Wallet (1125 × 432)."})]})]})]}),s===1&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Couleurs"}),i.jsxs("div",{className:"field",children:[i.jsx("span",{style:{fontWeight:600},children:"Palettes prêtes à l’emploi"}),i.jsx("div",{className:"palettes",children:Av.map(([L,W,se,Ae])=>i.jsxs("button",{type:"button",className:"palette","aria-pressed":o.backgroundColor===W&&o.foregroundColor===se,onClick:()=>u({...o,backgroundColor:W,foregroundColor:se,labelColor:Ae}),children:[i.jsx("span",{style:{background:W,color:se},children:"Aa"}),L]},L))})]}),h&&h!==o.backgroundColor&&i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("span",{style:{width:28,height:28,borderRadius:8,background:h,border:"1px solid var(--border)"}}),i.jsxs("span",{children:["Couleur extraite du logo : ",h]}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>E("backgroundColor",h),children:"Utiliser comme fond"})]}),[["backgroundColor","Fond"],["foregroundColor","Texte"],["labelColor","Libellés"]].map(([L,W])=>i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:L,children:W}),i.jsxs("div",{className:"color-row",children:[i.jsx("input",{type:"color","aria-label":`${W} (sélecteur)`,value:o[L],onChange:se=>E(L,se.target.value.toUpperCase())}),i.jsx("input",{id:L,className:"input",style:{maxWidth:160},value:o[L],pattern:"#[0-9A-Fa-f]{6}",onChange:se=>E(L,se.target.value)})]})]},L)),U<4.5&&i.jsxs("div",{className:"alert warn",children:["Contraste texte/fond insuffisant (",U.toFixed(1),":1, minimum 4,5:1) : le solde sera difficile à lire."]}),Le<3&&i.jsxs("div",{className:"alert warn",children:["Contraste libellés/fond faible (",Le.toFixed(1),":1, minimum conseillé 3:1)."]})]}),s===2&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Règle de points"}),i.jsxs("div",{className:"mode-cards",role:"radiogroup",children:[i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"mode",checked:o.pointsMode==="AMOUNT",onChange:()=>E("pointsMode","AMOUNT")}),i.jsxs("span",{children:[i.jsx("strong",{children:"Points selon le montant"}),i.jsx("br",{}),i.jsx("span",{className:"muted",children:"X points par euro dépensé"})]})]}),i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"mode",checked:o.pointsMode==="STAMP",onChange:()=>E("pointsMode","STAMP")}),i.jsxs("span",{children:[i.jsx("strong",{children:"Tampons"}),i.jsx("br",{}),i.jsx("span",{className:"muted",children:"1 tampon par passage"})]})]})]}),o.pointsMode==="AMOUNT"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"ppe",children:"Points par euro *"}),i.jsx("input",{id:"ppe",className:"input",type:"number",step:"0.01",min:.01,max:100,style:{maxWidth:160},value:o.pointsPerEuro,onChange:L=>E("pointsPerEuro",Number(L.target.value))})]}),i.jsxs("p",{className:"muted",style:{margin:0},children:["Exemple : un panier de 23,50 € = ",i.jsxs("strong",{children:[Math.floor(23.5*o.pointsPerEuro)," points"]})," (arrondi à l'inférieur)."]})]}):i.jsx("p",{className:"muted",style:{margin:0},children:"Chaque passage validé par un employé ajoute un tampon, quel que soit le montant."})]}),s===3&&i.jsx(zv,{rewards:o.rewards,unit:o.pointsMode==="STAMP"?"tampons":"points",onChange:L=>E("rewards",L)}),s===4&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Récapitulatif"}),i.jsxs("ul",{style:{margin:0,paddingLeft:20,lineHeight:1.8},children:[i.jsxs("li",{children:["Programme : ",i.jsx("strong",{children:o.programName})]}),i.jsxs("li",{children:["Règle : ",o.pointsMode==="STAMP"?"1 tampon par passage":`${o.pointsPerEuro} point(s) par euro`]}),i.jsxs("li",{children:["Récompenses : ",o.rewards.filter(L=>L.active!==!1).map(L=>`${L.label} (${L.cost})`).join(", ")||"aucune"]}),i.jsxs("li",{children:["Logo : ",c.logoUrl?"oui":i.jsx("span",{style:{color:"var(--warn)"},children:"manquant"})," · Bandeau : ",c.stripUrl?"oui":"non"]})]}),i.jsx("h3",{style:{margin:"8px 0 0"},children:"Affichette du comptoir"}),i.jsxs("div",{style:{display:"flex",gap:24,flexWrap:"wrap",alignItems:"flex-start"},children:[i.jsx("div",{style:{width:222,height:315,overflow:"hidden",borderRadius:8,boxShadow:"0 4px 16px rgb(0 0 0 / 0.15)"},children:i.jsx("div",{style:{transform:"scale(0.4)",transformOrigin:"top left"},children:i.jsx(Of,{format:"A5",url:e.enrollUrl,storeName:e.name,programName:o.programName,logoUrl:c.logoUrl,backgroundColor:o.backgroundColor,foregroundColor:o.foregroundColor,labelColor:o.labelColor,rewards:o.rewards,pointsMode:o.pointsMode})})}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,flex:"1 1 220px"},children:[i.jsx("p",{style:{margin:0},children:"Le QR mène à la page d'inscription :"}),i.jsx("a",{href:e.enrollUrl,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:e.enrollUrl}),i.jsx(Ee,{to:r,className:"btn secondary",children:"Imprimer l'affichette (A5 / A6)"})]})]}),e.status==="DRAFT"&&(l??i.jsxs("p",{style:{margin:0},children:["Le programme s'ouvre automatiquement dès que l'abonnement est payé. Sinon, utilisez le bouton ",i.jsx("strong",{children:"Activer"})," en haut de la fiche."]}))]}),i.jsxs("div",{className:"row between",children:[i.jsx("button",{type:"button",className:"btn secondary",disabled:s===0,onClick:()=>a(s-1),children:"Précédent"}),sx("apple"),children:"Apple Wallet"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":y==="google",onClick:()=>x("google"),children:"Google Wallet"})]}),y==="apple"?i.jsx(Og,{d:A}):i.jsx(Ug,{d:A}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Aperçu indicatif — QR et solde fictifs."})]})]})}function zv({rewards:e,unit:t,onChange:n}){const r=(l,s)=>n(e.map((a,o)=>o===l?{...a,...s}:a));return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Récompenses"}),e.length===0&&i.jsxs("div",{className:"field",children:[i.jsx("p",{className:"muted",style:{margin:0},children:"Aucune récompense pour l’instant. Ajoutez-en une, ou partez d’une idée :"}),i.jsx("div",{className:"row",style:{gap:8},children:Mv.map(l=>i.jsxs("button",{type:"button",className:"chip",onClick:()=>n([...e,{label:l,cost:10}]),children:["+ ",l]},l))})]}),e.map((l,s)=>i.jsxs("div",{className:"row",style:{alignItems:"flex-end",opacity:l.active===!1?.6:1},children:[i.jsxs("div",{className:"field",style:{flex:"1 1 240px"},children:[i.jsx("label",{htmlFor:`rw-label-${s}`,children:"Libellé"}),i.jsx("input",{id:`rw-label-${s}`,className:"input",maxLength:60,value:l.label,onChange:a=>r(s,{label:a.target.value})})]}),i.jsxs("div",{className:"field",style:{width:140},children:[i.jsxs("label",{htmlFor:`rw-cost-${s}`,children:["Coût (",t,")"]}),i.jsx("input",{id:`rw-cost-${s}`,className:"input",type:"number",min:1,value:l.cost,onChange:a=>r(s,{cost:Number(a.target.value)})})]}),l.active===!1?i.jsx("button",{type:"button",className:"btn secondary",onClick:()=>r(s,{active:!0}),children:"Réactiver"}):i.jsx("button",{type:"button",className:"btn secondary","aria-label":`Retirer ${l.label||"la récompense"}`,onClick:()=>n(e.filter((a,o)=>o!==s)),children:"Retirer"})]},l.id??`new-${s}`)),i.jsx("div",{children:i.jsx("button",{type:"button",className:"btn secondary",disabled:e.length>=20,onClick:()=>n([...e,{label:"",cost:10}]),children:"+ Ajouter une récompense"})})]})}const ua={MANAGER:"Dirigeant",EMPLOYEE:"Employé"};function Iv({storeId:e}){const t=`/api/admin/stores/${e}/staff`,[n,r]=j.useState([]),[l,s]=j.useState(null),[a,o]=j.useState(null),u=j.useRef(null),c=j.useRef(null),p=j.useCallback(()=>{O.get(t).then(r).catch(d=>s(d.message))},[t]);j.useEffect(p,[p]);function g(d,h,v){var N;o({name:d,email:h,reset:v}),(N=c.current)==null||N.showModal(),p()}async function m(d){try{await O.patch(`${t}/${d.id}`,{active:!d.active}),p()}catch(h){s(h.message)}}async function y(d){if(window.confirm(`Envoyer à ${d.displayName} (${d.email}) un lien pour choisir un nouveau mot de passe ?`))try{const h=await O.post(`${t}/${d.id}/reset-password`);g(d.displayName,h.invitationSentTo,!0)}catch(h){s(h.message)}}async function x(d){const h=d.role==="MANAGER"?"EMPLOYEE":"MANAGER";if(window.confirm(`${d.displayName} devient ${ua[h]}. Ses sessions ouvertes seront fermées.`))try{await O.patch(`${t}/${d.id}`,{role:h}),p()}catch(v){s(v.message)}}const w=n.filter(d=>d.active),S=w.filter(d=>d.role==="MANAGER").length,f=[...n].sort((d,h)=>Number(h.active)-Number(d.active)||d.role.localeCompare(h.role)||d.displayName.localeCompare(h.displayName));return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Employés"}),i.jsxs("p",{className:"muted",style:{margin:0},children:[w.length," compte",w.length>1?"s":""," actif",w.length>1?"s":""," · ",S," dirigeant",S>1?"s":""]})]}),i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=u.current)==null?void 0:d.showModal()},children:"+ Nouvel employé"})]}),l&&i.jsx("div",{className:"alert error",role:"alert",children:l}),n.length>0&&S===0&&i.jsx("div",{className:"alert warn",children:"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é."}),n.length===0?i.jsxs("section",{className:"card",style:{textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:40},children:[i.jsx("span",{className:"staff-avatar big","aria-hidden":"true",children:"👥"}),i.jsx("h3",{style:{margin:0},children:"Aucun compte pour l’instant"}),i.jsx("p",{className:"muted",style:{margin:0,maxWidth:420},children:"Créez au moins un Dirigeant : il pourra ensuite ajouter lui-même son équipe depuis l’app MonEspacePro."}),i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=u.current)==null?void 0:d.showModal()},children:"Créer le premier compte"})]}):i.jsx("div",{className:"staff-grid",children:f.map(d=>i.jsxs("article",{className:`card staff-card${d.active?"":" off"}`,children:[i.jsxs("div",{className:"row",style:{gap:12,flexWrap:"nowrap"},children:[i.jsx("span",{className:`staff-avatar${d.role==="MANAGER"?" mgr":""}`,"aria-hidden":"true",children:d.displayName.charAt(0).toUpperCase()}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("strong",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.displayName}),i.jsx("span",{className:"muted",style:{fontSize:14,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.email})]})]}),i.jsxs("div",{className:"row",style:{gap:6},children:[i.jsx("span",{className:`role-pill${d.role==="MANAGER"?" mgr":""}`,children:ua[d.role]}),d.active?i.jsx("span",{className:"badge ACTIVE",children:"Actif"}):i.jsx("span",{className:"badge DRAFT",children:"Désactivé"}),i.jsxs("span",{className:"muted",style:{fontSize:13},children:["depuis le ",new Date(d.createdAt).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"})]})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("button",{className:"btn secondary small",onClick:()=>x(d),children:d.role==="MANAGER"?"Passer Employé":"Passer Dirigeant"}),i.jsx("button",{className:"btn secondary small",onClick:()=>y(d),children:"Envoyer un lien de mot de passe"}),i.jsx("button",{className:"btn secondary small",onClick:()=>m(d),children:d.active?"Désactiver":"Réactiver"})]})]},d.id))}),i.jsx("dialog",{ref:u,"aria-labelledby":"new-staff-title",children:i.jsx(Fv,{base:t,onCancel:()=>{var d;return(d=u.current)==null?void 0:d.close()},onCreated:d=>{var h;(h=u.current)==null||h.close(),g(d.displayName,d.invitationSentTo??null,!1)}})}),i.jsx("dialog",{ref:c,"aria-labelledby":"sent-title",children:i.jsxs("div",{className:"dialog-body",children:[i.jsx("h2",{id:"sent-title",children:a!=null&&a.email?a.reset?"Lien envoyé":"Compte créé":"Compte créé, e-mail non envoyé"}),a!=null&&a.email?i.jsxs("p",{style:{margin:0},children:[i.jsx("strong",{children:a.name})," a reçu à ",i.jsx("strong",{children:a.email})," un lien pour choisir ",a.reset?"un nouveau":"son"," mot de passe (valable 7 jours, utilisable une fois)."]}):i.jsxs("div",{className:"alert warn",style:{margin:0},children:["L’e-mail d’invitation n’a pas pu partir. Utilisez « Envoyer un lien de mot de passe » sur la fiche de ",a==null?void 0:a.name," pour réessayer."]}),i.jsx("div",{className:"row",style:{justifyContent:"flex-end"},children:i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=c.current)==null?void 0:d.close()},children:"OK"})})]})})]})}function Fv({base:e,onCancel:t,onCreated:n}){const[r,l]=j.useState(""),[s,a]=j.useState(""),[o,u]=j.useState("EMPLOYEE"),[c,p]=j.useState(null),[g,m]=j.useState(!1);async function y(x){x.preventDefault(),m(!0),p(null);try{n(await O.post(e,{displayName:r,email:s,role:o})),l(""),a(""),u("EMPLOYEE")}catch(w){p(w.message)}finally{m(!1)}}return i.jsxs("form",{className:"dialog-body",onSubmit:y,children:[i.jsx("h2",{id:"new-staff-title",children:"Nouvel employé"}),c&&i.jsx("div",{className:"alert error",role:"alert",children:c}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"staff-name",children:"Prénom et nom *"}),i.jsx("input",{id:"staff-name",className:"input",required:!0,placeholder:"Prénom Nom",value:r,onChange:x=>l(x.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"staff-email",children:"E-mail *"}),i.jsx("input",{id:"staff-email",className:"input",type:"email",required:!0,placeholder:"prenom@exemple.fr",value:s,onChange:x=>a(x.target.value)})]}),i.jsxs("fieldset",{style:{border:0,padding:0,margin:0},className:"field",children:[i.jsx("legend",{style:{fontWeight:600,marginBottom:6},children:"Rôle *"}),i.jsx("div",{className:"mode-cards",children:["EMPLOYEE","MANAGER"].map(x=>i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"role",checked:o===x,onChange:()=>u(x)}),i.jsxs("span",{children:[i.jsx("strong",{children:ua[x]}),i.jsx("br",{}),i.jsx("span",{className:"muted",style:{fontSize:14},children:x==="MANAGER"?"Toute la configuration : carte, modules, campagnes, employés, statistiques":"Scanne les cartes et crédite les points, voit ses opérations"})]})]},x))})]}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"La personne recevra un e-mail pour choisir son mot de passe."}),i.jsxs("div",{className:"row",style:{justifyContent:"flex-end"},children:[i.jsx("button",{type:"button",className:"btn secondary",onClick:t,children:"Annuler"}),i.jsx("button",{className:"btn",disabled:g,children:"Créer le compte"})]})]})}const Du={ACTIVE:["Actif","ACTIVE"],INCOMPLETE:["En attente de paiement","DRAFT"],PAST_DUE:["Impayé","SUSPENDED"],CANCELED:["Résilié","CLOSED"]},Dv={multiStore:"Carte commune à plusieurs magasins"},sl=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),ln=e=>new Date(e).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"});function Ov({storeId:e,contactEmail:t,onChange:n}){const[r,l]=j.useState(null),[s,a]=j.useState(null),[o,u]=j.useState(null),[c,p]=j.useState(!1),[g,m]=j.useState(null),[y,x]=j.useState(null),w=j.useCallback(()=>{O.get(`/api/admin/stores/${e}/billing`).then(l).catch(C=>a(C.message))},[e]);j.useEffect(w,[w]);async function S(C,M,A){p(!0),a(null);try{const U=await O.post(M,A);u({...U,label:C}),w(),n()}catch(U){a(U.message)}finally{p(!1)}}if(!r)return s?i.jsx("div",{className:"alert error",children:s}):i.jsx("p",{className:"muted",children:"Chargement…"});const f=r.subscription,d=f&&f.status!=="CANCELED"&&f.hasSubscription?r.catalog.find(C=>C.plan===f.plan):null,h=!d,v=g??(f==null?void 0:f.plan)??"PRO",N=y??(f==null?void 0:f.interval)??"MONTH",E=r.invoices.filter(C=>C.paidAt).reduce((C,M)=>C+M.amountCents,0),k=r.invoices.filter(C=>!C.paidAt).length;return i.jsxs(i.Fragment,{children:[r.testMode&&i.jsx("div",{className:"alert warn",children:"Stripe est en mode test : aucun paiement réel n'est encaissé (carte de test 4242 4242 4242 4242)."}),s&&i.jsx("div",{className:"alert error",role:"alert",children:s}),i.jsxs("div",{className:"kpis",children:[i.jsxs("div",{className:`kpi${d?" ok":""}`,children:[i.jsx("b",{children:d?d.name:"—"}),i.jsx("span",{children:d?`formule ${f.interval==="YEAR"?"annuelle":"mensuelle"}`:(f==null?void 0:f.status)==="INCOMPLETE"?`en attente · ${qe[f.plan]} choisie`:"aucune formule"})]}),i.jsxs("div",{className:"kpi",children:[i.jsx("b",{children:d?sl(d.priceCents[f.interval]):"—"}),i.jsx("span",{children:d?`par ${f.interval==="YEAR"?"an":"mois"}`:"montant"})]}),i.jsxs("div",{className:`kpi${f!=null&&f.cancelAtPeriodEnd?" warn":""}`,children:[i.jsx("b",{style:{fontSize:20,lineHeight:"34px"},children:f!=null&&f.currentPeriodEnd&&f.status==="ACTIVE"?ln(f.currentPeriodEnd):"—"}),i.jsx("span",{children:f!=null&&f.cancelAtPeriodEnd?"fin de l’abonnement":"prochain prélèvement"})]}),i.jsxs("div",{className:`kpi${k?" err":""}`,children:[i.jsx("b",{children:sl(E)}),i.jsxs("span",{children:[r.invoices.length," facture",r.invoices.length>1?"s":"",k?` · ${k} impayée${k>1?"s":""}`:" · tout est réglé"]})]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Abonnement"}),i.jsx("p",{className:"muted",style:{margin:0},children:d?`Formule ${d.name}${f.legacyPrice?" (tarif fondateur)":""} — ${f.interval==="YEAR"?"annuelle":"mensuelle"}`:"Aucune formule souscrite. Sans abonnement actif, le magasin a les droits de la formule Essentiel."})]}),i.jsx("span",{className:`badge ${f?Du[f.status][1]:"DRAFT"}`,children:f?Du[f.status][0]:"Aucun abonnement"})]}),(f==null?void 0:f.cancelAtPeriodEnd)&&f.currentPeriodEnd&&i.jsxs("div",{className:"alert warn",children:["Résiliation demandée : l'abonnement s'arrête le ",i.jsx("strong",{children:ln(f.currentPeriodEnd)}),"."]}),(f==null?void 0:f.currentPeriodEnd)&&f.status==="ACTIVE"&&!f.cancelAtPeriodEnd&&i.jsxs("p",{style:{margin:0},children:["Prochain prélèvement le ",i.jsx("strong",{children:ln(f.currentPeriodEnd)}),"."]}),r.billingSuspended&&i.jsx("div",{className:"alert warn",children:"Magasin suspendu automatiquement pour impayé. Il sera réactivé dès que le paiement passera."}),d&&i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsxs("button",{className:"btn",disabled:c,onClick:()=>S("Espace abonnement",`/api/admin/stores/${e}/billing/portal-link`,{sendEmail:!0}),children:["Envoyer l'espace abonnement à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>S("Espace abonnement",`/api/admin/stores/${e}/billing/portal-link`,{sendEmail:!1}),children:"Ouvrir l'espace abonnement"}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Changer de formule, de moyen de paiement, résilier."})]})]}),h&&i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[i.jsxs("div",{className:"row between",children:[i.jsx("h2",{children:"Choisir une formule"}),i.jsxs("div",{role:"group","aria-label":"Périodicité",className:"row",style:{gap:8},children:[i.jsx("button",{type:"button",className:"chip","aria-pressed":N==="MONTH",onClick:()=>x("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":N==="YEAR",onClick:()=>x("YEAR"),children:"Annuel — 2 mois offerts"})]})]}),i.jsx("div",{className:"mode-cards",role:"radiogroup","aria-label":"Formule",children:r.catalog.map(C=>i.jsxs("label",{className:"mode-card",style:{flexDirection:"column",gap:8},children:[i.jsxs("span",{className:"row",style:{gap:10},children:[i.jsx("input",{type:"radio",name:"plan",checked:v===C.plan,onChange:()=>m(C.plan)}),i.jsx("strong",{style:{fontSize:18},children:C.name}),C.plan==="PRO"&&i.jsx("span",{className:"badge ACTIVE",style:{height:22},children:"Conseillée"})]}),i.jsxs("span",{style:{fontSize:24,fontWeight:800},children:[sl(C.priceCents[N]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",N==="YEAR"?"an":"mois",C.plan==="RESEAU"?" / magasin":""]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:C.tagline}),i.jsxs("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:[i.jsx("li",{children:C.limits.maxStaff?`${C.limits.maxStaff} employés`:"Employés illimités"}),i.jsx("li",{children:"Carte Wallet, points ou tampons, récompenses, mises à jour en direct"}),C.features.map(M=>i.jsx("li",{children:Dv[M]??M},M))]}),i.jsx("span",{style:{fontSize:14,fontWeight:700},children:C.modules.length?`Modules inclus (${C.modules.length})`:"Aucun module inclus"}),C.modules.length>0&&i.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:C.modules.map(M=>i.jsx("li",{title:M.tagline,children:M.name},M.id))})]},C.plan))}),i.jsxs("div",{className:"copy-line",style:{flexWrap:"wrap"},children:[i.jsx("span",{className:"muted",children:"Lien de paiement permanent :"}),i.jsx("code",{children:r.subscribeUrl}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>{var C;return(C=navigator.clipboard)==null?void 0:C.writeText(r.subscribeUrl)},children:"Copier"})]}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Il ne périme pas. Le commerçant peut saisir un code promo sur la page de paiement (codes à créer dans Stripe → Coupons)."}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsxs("button",{className:"btn",disabled:c,onClick:()=>S("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:v,interval:N,sendEmail:!0}),children:["Envoyer le lien à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>S("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:v,interval:N,sendEmail:!1}),children:"Enregistrer la formule sans envoyer"})]})]}),o&&i.jsxs("div",{className:"alert ok",children:[o.label," ",o.emailedTo?i.jsxs(i.Fragment,{children:["envoyé à ",i.jsx("strong",{children:o.emailedTo}),". "]}):"créé. ",i.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:o.url})]}),i.jsxs("div",{className:"row between",style:{marginTop:8},children:[i.jsx("h2",{children:"Factures"}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Émises et envoyées automatiquement à chaque paiement."})]}),i.jsxs("div",{className:"table-wrap",children:[i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{minWidth:720},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",style:{paddingLeft:24},children:"Facture"}),i.jsx("th",{scope:"col",children:"Objet"}),i.jsx("th",{scope:"col",children:"Période"}),i.jsx("th",{scope:"col",className:"num",children:"Montant"}),i.jsx("th",{scope:"col",children:"Statut"}),i.jsx("th",{scope:"col",children:i.jsx("span",{className:"sr-only",children:"PDF"})})]})}),i.jsx("tbody",{children:r.invoices.map(C=>i.jsxs("tr",{children:[i.jsx("td",{style:{paddingLeft:24,fontWeight:600},children:C.number}),i.jsx("td",{style:{fontSize:14},children:C.description.replace("Abonnement MonEspacePro — ","")}),i.jsxs("td",{children:[ln(C.periodStart)," → ",ln(C.periodEnd)]}),i.jsx("td",{className:"num",children:sl(C.amountCents)}),i.jsx("td",{children:C.paidAt?i.jsxs("span",{className:"badge ACTIVE",children:["Payée le ",ln(C.paidAt)]}):i.jsx("span",{className:"badge SUSPENDED",children:"Impayée"})}),i.jsx("td",{style:{textAlign:"right",paddingRight:24},children:i.jsx("button",{className:"btn secondary small",onClick:()=>la(`/api/admin/invoices/${C.id}/pdf`,`${C.number}.pdf`).catch(M=>a(M.message)),children:"PDF"})})]},C.id))})]})}),r.invoices.length===0&&i.jsx("p",{className:"muted",style:{padding:24,margin:0,textAlign:"center"},children:"Aucune facture pour l'instant. Elles sont créées automatiquement à chaque paiement."})]})]})}const Ou=e=>new Date(e).toLocaleString("fr-FR",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"});function Uv({storeId:e,storeName:t}){const[n,r]=j.useState(null),[l,s]=j.useState(""),[a,o]=j.useState(null),[u,c]=j.useState(null),[p,g]=j.useState(null),[m,y]=j.useState(!1),x=j.useCallback(()=>{O.get(`/api/admin/stores/${e}/campaigns`).then(r).catch(d=>c(d.message))},[e]);if(j.useEffect(x,[x]),!n)return u?i.jsx("div",{className:"alert error",children:u}):i.jsx("p",{className:"muted",children:"Chargement…"});const w=l.trim(),S=!n.allowed||!!n.nextAllowedAt;async function f(){if(confirm(`Envoyer ce message aux ${n.audience.cards} cartes de ${t} ? « ${w} »`)){y(!0),c(null);try{await O.post(`/api/admin/stores/${e}/campaigns`,{message:w,title:(a??n.defaultTitle).trim()}),s(""),g("Campagne envoyée. Les cartes se mettent à jour dans les minutes qui suivent."),x()}catch(d){c(d.message)}finally{y(!1)}}}return i.jsxs(i.Fragment,{children:[u&&i.jsx("div",{className:"alert error",role:"alert",children:u}),p&&i.jsx("div",{className:"alert ok",role:"status",children:p}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Nouvelle campagne"}),i.jsxs("p",{className:"muted",style:{margin:0},children:["Le message apparaît en notification sur le téléphone des clients et reste visible sur leur carte. Audience : ",i.jsx("strong",{children:n.audience.cards})," cartes, dont ",i.jsx("strong",{children:n.audience.appleDevices})," iPhone joignables (Google Wallet : tous les clients qui ont ajouté la carte)."]})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"campaign-title",children:"Titre de la notification"}),i.jsx("input",{id:"campaign-title",className:"input",maxLength:40,value:a??n.defaultTitle,onChange:d=>o(d.target.value),disabled:S||m}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Affiché sur Google Wallet. Sur iPhone, le nom du magasin apparaît toujours en titre."})]}),i.jsx("label",{htmlFor:"campaign-msg",children:"Message"}),i.jsx("textarea",{id:"campaign-msg",className:"input",rows:3,maxLength:n.maxLength,placeholder:"Ex. : -20 % sur les viennoiseries ce samedi, sur présentation de votre carte !",value:l,onChange:d=>s(d.target.value),disabled:S||m}),i.jsxs("div",{className:"row between",children:[i.jsxs("span",{className:"muted",style:{fontSize:14},children:[w.length," / ",n.maxLength," caractères · 1 campagne toutes les ",n.minIntervalHours," h maximum"]}),i.jsx("button",{className:"btn",disabled:S||m||w.length<5,onClick:f,children:m?"Envoi…":"Envoyer la campagne"})]}),n.nextAllowedAt&&i.jsxs("div",{className:"alert warn",children:["Prochain envoi possible le ",Ou(n.nextAllowedAt),"."]})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Historique"}),n.items.length===0?i.jsx("p",{className:"muted",style:{margin:0},children:"Aucune campagne envoyée pour l'instant."}):i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",children:"Date"}),i.jsx("th",{scope:"col",children:"Message"}),i.jsx("th",{scope:"col",children:"Envoyée par"}),i.jsx("th",{scope:"col",className:"num",children:"Cartes"})]})}),i.jsx("tbody",{children:n.items.map(d=>i.jsxs("tr",{children:[i.jsx("td",{className:"muted",style:{whiteSpace:"nowrap"},children:Ou(d.createdAt)}),i.jsxs("td",{children:[d.title&&i.jsxs("strong",{children:[d.title," · "]}),d.message]}),i.jsx("td",{children:d.sentByName}),i.jsx("td",{className:"num",children:d.cards})]},d.id))})]})})]})]})}const $v={campaigns:"📣",reminders:"⏰",birthday:"🎂",reviews:"⭐",referral:"🤝",stats:"📊",whiteLabel:"🏷️"},Uu=e=>e.type==="text"||e.type==="textarea";function Bv({m:e}){const[t,n]=e.override===!0?["Ajouté sur mesure","ACTIVE"]:e.override===!1?["Retiré","CLOSED"]:e.inPlan?["Inclus dans la formule","ACTIVE"]:["Non inclus","DRAFT"];return i.jsx("span",{className:`badge ${n}`,children:t})}function bv({f:e,value:t,onChange:n}){var o;const r=`f-${e.key}`,l=i.jsxs(i.Fragment,{children:[e.help&&i.jsxs("span",{className:"muted",style:{fontSize:14},children:[e.help," "]}),"variables"in e&&((o=e.variables)!=null&&o.length)?i.jsxs("span",{className:"muted",style:{fontSize:14},children:["Variables : ",e.variables.map(u=>i.jsx("code",{style:{marginRight:6},children:u},u))]}):null]});if(e.type==="boolean")return i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontWeight:600},children:[i.jsx("input",{type:"checkbox",checked:!!t,onChange:u=>n(u.target.checked)}),e.label,e.help&&i.jsxs("span",{className:"muted",style:{fontWeight:400,fontSize:14},children:["— ",e.help]})]});if(e.type==="int"||e.type==="hour")return i.jsxs("div",{children:[i.jsx("label",{htmlFor:r,style:{fontWeight:600},children:e.label}),i.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[i.jsx("input",{id:r,className:"input",type:"number",style:{width:120},min:e.min,max:e.max,value:Number(t),onChange:u=>n(Math.floor(Number(u.target.value)||0))}),i.jsx("span",{className:"muted",children:e.type==="hour"?"h":e.unit})]}),l]});const s=e,a=String(t??"");return i.jsxs("div",{children:[i.jsx("label",{htmlFor:r,style:{fontWeight:600},children:e.label}),s.type==="textarea"?i.jsx("textarea",{id:r,className:"input",rows:2,maxLength:s.maxLength,value:a,onChange:u=>n(u.target.value)}):i.jsx("input",{id:r,className:"input",type:s.type==="url"?"url":"text",maxLength:s.maxLength,value:a,onChange:u=>n(u.target.value)}),i.jsxs("div",{className:"row between",style:{gap:8},children:[i.jsx("span",{children:l}),i.jsxs("span",{className:"muted",style:{fontSize:13},children:[a.length," / ",s.maxLength]})]}),s.type!=="url"&&a!==s.default&&i.jsx("button",{type:"button",className:"link",style:{fontSize:14},onClick:()=>n(s.default),children:"Remettre le texte par défaut"})]})}function Wv({storeId:e,storeName:t,initial:n,onChanged:r}){const[l,s]=j.useState(n),[a,o]=j.useState(n.config),[u,c]=j.useState(!1),[p,g]=j.useState(!1),[m,y]=j.useState(null),[x,w]=j.useState(null),S=`/api/admin/stores/${e}/modules/${l.id}`,f=v=>{s(v),o(v.config)};j.useEffect(()=>{u&&O.get(S).then(f).catch(v=>y(v.message))},[u,S]);async function d(v,N){g(!0),y(null),w(null);try{f(await v()),w(N),r()}catch(E){y(E.message)}finally{g(!1)}}const h=JSON.stringify(a)!==JSON.stringify(l.config);return i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:14},children:[i.jsxs("div",{className:"row between",style:{alignItems:"flex-start",gap:12},children:[i.jsxs("div",{style:{flex:"1 1 320px",display:"flex",gap:14},children:[i.jsx("span",{className:`mod-ic${l.available&&l.config.enabled?" on":""}`,"aria-hidden":"true",children:$v[l.id]??"🧩"}),i.jsxs("div",{children:[i.jsxs("div",{className:"row",style:{gap:10,alignItems:"center"},children:[i.jsx("h2",{style:{margin:0},children:l.name}),i.jsx(Bv,{m:l})]}),i.jsx("p",{className:"muted",style:{margin:"6px 0 0"},children:l.description})]})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[l.available&&i.jsxs("label",{className:"switch",title:l.config.enabled?"Désactiver le module":"Activer le module",children:[i.jsx("input",{type:"checkbox",checked:l.config.enabled,disabled:p,onChange:v=>{const N=v.target.checked;d(()=>O.put(S,{enabled:N}),N?"Module activé.":"Module désactivé.")}}),i.jsx("span",{"aria-hidden":"true"}),i.jsx("span",{className:"sr-only",children:"Module activé"})]}),i.jsx("label",{className:"sr-only",htmlFor:`ov-${l.id}`,children:"Disponibilité du module"}),i.jsxs("select",{id:`ov-${l.id}`,className:"input",style:{width:"auto"},disabled:p,value:l.override===null?"plan":l.override?"add":"remove",onChange:v=>{const N=v.target.value==="plan"?null:v.target.value==="add";d(()=>O.put(`${S}/override`,{value:N}),N===null?"Module remis selon la formule.":N?"Module ajouté sur mesure.":"Module retiré.")},children:[i.jsxs("option",{value:"plan",children:["Selon la formule",l.inPlan?" (inclus)":" (non inclus)"]}),i.jsx("option",{value:"add",children:"Ajouter sur mesure"}),i.jsx("option",{value:"remove",children:"Retirer"})]}),i.jsx("button",{type:"button",className:"btn secondary",onClick:()=>c(!u),"aria-expanded":u,children:u?"Fermer":"Personnaliser"})]})]}),m&&i.jsx("div",{className:"alert error",role:"alert",children:m}),x&&i.jsx("div",{className:"alert ok",role:"status",children:x}),u&&i.jsxs(i.Fragment,{children:[!l.available&&i.jsx("div",{className:"alert warn",children:"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."}),l.stats&&i.jsx("div",{className:"kpis",children:Object.entries(l.stats).map(([v,N])=>i.jsxs("div",{className:"kpi",children:[i.jsx("b",{children:N??"—"}),i.jsx("span",{children:v})]},v))}),[["Réglages",l.fields.filter(v=>!Uu(v)),"mod-grid"],["Messages",l.fields.filter(Uu),"mod-stack"]].map(([v,N,E])=>N.length?i.jsxs("fieldset",{className:"mod-group",children:[i.jsx("legend",{children:v}),i.jsx("div",{className:E,children:N.map(k=>i.jsx(bv,{f:k,value:a[k.key],onChange:C=>o({...a,[k.key]:C})},k.key))})]},v):null),l.id==="stats"&&i.jsx(Ee,{to:"../statistiques",children:"Voir les statistiques du magasin →"}),i.jsxs("div",{className:`row mod-save${h?" dirty":""}`,style:{gap:8,justifyContent:"flex-end"},children:[h&&i.jsx("span",{className:"muted",style:{marginRight:"auto",fontSize:14},children:"Modifications non enregistrées"}),h&&i.jsx("button",{type:"button",className:"btn secondary",disabled:p,onClick:()=>o(l.config),children:"Annuler"}),i.jsx("button",{type:"button",className:"btn",disabled:p||!h,onClick:()=>d(()=>O.put(S,a),"Réglages enregistrés."),children:p?"Enregistrement…":"Enregistrer"})]}),l.id==="campaigns"&&l.available&&l.config.enabled&&i.jsx(Uv,{storeId:e,storeName:t})]})]})}function Vv({storeId:e,storeName:t}){const[n,r]=j.useState(null),[l,s]=j.useState(null),a=j.useCallback(()=>{O.get(`/api/admin/stores/${e}/modules`).then(r).catch(p=>s(p.message))},[e]);if(j.useEffect(a,[a]),!n)return l?i.jsx("div",{className:"alert error",children:l}):i.jsx("p",{className:"muted",children:"Chargement…"});const o=n.filter(p=>p.available&&p.config.enabled).length,u=n.filter(p=>p.available).length,c=n.filter(p=>p.override!==null).length;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"kpis",children:[i.jsxs("div",{className:"kpi ok",children:[i.jsx("b",{children:o}),i.jsx("span",{children:"modules activés"})]}),i.jsxs("div",{className:"kpi",children:[i.jsxs("b",{children:[u," / ",n.length]}),i.jsx("span",{children:"disponibles pour ce magasin"})]}),i.jsxs("div",{className:"kpi",children:[i.jsx("b",{children:c}),i.jsx("span",{children:"ajout(s) ou retrait(s) sur mesure"})]})]}),i.jsx("p",{className:"muted",style:{margin:0},children:"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, « Personnaliser » ouvre tous ses textes et réglages. Le dirigeant peut aussi les régler depuis l’app MonEspacePro."}),n.map(p=>i.jsx(Wv,{storeId:e,storeName:t,initial:p,onChanged:a},p.id))]})}const Hv=[[30,"30 jours"],[90,"3 mois"],[365,"12 mois"]],ri=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:e>=1e5?0:2}),sn=e=>e.toLocaleString("fr-FR");function Qv({value:e}){if(e===null)return null;const t=e>=0;return i.jsxs("span",{style:{fontSize:13,fontWeight:700,color:t?"var(--ok)":"var(--err)"},children:[t?"▲":"▼"," ",Math.abs(e).toLocaleString("fr-FR")," %"]})}function Bt({icon:e,label:t,value:n,hint:r,change:l}){return i.jsxs("div",{className:"card",style:{padding:16,display:"flex",flexDirection:"column",gap:4},children:[i.jsxs("span",{className:"muted",style:{fontSize:14,display:"flex",gap:8,alignItems:"center"},children:[i.jsx("span",{"aria-hidden":"true",children:e}),t]}),i.jsx("span",{style:{fontSize:26,fontWeight:800},children:n}),i.jsxs("span",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[l!==void 0&&i.jsx(Qv,{value:l}),r&&i.jsx("span",{className:"muted",style:{fontSize:13},children:r})]})]})}function Kv({series:e}){const t=Math.max(1,...e.map(l=>Math.max(l.visits,l.newCards))),n=100/e.length,r=Math.ceil(e.length/8);return i.jsxs("svg",{viewBox:"0 0 100 46",preserveAspectRatio:"none",style:{width:"100%",height:220},role:"img","aria-label":"Passages et nouvelles cartes sur la période",children:[e.map((l,s)=>i.jsxs("g",{children:[i.jsx("title",{children:`${l.label} : ${l.visits} passage(s), ${l.newCards} nouvelle(s) carte(s)`}),i.jsx("rect",{x:s*n+n*.1,y:40-l.visits/t*38,width:n*.45,height:l.visits/t*38,fill:"var(--primary)"}),i.jsx("rect",{x:s*n+n*.55,y:40-l.newCards/t*38,width:n*.35,height:l.newCards/t*38,fill:"var(--primary-soft)",stroke:"var(--primary)",strokeWidth:.1}),s%r===0&&i.jsx("text",{x:s*n+n/2,y:45,fontSize:2.2,textAnchor:"middle",fill:"currentColor",opacity:.6,children:l.label})]},s)),i.jsx("line",{x1:0,x2:100,y1:40,y2:40,stroke:"var(--border)",strokeWidth:.2})]})}function Yv({heat:e}){const t=Array.from({length:15},(r,l)=>l+7),n=Math.max(1,...e.values.flat());return i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{borderCollapse:"separate",borderSpacing:3,minWidth:560},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{}),t.map(r=>i.jsxs("th",{style:{fontSize:12,fontWeight:500,padding:0,textAlign:"center"},children:[r,"h"]},r))]})}),i.jsx("tbody",{children:e.weekdays.map((r,l)=>i.jsxs("tr",{children:[i.jsx("th",{scope:"row",style:{fontSize:13,fontWeight:600,padding:"0 8px 0 0"},children:r}),t.map(s=>{const a=e.values[l][s];return i.jsx("td",{title:`${r} ${s} h : ${a} passage(s)`,style:{padding:0,height:26,borderRadius:4,background:a?`color-mix(in srgb, var(--primary) ${Math.round(15+a/n*85)}%, transparent)`:"var(--surface-2)"}},s)})]},r))})]})})}function Gv({storeId:e,storeSlug:t}){const[n,r]=j.useState(30),[l,s]=j.useState(null),[a,o]=j.useState(null),[u,c]=j.useState(null);j.useEffect(()=>{o(null),O.get(`/api/admin/stores/${e}/stats?days=${n}`).then(s).catch(y=>o(y.message))},[e,n]);async function p(y){c(y);try{const x=new Date().toISOString().slice(0,10);y==="customers"?await la(`/api/admin/stores/${e}/export/customers`,`clients-${t}-${x}.csv`):await la(`/api/admin/stores/${e}/export/transactions?days=${n}`,`operations-${t}-${n}j-${x}.csv`)}catch(x){o(x.message)}finally{c(null)}}const g=l==null?void 0:l.kpis,m=(l==null?void 0:l.pointsMode)==="STAMP"?"tampons":"points";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",style:{alignItems:"center"},children:[i.jsx("div",{role:"group","aria-label":"Période",className:"s-seg",children:Hv.map(([y,x])=>i.jsx("button",{type:"button","aria-pressed":n===y,onClick:()=>r(y),children:x},y))}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>p("customers"),children:u==="customers"?"Export…":"📇 Clients (CSV)"}),i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>p("transactions"),children:u==="transactions"?"Export…":"🧾 Opérations (CSV)"})]})]}),a&&i.jsx("div",{className:"alert error",role:"alert",children:a}),l&&!l.allowed&&i.jsx("div",{className:"alert warn",children:"Ce magasin n'a pas la formule Pro : il ne voit pas ces statistiques dans son app (vous, si)."}),!l||!g?!a&&i.jsx("p",{className:"muted",children:"Chargement…"}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(190px, 1fr))",gap:12},children:[i.jsx(Bt,{icon:"🚶",label:"Passages",value:sn(g.visits),change:g.visitsChange,hint:"vs période précédente"}),i.jsx(Bt,{icon:"🆕",label:"Nouvelles cartes",value:sn(g.newCards),change:g.newCardsChange,hint:`${sn(g.cardsTotal)} au total`}),i.jsx(Bt,{icon:"👥",label:"Clients actifs",value:sn(g.activeCustomers),hint:`${g.visitsPerCustomer.toLocaleString("fr-FR")} passage(s) par client`}),i.jsx(Bt,{icon:"🔁",label:"Clients fidèles",value:g.returningRate===null?"—":`${g.returningRate.toLocaleString("fr-FR")} %`,hint:"venus au moins 2 fois"}),l.pointsMode==="AMOUNT"&&i.jsx(Bt,{icon:"💶",label:"Achats enregistrés",value:ri(g.revenueCents),hint:g.averageBasketCents===null?void 0:`panier moyen ${ri(g.averageBasketCents)}`}),i.jsx(Bt,{icon:"🎁",label:"Récompenses",value:sn(g.rewardsRedeemed),hint:`${sn(g.pointsGiven)} ${m} distribués`}),i.jsx(Bt,{icon:"📱",label:"Cartes dans Apple Wallet",value:g.appleWalletRate===null?"—":`${g.appleWalletRate.toLocaleString("fr-FR")} %`,hint:"iPhone joignables"})]}),i.jsxs("div",{className:"stats-pair",children:[i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Fréquentation"}),i.jsxs("p",{className:"muted",style:{marginTop:0,fontSize:14},children:[i.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"var(--primary)",borderRadius:2}})," Passages   ",i.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"var(--primary-soft)",border:"1px solid var(--primary)",borderRadius:2}})," Nouvelles cartes"]}),i.jsx(Kv,{series:l.series})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Heures d'affluence"}),i.jsx("p",{className:"muted",style:{marginTop:0},children:l.busiest?`Créneau le plus fréquenté : ${l.busiest}.`:"Pas encore de passage sur la période."}),i.jsx(Yv,{heat:l.heatmap})]})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Meilleurs clients"}),l.top.length===0?i.jsx("p",{className:"muted",style:{margin:0},children:"Pas encore de passage sur la période."}):i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",style:{width:56},children:"Rang"}),i.jsx("th",{scope:"col",children:"Client"}),i.jsx("th",{scope:"col",className:"num",children:"Passages"}),l.pointsMode==="AMOUNT"&&i.jsx("th",{scope:"col",className:"num",children:"Achats"}),i.jsx("th",{scope:"col",className:"num",children:"Solde"})]})}),i.jsx("tbody",{children:l.top.map((y,x)=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("span",{className:`rank${x<3?" top":""}`,children:["🥇","🥈","🥉"][x]??x+1})}),i.jsx("td",{style:{fontWeight:600},children:y.firstName}),i.jsx("td",{className:"num",children:y.visits}),l.pointsMode==="AMOUNT"&&i.jsx("td",{className:"num",children:ri(y.amountCents)}),i.jsx("td",{className:"num",children:y.balance})]},x))})]})})]})]})]})}const qv=[["infos","Infos"],["carte","Carte de fidélité"],["employes","Employés"],["modules","Modules"],["statistiques","Statistiques"],["facturation","Facturation"]];function Jv(){var c,p,g;const{id:e}=df(),[t,n]=j.useState(null),[r,l]=j.useState(null),[s,a]=j.useState(null),o=j.useCallback(()=>{O.get(`/api/admin/stores/${e}`).then(n).catch(m=>l(m.message))},[e]);j.useEffect(o,[o]);async function u(m,y){if(!(y&&!window.confirm(y))){l(null);try{await O.patch(`/api/admin/stores/${e}/status`,{status:m}),o()}catch(x){l(x.message)}}}return t?i.jsxs(i.Fragment,{children:[i.jsx(Ee,{to:"/magasins",children:"← Magasins"}),i.jsxs("section",{className:"card store-head",children:[i.jsxs("div",{className:"store-id",children:[i.jsx("span",{className:"store-avatar","aria-hidden":"true",children:t.name.charAt(0).toUpperCase()}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("h1",{style:{fontSize:28,lineHeight:"34px"},children:t.name}),i.jsx(yf,{status:t.status}),((c=t.subscription)==null?void 0:c.stripeSubscriptionId)&&t.subscription.status!=="CANCELED"&&i.jsx(xl,{to:"facturation",className:"badge DRAFT",style:{textDecoration:"none"},title:"Formule d'abonnement",children:qe[t.subscription.plan]})]}),i.jsxs("p",{className:"muted",style:{margin:0},children:[t.city," · ",t.counts.cards," clients · ",t.counts.staff," employés · ",t.contactName]}),i.jsxs("ul",{className:"open-steps","aria-label":"Étapes d’ouverture",children:[i.jsxs("li",{className:((p=t.subscription)==null?void 0:p.status)==="ACTIVE"?"done":"",children:[((g=t.subscription)==null?void 0:g.status)==="ACTIVE"?"✓":"○"," Abonnement payé"]}),i.jsxs("li",{className:t.hasCard?"done":"",children:[t.hasCard?"✓":"○"," Carte conçue"]}),i.jsxs("li",{className:t.status==="ACTIVE"?"done":"",children:[t.status==="ACTIVE"?"✓":"○"," Programme ouvert"]})]})]})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[(t.status==="DRAFT"||t.status==="CLOSED")&&i.jsx("button",{className:"btn",onClick:()=>u("ACTIVE"),children:"Activer"}),t.status==="SUSPENDED"&&i.jsx("button",{className:"btn",onClick:()=>u("ACTIVE"),children:"Réactiver"}),t.status==="ACTIVE"&&i.jsx("button",{className:"btn secondary",onClick:()=>u("SUSPENDED","Suspendre ce magasin ? Les employés ne pourront plus scanner."),children:"Suspendre"}),t.status!=="CLOSED"&&i.jsx("button",{className:"btn secondary",onClick:()=>u("CLOSED","Fermer ce magasin ?"),children:"Fermer"})]}),i.jsxs("div",{className:"copy-line",style:{flexBasis:"100%"},children:[i.jsx("span",{className:"muted",children:"Lien d’inscription :"}),i.jsx("code",{children:t.enrollUrl}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>{var m;return(m=navigator.clipboard)==null?void 0:m.writeText(t.enrollUrl).then(()=>a("Lien copié."))},children:"Copier"})]})]}),t.status==="SUSPENDED"&&i.jsxs("div",{className:"alert warn",role:"status",children:["Magasin suspendu",t.billingSuspended?" pour impayé":""," : les scans et les nouvelles inscriptions sont refusés.",t.billingSuspended&&i.jsxs(i.Fragment,{children:[" Voir l'onglet ",i.jsx(xl,{to:"facturation",children:"Facturation"}),"."]})]}),r&&i.jsx("div",{className:"alert error",role:"alert",children:r}),s&&i.jsx("div",{className:"alert ok",role:"status",children:s}),i.jsx("nav",{className:"tabs","aria-label":"Sections du magasin",children:qv.map(([m,y])=>i.jsx(xl,{to:m,children:y},m))}),i.jsxs(Xi,{children:[i.jsx(q,{index:!0,element:i.jsx(yl,{to:"infos",replace:!0})}),i.jsx(q,{path:"infos",element:i.jsx(xf,{initial:t,submitLabel:"Enregistrer",onSubmit:async m=>{const{name:y,siret:x,addressLine:w,postalCode:S,city:f,contactName:d,contactEmail:h,contactPhone:v,maxAmountEuros:N,minScanIntervalMin:E}=m;await O.patch(`/api/admin/stores/${e}`,{name:y,siret:x,addressLine:w,postalCode:S,city:f,contactName:d,contactEmail:h,contactPhone:v,maxAmountEuros:N,minScanIntervalMin:E}),a("Modifications enregistrées."),o()}},t.id)}),i.jsx(q,{path:"carte",element:i.jsx(Bf,{store:t,onSaved:o})}),i.jsx(q,{path:"employes",element:i.jsx(Iv,{storeId:t.id})}),i.jsx(q,{path:"modules",element:i.jsx(Vv,{storeId:t.id,storeName:t.name})}),i.jsx(q,{path:"statistiques",element:i.jsx(Gv,{storeId:t.id,storeSlug:t.slug})}),i.jsx(q,{path:"facturation",element:i.jsx(Ov,{storeId:t.id,contactEmail:t.contactEmail,onChange:o})})]})]}):r?i.jsx("div",{className:"alert error",children:r}):i.jsx("p",{className:"muted",children:"Chargement…"})}function $u({merchant:e=!1}){const{id:t}=df(),n=e?"/api/staff/store":`/api/admin/stores/${t}`,r=e?"/api/staff/card-design":`/api/admin/stores/${t}/card-design`,[l,s]=io(),a=l.get("format")==="A6"?"A6":"A5",[o,u]=j.useState(null),[c,p]=j.useState(null),[g,m]=j.useState(null);return j.useEffect(()=>{Promise.all([O.get(n),O.get(r)]).then(([y,x])=>{u(y),p(x)}).catch(y=>m(y.message))},[n,r]),g?i.jsx("div",{className:"alert error",style:{margin:24},children:g}):o?c?i.jsxs("div",{className:"poster-page",children:[i.jsx("style",{children:`@page{size:${a};margin:0}@media print{.no-print{display:none!important}body{background:#fff}.poster-page{padding:0!important}}`}),i.jsxs("div",{className:"no-print row between",style:{padding:16},children:[i.jsx(Ee,{to:e?"/espace":`/magasins/${t}/carte`,children:"← Retour à la carte"}),i.jsxs("div",{className:"row",style:{gap:8},children:[["A5","A6"].map(y=>i.jsx("button",{type:"button",className:"chip","aria-pressed":a===y,onClick:()=>s({format:y}),children:y},y)),i.jsx("button",{type:"button",className:"btn",onClick:()=>window.print(),children:"Imprimer"})]})]}),o.status!=="ACTIVE"&&i.jsx("div",{className:"alert warn no-print",style:{margin:"0 16px 16px"},children:"Le magasin n'est pas actif : le QR mène pour l'instant à une page « introuvable » ou « indisponible »."}),i.jsx("div",{style:{display:"flex",justifyContent:"center",padding:16},className:"poster-page",children:i.jsx(Of,{format:a,url:o.enrollUrl,storeName:o.name,programName:c.programName,logoUrl:na(c.logoUrl),backgroundColor:c.backgroundColor,foregroundColor:c.foregroundColor,labelColor:c.labelColor,rewards:c.rewards,pointsMode:c.pointsMode})}),i.jsx("p",{className:"no-print muted",style:{textAlign:"center"},children:o.enrollUrl})]}):i.jsx("div",{className:"alert warn",style:{margin:24},children:"Concevez d'abord la carte de fidélité."}):i.jsx("p",{className:"muted",style:{margin:24},children:"Chargement…"})}const Bu=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),bu=["ESSENTIEL","PRO","RESEAU"],Xv=[["name","Nom du commerce",{autoComplete:"organization",placeholder:"Boulangerie Kerlann",maxLength:120}],["siret","SIRET",{inputMode:"numeric",placeholder:"123 456 789 00012"}],["addressLine","Adresse",{autoComplete:"street-address",maxLength:200}],["postalCode","Code postal",{autoComplete:"postal-code",inputMode:"numeric",maxLength:5}],["city","Ville",{autoComplete:"address-level2",maxLength:120}],["contactName","Prénom et nom",{autoComplete:"name",maxLength:120}],["contactPhone","Téléphone",{autoComplete:"tel",type:"tel"}],["contactEmail","E-mail (votre identifiant de connexion)",{autoComplete:"email",type:"email"}]];function Zv(){const[e]=io(),t=(e.get("formule")??"").toUpperCase(),[n,r]=j.useState(bu.includes(t)?t:"PRO"),[l,s]=j.useState(e.get("periode")==="annuel"?"YEAR":"MONTH"),[a,o]=j.useState([]),[u,c]=j.useState({name:"",siret:"",addressLine:"",postalCode:"",city:"",contactName:"",contactPhone:"",contactEmail:"",password:""}),[p,g]=j.useState(!1),[m,y]=j.useState(e.get("annule")?"Paiement annulé : rien n’a été prélevé. Vous pouvez reprendre quand vous voulez.":null),[x,w]=j.useState(!1);j.useEffect(()=>{const v=N=>N.persisted&&w(!1);return window.addEventListener("pageshow",v),()=>window.removeEventListener("pageshow",v)},[]),j.useEffect(()=>{ra.get("/api/public/signup/plans").then(o).catch(()=>{})},[]);async function S(v){v.preventDefault(),w(!0),y(null);try{const{url:N}=await ra.post("/api/public/signup",{...u,plan:n,interval:l,cgv:p});window.location.assign(N)}catch(N){y(N.message),w(!1),window.scrollTo({top:0,behavior:"smooth"})}}const f=a.find(v=>v.plan===n),d=a.length?a:bu.map(v=>({plan:v,name:qe[v],tagline:"",priceCents:{MONTH:0,YEAR:0},modules:[],limits:{maxStaff:null}})),h=v=>{const[,N,E]=Xv.find(([k])=>k===v);return i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:`s-${v}`,children:N}),i.jsx("input",{id:`s-${v}`,className:"input",required:!0,value:u[v],onChange:k=>c({...u,[v]:k.target.value}),...E})]},v)};return i.jsxs("main",{className:"s-page",children:[i.jsxs("header",{className:"s-head",children:[i.jsx("a",{href:"https://monespacepro.eu/",style:{textDecoration:"none",color:"inherit"},"aria-label":"MonEspacePro, accueil",children:i.jsx(Fr,{admin:!1})}),i.jsxs("span",{className:"muted",style:{fontSize:14},children:["Déjà inscrit ? ",i.jsx(Ee,{to:"/espace",children:"Se connecter"})]})]}),i.jsxs("form",{onSubmit:S,className:"s-layout",children:[i.jsxs("div",{className:"s-main",children:[i.jsxs("div",{children:[i.jsx("h1",{children:"Créer mon programme de fidélité"}),i.jsx("p",{className:"muted",style:{margin:"6px 0 0"},children:"Trois minutes, sans engagement. Votre espace est prêt dès le paiement validé."})]}),m&&i.jsx("div",{className:"alert error",role:"alert",children:m}),i.jsxs("section",{className:"card s-section",children:[i.jsxs("div",{className:"s-title",children:[i.jsx("span",{className:"s-num",children:"1"}),i.jsx("h2",{children:"Votre formule"})]}),i.jsxs("div",{role:"group","aria-label":"Périodicité",className:"s-seg",children:[i.jsx("button",{type:"button","aria-pressed":l==="MONTH",onClick:()=>s("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button","aria-pressed":l==="YEAR",onClick:()=>s("YEAR"),children:"Annuel · 2 mois offerts"})]}),i.jsx("div",{className:"s-plans",role:"radiogroup","aria-label":"Formule",children:d.map(v=>i.jsxs("label",{className:`s-plan${n===v.plan?" on":""}`,children:[i.jsx("input",{type:"radio",name:"plan",className:"sr-only",checked:n===v.plan,onChange:()=>r(v.plan)}),v.plan==="PRO"&&i.jsx("span",{className:"s-tag",children:"Conseillée"}),i.jsx("strong",{children:v.name}),v.priceCents[l]>0&&i.jsxs("span",{className:"s-price",children:[Bu(v.priceCents[l]),i.jsxs("small",{children:[" / ",l==="YEAR"?"an":"mois"]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:v.tagline})]},v.plan))})]}),i.jsxs("section",{className:"card s-section",children:[i.jsxs("div",{className:"s-title",children:[i.jsx("span",{className:"s-num",children:"2"}),i.jsx("h2",{children:"Votre commerce"})]}),h("name"),h("siret"),h("addressLine"),i.jsxs("div",{className:"s-two",children:[h("postalCode"),h("city")]})]}),i.jsxs("section",{className:"card s-section",children:[i.jsxs("div",{className:"s-title",children:[i.jsx("span",{className:"s-num",children:"3"}),i.jsx("h2",{children:"Vos identifiants"})]}),i.jsxs("div",{className:"s-two",children:[h("contactName"),h("contactPhone")]}),h("contactEmail"),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"s-password",children:"Mot de passe"}),i.jsx("input",{id:"s-password",className:"input",type:"password",required:!0,minLength:10,autoComplete:"new-password",value:u.password,onChange:v=>c({...u,password:v.target.value})}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"10 caractères minimum. Il ouvre votre espace web et l’app MonEspacePro."})]})]})]}),i.jsx("aside",{className:"s-side",children:i.jsxs("section",{className:"card s-summary",children:[i.jsx("span",{className:"muted",style:{fontSize:13,textTransform:"uppercase",letterSpacing:".05em"},children:"Récapitulatif"}),i.jsxs("div",{className:"row between",style:{alignItems:"baseline"},children:[i.jsxs("strong",{style:{fontSize:20},children:["Formule ",(f==null?void 0:f.name)??qe[n]]}),f&&i.jsxs("span",{style:{fontSize:22,fontWeight:800},children:[Bu(f.priceCents[l]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",l==="YEAR"?"an":"mois"]})]})]}),f&&i.jsxs("ul",{className:"s-list",children:[i.jsx("li",{children:"Carte dans Apple Wallet et Google Wallet"}),i.jsx("li",{children:f.limits.maxStaff?`${f.limits.maxStaff} employés`:"Employés illimités"}),f.modules.map(v=>i.jsx("li",{children:v.name},v.id))]}),i.jsxs("label",{className:"row",style:{gap:10,alignItems:"flex-start",flexWrap:"nowrap",fontSize:14},children:[i.jsx("input",{type:"checkbox",required:!0,checked:p,onChange:v=>g(v.target.checked),style:{marginTop:3}}),i.jsxs("span",{children:["J’accepte les ",i.jsx("a",{href:"https://monespacepro.eu/cgv/",target:"_blank",rel:"noreferrer",children:"CGV"})," et la"," ",i.jsx("a",{href:"https://monespacepro.eu/confidentialite/",target:"_blank",rel:"noreferrer",children:"politique de confidentialité"}),"."]})]}),i.jsx("button",{className:"btn",disabled:x,style:{width:"100%"},children:x?"Redirection vers le paiement…":"Continuer vers le paiement"}),i.jsxs("ul",{className:"s-trust",children:[i.jsx("li",{children:"🔒 Paiement sécurisé par Stripe"}),i.jsx("li",{children:"💳 Carte bancaire ou prélèvement SEPA"}),i.jsx("li",{children:"↩︎ Sans engagement, résiliable à tout moment"})]})]})})]})]})}function ey({onLogin:e}){const t=Dt(),[n]=io(),r=n.has("bienvenue"),[l,s]=j.useState(""),[a,o]=j.useState(""),[u,c]=j.useState(null),[p,g]=j.useState(!1);async function m(y){y.preventDefault(),g(!0),c(null);try{await Eg(l,a),e(),t("/espace",{replace:!0})}catch(x){c(r&&x instanceof gs&&x.status===401?"Votre espace est en cours de création. Réessayez dans quelques secondes.":x.message)}finally{g(!1)}}return i.jsx("main",{style:{minHeight:"100vh",display:"grid",placeItems:"center",padding:16},children:i.jsxs("form",{className:"card",onSubmit:m,style:{width:"100%",maxWidth:420,display:"flex",flexDirection:"column",gap:20},children:[i.jsx(Fr,{admin:!1}),r&&i.jsx("div",{className:"alert ok",children:"Paiement reçu, merci ! Connectez-vous avec l’e-mail et le mot de passe choisis à l’inscription."}),i.jsxs("div",{children:[i.jsx("h1",{style:{fontSize:26},children:"Mon espace"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Mêmes identifiants que l’app MonEspacePro."})]}),u&&i.jsx("div",{className:"alert error",role:"alert",children:u}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"m-email",children:"E-mail"}),i.jsx("input",{id:"m-email",className:"input",type:"email",autoComplete:"username",required:!0,value:l,onChange:y=>s(y.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"m-password",children:"Mot de passe"}),i.jsx("input",{id:"m-password",className:"input",type:"password",autoComplete:"current-password",required:!0,value:a,onChange:y=>o(y.target.value)})]}),i.jsx("button",{className:"btn",disabled:p,children:p?"Connexion…":"Se connecter"}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14,textAlign:"center"},children:["Pas encore client ? ",i.jsx(Ee,{to:"/inscription",children:"Créer mon programme"})]})]})})}function ty(){const[e,t]=j.useState(null),[n,r]=j.useState(null),[l,s]=j.useState(!1),[a,o]=j.useState(null),u=j.useCallback(()=>{O.get("/api/staff/store").then(t).catch(x=>r(x instanceof gs&&x.status===403?"Cet espace est réservé au Dirigeant du magasin. Utilisez l’app MonEspacePro pour scanner les cartes.":x.message)),O.get("/api/staff/card-design").then(x=>o(!!x)).catch(()=>o(null))},[]);j.useEffect(u,[u]);function c(x){var w;(w=navigator.clipboard)==null||w.writeText(x).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})}const p=!!e&&!e.subscribeUrl,g=(e==null?void 0:e.status)==="ACTIVE",m=[["Abonnement",p?`Formule ${e!=null&&e.subscription?qe[e.subscription.plan]:""} active`:"En attente du paiement",p],["Carte de fidélité",a?"Conçue":"Logo, couleurs, récompenses",!!a],["Programme ouvert",g?"Vos clients peuvent s’inscrire":"S’ouvre automatiquement",g]],y=m.findIndex(([,,x])=>!x);return i.jsxs("div",{style:{minHeight:"100vh"},children:[i.jsxs("header",{className:"m-top",children:[i.jsx(Fr,{admin:!1}),i.jsx("span",{className:"grow"}),e&&i.jsx("span",{className:"muted",style:{fontSize:14},children:e.name}),e&&i.jsx("span",{className:"m-avatar","aria-hidden":"true",children:e.name.charAt(0).toUpperCase()}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:uo,children:"Se déconnecter"})]}),i.jsxs("main",{className:"container",style:{padding:24,display:"flex",flexDirection:"column",gap:24},children:[n&&i.jsx("div",{className:"alert error",role:"alert",children:n}),!e&&!n&&i.jsx("p",{className:"muted",children:"Chargement…"}),e&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"m-hero",children:[i.jsxs("div",{children:[i.jsx("h1",{children:e.name}),i.jsxs("p",{children:[e.subscription?`Formule ${qe[e.subscription.plan]}`:"Aucune formule"," ·"," ",g?"programme ouvert à vos clients":e.status==="SUSPENDED"?"programme suspendu":"programme pas encore ouvert"]})]}),e.subscribeUrl&&i.jsx("a",{className:"btn",href:e.subscribeUrl,children:"Activer mon abonnement"})]}),e.status==="SUSPENDED"&&i.jsx("div",{className:"alert warn",children:"Programme suspendu. Il rouvre automatiquement dès le paiement de l’abonnement régularisé."}),i.jsx("ol",{className:"m-steps","aria-label":"Étapes d’ouverture",children:m.map(([x,w,S],f)=>i.jsxs("li",{className:`m-step${S?" done":""}${f===y?" current":""}`,"aria-current":f===y?"step":void 0,children:[i.jsx("span",{className:"dot",children:S?"✓":f+1}),i.jsxs("div",{children:[i.jsx("strong",{children:x}),i.jsx("span",{children:w})]})]},x))}),i.jsxs("div",{className:"m-grid",children:[i.jsxs("section",{className:"card m-tile",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:"🔗"}),i.jsx("h2",{children:"Lien d’inscription"}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Vos clients s’inscrivent ici (c’est le QR code de l’affichette)."}),i.jsxs("div",{className:"m-copy",children:[i.jsx("code",{children:e.enrollUrl}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>c(e.enrollUrl),children:l?"Copié ✓":"Copier"})]})]}),i.jsxs("section",{className:"card m-tile",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:"🖨️"}),i.jsx("h2",{children:"Affichette du comptoir"}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"À imprimer en A5 ou A6 et à poser près de la caisse."}),i.jsx("div",{children:a?i.jsx(Ee,{className:"btn secondary",to:"/espace/affichette",children:"Imprimer l’affichette"}):i.jsx("span",{className:"muted",style:{fontSize:14},children:"Disponible une fois la carte conçue."})})]}),i.jsxs("section",{className:"card m-tile",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:"📱"}),i.jsx("h2",{children:"App MonEspacePro"}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Scan des cartes, employés, modules (campagnes, anniversaire, relances…) et statistiques : avec les mêmes identifiants."})]})]}),i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:12},children:[i.jsx("h2",{children:"Ma carte de fidélité"}),i.jsx(Bf,{store:e,onSaved:u,base:"/api/staff/card-design",posterHref:"/espace/affichette",draftNote:i.jsx("p",{style:{margin:0},children:e.subscribeUrl?"Votre programme s’ouvrira automatiquement dès votre abonnement activé.":"Enregistrez la carte : votre programme s’ouvre automatiquement à vos clients."})})]})]})]})]})}function ny(){const e=Dt(),t=Ft(),[n,r]=j.useState(Ng()),l=t.pathname.startsWith("/espace");j.useEffect(()=>{Sg(()=>{r(null),e(l?"/espace":"/connexion")})},[e,l]);const s=i.jsx(ey,{onLogin:()=>r("staff")});return n!=="admin"||t.pathname==="/inscription"?i.jsxs(Xi,{children:[i.jsx(q,{path:"/inscription",element:i.jsx(Zv,{})}),n==="staff"?i.jsxs(i.Fragment,{children:[i.jsx(q,{path:"/espace/affichette",element:i.jsx($u,{merchant:!0})}),i.jsx(q,{path:"/espace",element:i.jsx(ty,{})}),i.jsx(q,{path:"*",element:i.jsx(yl,{to:"/espace",replace:!0})})]}):i.jsxs(i.Fragment,{children:[i.jsx(q,{path:"/espace",element:s}),i.jsx(q,{path:"/connexion",element:i.jsx(Rg,{onLogin:()=>r("admin")})}),i.jsx(q,{path:"*",element:i.jsx(yl,{to:l?"/espace":"/connexion",replace:!0})})]})]}):i.jsxs(Xi,{children:[i.jsx(q,{path:"/espace",element:s}),i.jsx(q,{path:"/magasins/:id/affichette",element:i.jsx($u,{})}),i.jsxs(q,{element:i.jsx(Pg,{}),children:[i.jsx(q,{path:"/magasins",element:i.jsx(_g,{})}),i.jsx(q,{path:"/magasins/nouveau",element:i.jsx(Dg,{})}),i.jsx(q,{path:"/magasins/:id/*",element:i.jsx(Jv,{})})]}),i.jsx(q,{path:"*",element:i.jsx(yl,{to:"/magasins",replace:!0})})]})}tf(document.getElementById("root")).render(i.jsx(j.StrictMode,{children:i.jsx(gg,{future:{v7_startTransition:!0},children:i.jsx(ny,{})})})); diff --git a/site/carte-de-fidelite/boucherie-charcuterie/index.html b/site/carte-de-fidelite/boucherie-charcuterie/index.html index ecf3031..9cf2867 100644 --- a/site/carte-de-fidelite/boucherie-charcuterie/index.html +++ b/site/carte-de-fidelite/boucherie-charcuterie/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/boulangerie/index.html b/site/carte-de-fidelite/boulangerie/index.html index d9d8dde..ed313c6 100644 --- a/site/carte-de-fidelite/boulangerie/index.html +++ b/site/carte-de-fidelite/boulangerie/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/boutique/index.html b/site/carte-de-fidelite/boutique/index.html index e883408..5b5057d 100644 --- a/site/carte-de-fidelite/boutique/index.html +++ b/site/carte-de-fidelite/boutique/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/cafe-bar/index.html b/site/carte-de-fidelite/cafe-bar/index.html index 81b362d..06140a8 100644 --- a/site/carte-de-fidelite/cafe-bar/index.html +++ b/site/carte-de-fidelite/cafe-bar/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/coiffeur-barbier/index.html b/site/carte-de-fidelite/coiffeur-barbier/index.html index 3fbd755..9127f51 100644 --- a/site/carte-de-fidelite/coiffeur-barbier/index.html +++ b/site/carte-de-fidelite/coiffeur-barbier/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/epicerie-primeur/index.html b/site/carte-de-fidelite/epicerie-primeur/index.html index a63f521..a2e6ecb 100644 --- a/site/carte-de-fidelite/epicerie-primeur/index.html +++ b/site/carte-de-fidelite/epicerie-primeur/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/fleuriste/index.html b/site/carte-de-fidelite/fleuriste/index.html index 8304750..1c435ea 100644 --- a/site/carte-de-fidelite/fleuriste/index.html +++ b/site/carte-de-fidelite/fleuriste/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/index.html b/site/carte-de-fidelite/index.html index 9655996..ac56021 100644 --- a/site/carte-de-fidelite/index.html +++ b/site/carte-de-fidelite/index.html @@ -228,7 +228,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/institut-beaute/index.html b/site/carte-de-fidelite/institut-beaute/index.html index ee7c2d9..934df82 100644 --- a/site/carte-de-fidelite/institut-beaute/index.html +++ b/site/carte-de-fidelite/institut-beaute/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/pizzeria/index.html b/site/carte-de-fidelite/pizzeria/index.html index bc97374..054cea7 100644 --- a/site/carte-de-fidelite/pizzeria/index.html +++ b/site/carte-de-fidelite/pizzeria/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/pressing/index.html b/site/carte-de-fidelite/pressing/index.html index f96f372..09dfae8 100644 --- a/site/carte-de-fidelite/pressing/index.html +++ b/site/carte-de-fidelite/pressing/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/restaurant/index.html b/site/carte-de-fidelite/restaurant/index.html index b9eebb3..7c5fbf9 100644 --- a/site/carte-de-fidelite/restaurant/index.html +++ b/site/carte-de-fidelite/restaurant/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/carte-de-fidelite/sandwicherie/index.html b/site/carte-de-fidelite/sandwicherie/index.html index f905720..d4670a4 100644 --- a/site/carte-de-fidelite/sandwicherie/index.html +++ b/site/carte-de-fidelite/sandwicherie/index.html @@ -206,7 +206,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/cgv/index.html b/site/cgv/index.html index ec3536b..8c29435 100644 --- a/site/cgv/index.html +++ b/site/cgv/index.html @@ -94,7 +94,7 @@
-

Légal

Conditions générales de vente

Dernière mise à jour : 7 octobre 2026

+

Légal

Conditions générales de vente

Dernière mise à jour : 9 octobre 2026

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/confidentialite/index.html b/site/confidentialite/index.html index dcdc8ea..ce5a4c8 100644 --- a/site/confidentialite/index.html +++ b/site/confidentialite/index.html @@ -142,7 +142,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/contact/index.html b/site/contact/index.html index ac7a1cb..6ff0b08 100644 --- a/site/contact/index.html +++ b/site/contact/index.html @@ -149,7 +149,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/espace/affichette/index.html b/site/espace/affichette/index.html index 710a10c..6edeb1d 100644 --- a/site/espace/affichette/index.html +++ b/site/espace/affichette/index.html @@ -8,7 +8,7 @@ Affichette — MonEspacePro - + diff --git a/site/espace/index.html b/site/espace/index.html index 88a2628..03773f0 100644 --- a/site/espace/index.html +++ b/site/espace/index.html @@ -8,7 +8,7 @@ Mon espace — MonEspacePro - + diff --git a/site/faq/index.html b/site/faq/index.html index 60b0446..c7135d6 100644 --- a/site/faq/index.html +++ b/site/faq/index.html @@ -171,7 +171,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/fonctionnalites/index.html b/site/fonctionnalites/index.html index 54a07df..78e1f75 100644 --- a/site/fonctionnalites/index.html +++ b/site/fonctionnalites/index.html @@ -259,7 +259,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/guides/carte-fidelite-apple-wallet-google-wallet/index.html b/site/guides/carte-fidelite-apple-wallet-google-wallet/index.html index 6cd6dec..f140faa 100644 --- a/site/guides/carte-fidelite-apple-wallet-google-wallet/index.html +++ b/site/guides/carte-fidelite-apple-wallet-google-wallet/index.html @@ -164,7 +164,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/guides/carte-fidelite-papier-ou-dematerialisee/index.html b/site/guides/carte-fidelite-papier-ou-dematerialisee/index.html index 0925fd4..af5e59d 100644 --- a/site/guides/carte-fidelite-papier-ou-dematerialisee/index.html +++ b/site/guides/carte-fidelite-papier-ou-dematerialisee/index.html @@ -166,7 +166,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/guides/creer-carte-de-fidelite/index.html b/site/guides/creer-carte-de-fidelite/index.html index 310508d..09172fc 100644 --- a/site/guides/creer-carte-de-fidelite/index.html +++ b/site/guides/creer-carte-de-fidelite/index.html @@ -170,7 +170,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/guides/faire-revenir-ses-clients/index.html b/site/guides/faire-revenir-ses-clients/index.html index a6d657a..b2f8855 100644 --- a/site/guides/faire-revenir-ses-clients/index.html +++ b/site/guides/faire-revenir-ses-clients/index.html @@ -155,7 +155,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/guides/fidelite-rgpd/index.html b/site/guides/fidelite-rgpd/index.html index ad8c2a4..de815f7 100644 --- a/site/guides/fidelite-rgpd/index.html +++ b/site/guides/fidelite-rgpd/index.html @@ -155,7 +155,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/guides/idees-recompenses-fidelite/index.html b/site/guides/idees-recompenses-fidelite/index.html index d2da8e9..e9c2e7d 100644 --- a/site/guides/idees-recompenses-fidelite/index.html +++ b/site/guides/idees-recompenses-fidelite/index.html @@ -200,7 +200,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/guides/index.html b/site/guides/index.html index 5ff7a81..245e382 100644 --- a/site/guides/index.html +++ b/site/guides/index.html @@ -127,7 +127,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/guides/tampons-ou-points/index.html b/site/guides/tampons-ou-points/index.html index 383dc7f..4167459 100644 --- a/site/guides/tampons-ou-points/index.html +++ b/site/guides/tampons-ou-points/index.html @@ -166,7 +166,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/index.html b/site/index.html index c903524..45aa135 100644 --- a/site/index.html +++ b/site/index.html @@ -353,7 +353,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/inscription/index.html b/site/inscription/index.html index cfc1393..11cb582 100644 --- a/site/inscription/index.html +++ b/site/inscription/index.html @@ -7,7 +7,7 @@ Créer mon programme de fidélité — MonEspacePro - + diff --git a/site/mentions-legales/index.html b/site/mentions-legales/index.html index 766efc0..4d141f1 100644 --- a/site/mentions-legales/index.html +++ b/site/mentions-legales/index.html @@ -129,7 +129,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI
diff --git a/site/sitemap.xml b/site/sitemap.xml index 22fe4a2..21ca82f 100644 --- a/site/sitemap.xml +++ b/site/sitemap.xml @@ -11,6 +11,7 @@ https://monespacepro.eu/fonctionnalites/2026-10-090.9 https://monespacepro.eu/guides/2026-10-090.8 https://monespacepro.eu/mentions-legales/2026-10-090.3 +https://monespacepro.eu/sous-traitance/2026-10-090.3 https://monespacepro.eu/tarif/2026-10-090.9 https://monespacepro.eu/carte-de-fidelite/boucherie-charcuterie/2026-10-090.8 https://monespacepro.eu/carte-de-fidelite/boulangerie/2026-10-090.8 diff --git a/site/sous-traitance/index.html b/site/sous-traitance/index.html new file mode 100644 index 0000000..fb81566 --- /dev/null +++ b/site/sous-traitance/index.html @@ -0,0 +1,170 @@ + + + + + +Accord de sous-traitance (RGPD) — MonEspacePro + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ +
+
+
+

Légal

Accord de sous-traitance (RGPD)

Dernière mise à jour : 9 octobre 2026

+
+
+
+ + + + + +
+ + diff --git a/site/tarif/index.html b/site/tarif/index.html index f621971..4970181 100644 --- a/site/tarif/index.html +++ b/site/tarif/index.html @@ -316,7 +316,7 @@

La carte de fidélité dématérialisée pour les commerces indépendants.

- +
© MonEspacePro — EI Tony AvertyTVA non applicable, art. 293 B du CGI