diff --git a/admin/src/pages/MerchantSpace.tsx b/admin/src/pages/MerchantSpace.tsx
index 355e98d..09298a4 100644
--- a/admin/src/pages/MerchantSpace.tsx
+++ b/admin/src/pages/MerchantSpace.tsx
@@ -50,7 +50,7 @@ export function MerchantLoginPage({ onLogin }: { onLogin: () => void }) {
{welcome &&
Paiement reçu, merci ! Connectez-vous avec l’e-mail et le mot de passe choisis à l’inscription.
}
Mon espace
-
Mêmes identifiants que l’app MonEspacePro Pro.
+
Mêmes identifiants que l’app MonEspacePro.
{error && {error}
}
@@ -79,7 +79,7 @@ export function MerchantSpace() {
api
.get('/api/staff/store')
.then(setStore)
- .catch((e) => setError(e instanceof ApiError && e.status === 403 ? 'Cet espace est réservé au Dirigeant du magasin. Utilisez l’app MonEspacePro Pro pour scanner les cartes.' : e.message));
+ .catch((e) => setError(e instanceof ApiError && e.status === 403 ? 'Cet espace est réservé au Dirigeant du magasin. Utilisez l’app MonEspacePro pour scanner les cartes.' : e.message));
}, []);
useEffect(reload, [reload]);
@@ -114,7 +114,7 @@ export function MerchantSpace() {
)}
- Employés, modules (campagnes, anniversaire, relances…) et statistiques : dans l’app MonEspacePro Pro, avec les mêmes identifiants.
+ Employés, modules (campagnes, anniversaire, relances…) et statistiques : dans l’app MonEspacePro, avec les mêmes identifiants.
setV({ ...v, password: e.target.value })}
/>
- 10 caractères minimum. Il ouvre votre espace web et l’app MonEspacePro Pro.
+ 10 caractères minimum. Il ouvre votre espace web et l’app MonEspacePro.
diff --git a/backend/src/billing/billing.service.ts b/backend/src/billing/billing.service.ts
index 757bd9d..0f5f315 100644
--- a/backend/src/billing/billing.service.ts
+++ b/backend/src/billing/billing.service.ts
@@ -181,7 +181,7 @@ export class BillingService {
const espace = `${webUrl}/espace`;
const c = opts.credentials;
const text = `Bonjour ${store.contactName},\n\nVoici le lien pour activer la formule ${def.name} de MonEspacePro pour ${store.name} (${priceText}, sans engagement) :\n${url}\n${
- c ? `\nVotre compte Dirigeant (app MonEspacePro Pro et espace web ${espace}) :\nE-mail : ${c.email}\nMot de passe provisoire : ${c.password}\n` : ''
+ c ? `\nVotre compte Dirigeant (app MonEspacePro et espace web ${espace}) :\nE-mail : ${c.email}\nMot de passe provisoire : ${c.password}\n` : ''
}\nMonEspacePro`;
const html = emailLayout({
webUrl,
@@ -206,7 +206,7 @@ export class BillingService {
] as [string, string][])
: []),
],
- note: 'Vos identifiants ouvrent aussi l’app MonEspacePro Pro, pour scanner les cartes de vos clients.',
+ note: 'Vos identifiants ouvrent aussi l’app MonEspacePro, pour scanner les cartes de vos clients.',
});
await this.mail.send(store.contactEmail, `Activez la formule ${def.name} de MonEspacePro`, text, html);
}
diff --git a/backend/src/signup/signup.service.ts b/backend/src/signup/signup.service.ts
index 9a82b9f..45773ca 100644
--- a/backend/src/signup/signup.service.ts
+++ b/backend/src/signup/signup.service.ts
@@ -94,7 +94,7 @@ export class SignupService {
const store = await this.prisma.store.findUniqueOrThrow({ where: { id: storeId }, include: { subscription: true } });
const espace = `${this.config.get('webUrl')}/espace`;
const def = PLANS[store.subscription?.plan ?? 'ESSENTIEL'];
- const text = `Bonjour ${store.contactName},\n\nBienvenue sur MonEspacePro ! Votre abonnement ${def.name} pour ${store.name} est actif.\n\nDernière étape : concevez votre carte de fidélité (logo, couleurs, récompenses) sur ${espace}, avec l'e-mail ${store.contactEmail} et le mot de passe choisi à l'inscription. Votre programme s'ouvre à vos clients dès la carte enregistrée.\n\nEn caisse, installez l'app MonEspacePro Pro sur votre téléphone et connectez-vous avec les mêmes identifiants.\n\nMonEspacePro`;
+ const text = `Bonjour ${store.contactName},\n\nBienvenue sur MonEspacePro ! Votre abonnement ${def.name} pour ${store.name} est actif.\n\nDernière étape : concevez votre carte de fidélité (logo, couleurs, récompenses) sur ${espace}, avec l'e-mail ${store.contactEmail} et le mot de passe choisi à l'inscription. Votre programme s'ouvre à vos clients dès la carte enregistrée.\n\nEn caisse, installez l'app MonEspacePro sur votre téléphone et connectez-vous avec les mêmes identifiants.\n\nMonEspacePro`;
const html = emailLayout({
webUrl: this.config.get('webUrl')!,
preheader: `Concevez votre carte de fidélité pour ouvrir ${store.name} à vos clients.`,
@@ -108,7 +108,7 @@ export class SignupService {
details: [
['Identifiant', esc(store.contactEmail)],
['Mot de passe', 'Celui choisi à l’inscription'],
- ['En caisse', 'App MonEspacePro Pro, mêmes identifiants'],
+ ['En caisse', 'App MonEspacePro, mêmes identifiants'],
],
note: 'Depuis l’app Pro, vous créez aussi les comptes de vos employés et réglez vos modules.',
});
diff --git a/pro/app.json b/pro/app.json
index ccf1e67..4b19ad6 100644
--- a/pro/app.json
+++ b/pro/app.json
@@ -1,6 +1,6 @@
{
"expo": {
- "name": "MonEspacePro Pro",
+ "name": "MonEspacePro",
"slug": "monespacepro-pro",
"version": "0.1.0",
"orientation": "portrait",
diff --git a/pro/app/scan.tsx b/pro/app/scan.tsx
index 75d463a..cd1ff79 100644
--- a/pro/app/scan.tsx
+++ b/pro/app/scan.tsx
@@ -25,7 +25,7 @@ export default function Scan() {
{permission.canAskAgain ? (
) : (
- Autorisez la caméra pour MonEspacePro Pro dans les réglages du téléphone.
+ Autorisez la caméra pour MonEspacePro dans les réglages du téléphone.
)}
router.back()} />
diff --git a/pro/app/team.tsx b/pro/app/team.tsx
index d8bdb46..3d3416a 100644
--- a/pro/app/team.tsx
+++ b/pro/app/team.tsx
@@ -83,7 +83,7 @@ export default function Team() {
Share.share({ message: `MonEspacePro Pro\nIdentifiant : ${created.email}\nMot de passe : ${created.provisionalPassword}` })}
+ onPress={() => Share.share({ message: `MonEspacePro\nIdentifiant : ${created.email}\nMot de passe : ${created.provisionalPassword}` })}
/>
)}
diff --git a/site-src/build.js b/site-src/build.js
index 06aa43a..8f2e1df 100644
--- a/site-src/build.js
+++ b/site-src/build.js
@@ -165,6 +165,7 @@ function transform(file, body) {
/** Boutons d'appel à l'action → page Tarif (inscription en ligne). Les liens « Nous écrire » restent sur Contact. */
function ctaToPricing(html) {
return html
+ .replaceAll('MonEspacePro Pro', 'MonEspacePro') // nom de l'app mobile
.replace(/Demander une démo<\/a>/g, ' Commencer ')
.replace(/Équiper mon commerce<\/a>/g, ' Équiper mon commerce ');
}
diff --git a/site-src/pricing.js b/site-src/pricing.js
index 3db4c5a..251950b 100644
--- a/site-src/pricing.js
+++ b/site-src/pricing.js
@@ -15,7 +15,7 @@ const MARKETING = {
{ label: 'La carte à vos couleurs, dans Apple Wallet et Google Wallet' },
{ label: 'Points ou tampons, récompenses définies par vous' },
{ label: 'Solde et récompenses mis à jour en direct dans le Wallet' },
- { label: 'App MonEspacePro Pro pour 3 employés' },
+ { label: 'App MonEspacePro pour 3 employés' },
{ label: 'Anti-triche : plafond, délai, historique par employé' },
{ label: 'Affichette de comptoir A5 / A6' },
],
diff --git a/site/assets/espace/index-U4aQOhAx.js b/site/assets/espace/index-C1uHARHs.js
similarity index 97%
rename from site/assets/espace/index-U4aQOhAx.js
rename to site/assets/espace/index-C1uHARHs.js
index f9b868e..63eafe2 100644
--- a/site/assets/espace/index-U4aQOhAx.js
+++ b/site/assets/espace/index-C1uHARHs.js
@@ -73,4 +73,4 @@ Minimum version required to store current data is: `+s+`.
`);const o=hy(t,n,l),a=xs.getSymbolSize(t),u=new ry(a);return uy(u,t),cy(u),dy(u,t),Xs(u,n,0),t>=7&&fy(u,t),py(u,o),isNaN(r)&&(r=ro.getBestMask(u,Xs.bind(null,u,n))),ro.applyMask(r,u),Xs(u,n,r),{modules:u,version:t,errorCorrectionLevel:n,maskPattern:r,segments:l}}vf.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=qs.M,l,s;return typeof n<"u"&&(r=qs.from(n.errorCorrectionLevel,qs.M),l=Yl.from(n.version),s=ro.from(n.maskPattern),n.toSJISFunc&&xs.setToSJISFunction(n.toSJISFunc)),gy(t,l,r,s)};var _f={},ca={};(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,o=r.scale||4;return{width:s,scale:s?4:o,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 o=l.modules.size,a=l.modules.data,u=e.getScale(o,s),c=Math.floor((o+s.margin*2)*u),f=s.margin*u,h=[s.color.light,s.color.dark];for(let g=0;g=f&&v>=f&&g"u"&&(!o||!o.getContext)&&(u=o,o=void 0),o||(c=r()),u=t.getOptions(u);const f=t.getImageWidth(s.modules.size,u),h=c.getContext("2d"),g=h.createImageData(f,f);return t.qrToImageData(g.data,s,u),n(h,c,f),h.putImageData(g,0,0),c},e.renderToDataURL=function(s,o,a){let u=a;typeof u>"u"&&(!o||!o.getContext)&&(u=o,o=void 0),u||(u={});const c=e.render(s,o,u),f=u.type||"image/png",h=u.rendererOpts||{};return c.toDataURL(f,h.quality)}})(_f);var Mf={};const yy=ca;function Mu(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function Zs(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function vy(e,t,n){let r="",l=0,s=!1,o=0;for(let a=0;a0&&u>0&&e[a-1]||(r+=s?Zs("M",u+n,.5+c+n):Zs("m",l,0),l=0,s=!1),u+1 ':"",c=" ',f='viewBox="0 0 '+a+" "+a+'"',g=''+u+c+`
`;return typeof r=="function"&&r(null,g),g};const xy=zg,so=vf,Af=_f,wy=Mf;function da(e,t,n,r,l){const s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!xy())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(l=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof l>"u"?(l=r,r=void 0):(l=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(u,c){try{const f=so.create(n,r);u(e(f,t,r))}catch(f){c(f)}})}try{const u=so.create(n,r);l(null,e(u,t,r))}catch(u){l(u)}}Dr.create=so.create;Dr.toCanvas=da.bind(null,Af.render);Dr.toDataURL=da.bind(null,Af.renderToDataURL);Dr.toString=da.bind(null,function(e,t,n){return wy.render(e,n)});const jy={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 zf(e){const t=jy[e.format],n=(e.rewards??[]).filter(c=>c.active!==!1&&c.label.trim()).sort((c,f)=>c.cost-f.cost),r=n.slice(0,t.maxRewards),l=e.pointsMode==="STAMP"?"tampons":"points",s=r.length?t.qrWithRewards:t.qr,[o,a]=w.useState("");w.useEffect(()=>{Dr.toString(e.url,{type:"svg",errorCorrectionLevel:"Q",margin:0,color:{dark:"#111111",light:"#FFFFFF"}}).then(a)},[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:o}}),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 If(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 Ff(e){return new Promise((t,n)=>e.toBlob(r=>r?t(r):n(new Error("Conversion impossible")),"image/png"))}async function Sy(e){const t=await If(e),n=1125,r=432,l=Math.max(n/t.width,r/t.height),s=n/l,o=r/l,a=Object.assign(document.createElement("canvas"),{width:n,height:r});return a.getContext("2d").drawImage(t,(t.width-s)/2,(t.height-o)/2,s,o,0,0,n,r),Ff(a)}async function Cy(e){const t=await If(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),Ff(r)}async function Ey(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&&f>235&&h>235)continue;const v=`${c>>5}${f>>5}${h>>5}`,y=s.get(v)??{n:0,r:0,g:0,b:0};s.set(v,{n:y.n+1,r:y.r+c,g:y.g+f,b:y.b+h})}const o=[...s.values()].sort((u,c)=>c.n-u.n)[0];if(!o)return null;const a=u=>Math.round(u/o.n).toString(16).padStart(2,"0");return`#${a(o.r)}${a(o.g)}${a(o.b)}`.toUpperCase()}function Au(e,t){const n=s=>{const[o,a,u]=[1,3,5].map(c=>{const f=parseInt(s.slice(c,c+2),16)/255;return f<=.03928?f/12.92:((f+.055)/1.055)**2.4});return .2126*o+.7152*a+.0722*u},[r,l]=[n(e),n(t)].sort((s,o)=>o-s);return(r+.05)/(l+.05)}const ei=["Identité","Couleurs","Règle de points","Récompenses","Récapitulatif"];function Ny(e){return{programName:`Fidélité ${e.name}`.slice(0,40),backgroundColor:"#1F2937",foregroundColor:"#FFFFFF",labelColor:"#D1D5DB",pointsMode:"AMOUNT",pointsPerEuro:1,rewards:[]}}function Df({store:e,onSaved:t,base:n=`/api/admin/stores/${e.id}/card-design`,posterHref:r=`/magasins/${e.id}/affichette`,draftNote:l}){const[s,o]=w.useState(0),[a,u]=w.useState(null),[c,f]=w.useState({logoUrl:null,stripUrl:null}),[h,g]=w.useState(!1),[v,y]=w.useState("apple"),[j,E]=w.useState(null),[p,d]=w.useState(!1),[m,x]=w.useState(null);function C(L){const{logoUrl:ne,stripUrl:je,...Ve}=L;u(Ve),f({logoUrl:eo(ne),stripUrl:eo(je)}),g(!0)}if(w.useEffect(()=>{b.get(n).then(L=>L?C(L):u(Ny(e))).catch(L=>E(L.message))},[n,e]),w.useEffect(()=>{c.logoUrl&&Ey(c.logoUrl).then(x)},[c.logoUrl]),!a)return j?i.jsx("div",{className:"alert error",children:j}):i.jsx("p",{className:"muted",children:"Chargement…"});const S=(L,ne)=>u({...a,[L]:ne});async function N(){E(null),d(!0);try{const{programName:L,backgroundColor:ne,foregroundColor:je,labelColor:Ve,pointsMode:Xe,pointsPerEuro:R}=a,M=a.rewards.map(({id:A,label:W,cost:X,active:tn})=>({id:A,label:W,cost:X,active:tn}));return C(await b.put(n,{programName:L,backgroundColor:ne,foregroundColor:je,labelColor:Ve,pointsMode:Xe,pointsPerEuro:R,rewards:M})),t(),!0}catch(L){return E(L.message),!1}finally{d(!1)}}async function P(){await N()&&o(L=>Math.min(L+1,ei.length-1))}async function z(L,ne){var Ve;const je=(Ve=ne.target.files)==null?void 0:Ve[0];if(ne.target.value="",!!je&&!(!h&&!await N())){d(!0),E(null);try{const Xe=L==="logo"?await Cy(je):await Sy(je),R=new FormData;R.append("file",Xe,`${L}.png`),C(await b.post(`${n}/images/${L}`,R))}catch(Xe){E(Xe.message)}finally{d(!1)}}}const _={...a,...c,storeName:e.name},Y=Au(a.backgroundColor,a.foregroundColor),Te=Au(a.backgroundColor,a.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:ei.map((L,ne)=>i.jsx("li",{children:i.jsxs("button",{type:"button","aria-current":ne===s?"step":void 0,onClick:()=>o(ne),children:[ne+1," · ",L]})},L))}),j&&i.jsx("div",{className:"alert error",role:"alert",children:j}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[s===0&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Identité"}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"programName",children:"Nom du programme *"}),i.jsx("input",{id:"programName",className:"input",maxLength:40,value:a.programName,onChange:L=>S("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=>z("logo",L),disabled:p})]}),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=>z("strip",L),disabled:p})]}),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"}),m&&m!==a.backgroundColor&&i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("span",{style:{width:28,height:28,borderRadius:8,background:m,border:"1px solid var(--border)"}}),i.jsxs("span",{children:["Couleur extraite du logo : ",m]}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>S("backgroundColor",m),children:"Utiliser comme fond"})]}),[["backgroundColor","Fond"],["foregroundColor","Texte"],["labelColor","Libellés"]].map(([L,ne])=>i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:L,children:ne}),i.jsxs("div",{className:"color-row",children:[i.jsx("input",{type:"color","aria-label":`${ne} (sélecteur)`,value:a[L],onChange:je=>S(L,je.target.value.toUpperCase())}),i.jsx("input",{id:L,className:"input",style:{maxWidth:160},value:a[L],pattern:"#[0-9A-Fa-f]{6}",onChange:je=>S(L,je.target.value)})]})]},L)),Y<4.5&&i.jsxs("div",{className:"alert warn",children:["Contraste texte/fond insuffisant (",Y.toFixed(1),":1, minimum 4,5:1) : le solde sera difficile à lire."]}),Te<3&&i.jsxs("div",{className:"alert warn",children:["Contraste libellés/fond faible (",Te.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:a.pointsMode==="AMOUNT",onChange:()=>S("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:a.pointsMode==="STAMP",onChange:()=>S("pointsMode","STAMP")}),i.jsxs("span",{children:[i.jsx("strong",{children:"Tampons"}),i.jsx("br",{}),i.jsx("span",{className:"muted",children:"1 tampon par passage"})]})]})]}),a.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:a.pointsPerEuro,onChange:L=>S("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*a.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(ky,{rewards:a.rewards,unit:a.pointsMode==="STAMP"?"tampons":"points",onChange:L=>S("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:a.programName})]}),i.jsxs("li",{children:["Règle : ",a.pointsMode==="STAMP"?"1 tampon par passage":`${a.pointsPerEuro} point(s) par euro`]}),i.jsxs("li",{children:["Récompenses : ",a.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(zf,{format:"A5",url:e.enrollUrl,storeName:e.name,programName:a.programName,logoUrl:c.logoUrl,backgroundColor:a.backgroundColor,foregroundColor:a.foregroundColor,labelColor:a.labelColor,rewards:a.rewards,pointsMode:a.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(We,{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:()=>o(s-1),children:"Précédent"}),sy("apple"),children:"Apple Wallet"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":v==="google",onClick:()=>y("google"),children:"Google Wallet"})]}),v==="apple"?i.jsx(Mg,{d:_}):i.jsx(Ag,{d:_}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Aperçu indicatif — QR et solde fictifs."})]})]})}function ky({rewards:e,unit:t,onChange:n}){const r=(l,s)=>n(e.map((o,a)=>a===l?{...o,...s}:o));return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Récompenses"}),e.length===0&&i.jsxs("p",{className:"muted",style:{margin:0},children:["Aucune récompense. Exemple : « Café offert » pour 10 ",t,"."]}),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:o=>r(s,{label:o.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:o=>r(s,{cost:Number(o.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((o,a)=>a!==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 Uf={MANAGER:"Dirigeant",EMPLOYEE:"Employé"};function Py({storeId:e}){const t=`/api/admin/stores/${e}/staff`,[n,r]=w.useState([]),[l,s]=w.useState(null),[o,a]=w.useState(null),u=w.useRef(null),c=w.useRef(null),f=w.useCallback(()=>{b.get(t).then(r).catch(y=>s(y.message))},[t]);w.useEffect(f,[f]);function h(y){var j;a(y),(j=c.current)==null||j.showModal(),f()}async function g(y){try{await b.patch(`${t}/${y.id}`,{active:!y.active}),f()}catch(j){s(j.message)}}async function v(y){if(window.confirm(`Générer un nouveau mot de passe pour ${y.displayName} ? Ses sessions seront fermées.`))try{h(await b.post(`${t}/${y.id}/reset-password`))}catch(j){s(j.message)}}return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",children:[i.jsx("h2",{children:"Employés"}),i.jsx("button",{className:"btn",onClick:()=>{var y;return(y=u.current)==null?void 0:y.showModal()},children:"+ Nouvel employé"})]}),l&&i.jsx("div",{className:"alert error",role:"alert",children:l}),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:"Nom"}),i.jsx("th",{scope:"col",children:"E-mail"}),i.jsx("th",{scope:"col",children:"Rôle"}),i.jsx("th",{scope:"col",children:"Statut"}),i.jsx("th",{scope:"col",children:i.jsx("span",{className:"sr-only",children:"Actions"})})]})}),i.jsx("tbody",{children:n.map(y=>i.jsxs("tr",{style:{opacity:y.active?1:.6},children:[i.jsx("td",{style:{paddingLeft:24,fontWeight:600},children:y.displayName}),i.jsx("td",{children:y.email}),i.jsx("td",{children:Uf[y.role]}),i.jsx("td",{children:y.active?i.jsx("span",{className:"badge ACTIVE",children:"Actif"}):i.jsx("span",{className:"badge DRAFT",children:"Désactivé"})}),i.jsxs("td",{style:{textAlign:"right",whiteSpace:"nowrap"},children:[i.jsx("button",{className:"btn secondary small",onClick:()=>v(y),children:"Nouveau mot de passe"})," ",i.jsx("button",{className:"btn secondary small",onClick:()=>g(y),children:y.active?"Désactiver":"Réactiver"})]})]},y.id))})]})}),n.length===0&&i.jsx("p",{className:"muted",style:{padding:24,margin:0,textAlign:"center"},children:"Aucun employé. Créez au moins un dirigeant pour que le magasin puisse utiliser l'app Pro."})]}),i.jsx("dialog",{ref:u,"aria-labelledby":"new-staff-title",children:i.jsx(Ry,{base:t,onCancel:()=>{var y;return(y=u.current)==null?void 0:y.close()},onCreated:y=>{var j;(j=u.current)==null||j.close(),h(y)}})}),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:o==null?void 0:o.displayName})," (",o==null?void 0:o.email,"). Il ne sera plus affiché ensuite."]}),i.jsx("div",{className:"password-box",children:o==null?void 0:o.provisionalPassword}),i.jsxs("div",{className:"row",style:{justifyContent:"flex-end"},children:[i.jsx("button",{className:"btn secondary",onClick:()=>{var y;return(y=navigator.clipboard)==null?void 0:y.writeText((o==null?void 0:o.provisionalPassword)??"")},children:"Copier"}),i.jsx("button",{className:"btn",onClick:()=>{var y;return(y=c.current)==null?void 0:y.close()},children:"J'ai noté le mot de passe"})]})]})})]})}function Ry({base:e,onCancel:t,onCreated:n}){const[r,l]=w.useState(""),[s,o]=w.useState(""),[a,u]=w.useState("EMPLOYEE"),[c,f]=w.useState(null),[h,g]=w.useState(!1);async function v(y){y.preventDefault(),g(!0),f(null);try{n(await b.post(e,{displayName:r,email:s,role:a})),l(""),o(""),u("EMPLOYEE")}catch(j){f(j.message)}finally{g(!1)}}return i.jsxs("form",{className:"dialog-body",onSubmit:v,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:y=>l(y.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:y=>o(y.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(y=>i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"role",checked:a===y,onChange:()=>u(y)}),i.jsxs("span",{children:[i.jsx("strong",{children:Uf[y]}),i.jsx("br",{}),i.jsx("span",{className:"muted",style:{fontSize:14},children:y==="MANAGER"?"Toute la configuration : carte, modules, campagnes, employés, statistiques":"Scanne les cartes et crédite les points, voit ses opérations"})]})]},y))})]}),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:h,children:"Créer le compte"})]})]})}const zu={ACTIVE:["Actif","ACTIVE"],INCOMPLETE:["En attente de paiement","DRAFT"],PAST_DUE:["Impayé","SUSPENDED"],CANCELED:["Résilié","CLOSED"]},Ty={multiStore:"Carte commune à plusieurs magasins"},Iu=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),Gn=e=>new Date(e).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"});function Ly({storeId:e,contactEmail:t,onChange:n}){const[r,l]=w.useState(null),[s,o]=w.useState(null),[a,u]=w.useState(null),[c,f]=w.useState(!1),[h,g]=w.useState(null),[v,y]=w.useState(null),j=w.useCallback(()=>{b.get(`/api/admin/stores/${e}/billing`).then(l).catch(S=>o(S.message))},[e]);w.useEffect(j,[j]);async function E(S,N,P){f(!0),o(null);try{const z=await b.post(N,P);u({...z,label:S}),j(),n()}catch(z){o(z.message)}finally{f(!1)}}if(!r)return s?i.jsx("div",{className:"alert error",children:s}):i.jsx("p",{className:"muted",children:"Chargement…"});const p=r.subscription,d=p&&p.status!=="CANCELED"&&p.hasSubscription?r.catalog.find(S=>S.plan===p.plan):null,m=!d,x=h??(p==null?void 0:p.plan)??"PRO",C=v??(p==null?void 0:p.interval)??"MONTH";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("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}${p.legacyPrice?" (tarif fondateur)":""} — ${p.interval==="YEAR"?"annuelle":"mensuelle"}`:"Aucune formule souscrite. Sans abonnement actif, le magasin a les droits de la formule Essentiel."})]}),i.jsx("span",{className:`badge ${p?zu[p.status][1]:"DRAFT"}`,children:p?zu[p.status][0]:"Aucun abonnement"})]}),(p==null?void 0:p.cancelAtPeriodEnd)&&p.currentPeriodEnd&&i.jsxs("div",{className:"alert warn",children:["Résiliation demandée : l'abonnement s'arrête le ",i.jsx("strong",{children:Gn(p.currentPeriodEnd)}),"."]}),(p==null?void 0:p.currentPeriodEnd)&&p.status==="ACTIVE"&&!p.cancelAtPeriodEnd&&i.jsxs("p",{style:{margin:0},children:["Prochain prélèvement le ",i.jsx("strong",{children:Gn(p.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:()=>E("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:()=>E("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."})]})]}),m&&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":C==="MONTH",onClick:()=>y("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":C==="YEAR",onClick:()=>y("YEAR"),children:"Annuel — 2 mois offerts"})]})]}),i.jsx("div",{className:"mode-cards",role:"radiogroup","aria-label":"Formule",children:r.catalog.map(S=>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:x===S.plan,onChange:()=>g(S.plan)}),i.jsx("strong",{style:{fontSize:18},children:S.name}),S.plan==="PRO"&&i.jsx("span",{className:"badge ACTIVE",style:{height:22},children:"Conseillée"})]}),i.jsxs("span",{style:{fontSize:24,fontWeight:800},children:[Iu(S.priceCents[C]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",C==="YEAR"?"an":"mois",S.plan==="RESEAU"?" / magasin":""]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:S.tagline}),i.jsxs("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:[i.jsx("li",{children:S.limits.maxStaff?`${S.limits.maxStaff} employés`:"Employés illimités"}),i.jsx("li",{children:"Carte Wallet, points ou tampons, récompenses, mises à jour en direct"}),S.features.map(N=>i.jsx("li",{children:Ty[N]??N},N))]}),i.jsx("span",{style:{fontSize:14,fontWeight:700},children:S.modules.length?`Modules inclus (${S.modules.length})`:"Aucun module inclus"}),S.modules.length>0&&i.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:S.modules.map(N=>i.jsx("li",{title:N.tagline,children:N.name},N.id))})]},S.plan))}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14},children:["Lien permanent (il ne périme pas) : ",i.jsx("a",{href:r.subscribeUrl,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:r.subscribeUrl}),". Le commerçant pourra 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:()=>E("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:x,interval:C,sendEmail:!0}),children:["Envoyer le lien à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>E("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:x,interval:C,sendEmail:!1}),children:"Enregistrer la formule sans envoyer"})]})]}),a&&i.jsxs("div",{className:"alert ok",children:[a.label," ",a.emailedTo?i.jsxs(i.Fragment,{children:["envoyé à ",i.jsx("strong",{children:a.emailedTo}),". "]}):"créé. ",i.jsx("a",{href:a.url,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:a.url})]}),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(S=>i.jsxs("tr",{children:[i.jsx("td",{style:{paddingLeft:24,fontWeight:600},children:S.number}),i.jsx("td",{style:{fontSize:14},children:S.description.replace("Abonnement MonEspacePro — ","")}),i.jsxs("td",{children:[Gn(S.periodStart)," → ",Gn(S.periodEnd)]}),i.jsx("td",{className:"num",children:Iu(S.amountCents)}),i.jsx("td",{children:S.paidAt?i.jsxs("span",{className:"badge ACTIVE",children:["Payée le ",Gn(S.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:()=>to(`/api/admin/invoices/${S.id}/pdf`,`${S.number}.pdf`).catch(N=>o(N.message)),children:"PDF"})})]},S.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 Fu=e=>new Date(e).toLocaleString("fr-FR",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"});function _y({storeId:e,storeName:t}){const[n,r]=w.useState(null),[l,s]=w.useState(""),[o,a]=w.useState(null),[u,c]=w.useState(null),[f,h]=w.useState(null),[g,v]=w.useState(!1),y=w.useCallback(()=>{b.get(`/api/admin/stores/${e}/campaigns`).then(r).catch(d=>c(d.message))},[e]);if(w.useEffect(y,[y]),!n)return u?i.jsx("div",{className:"alert error",children:u}):i.jsx("p",{className:"muted",children:"Chargement…"});const j=l.trim(),E=!n.allowed||!!n.nextAllowedAt;async function p(){if(confirm(`Envoyer ce message aux ${n.audience.cards} cartes de ${t} ?
-« ${j} »`)){v(!0),c(null);try{await b.post(`/api/admin/stores/${e}/campaigns`,{message:j,title:(o??n.defaultTitle).trim()}),s(""),h("Campagne envoyée. Les cartes se mettent à jour dans les minutes qui suivent."),y()}catch(d){c(d.message)}finally{v(!1)}}}return i.jsxs(i.Fragment,{children:[u&&i.jsx("div",{className:"alert error",role:"alert",children:u}),f&&i.jsx("div",{className:"alert ok",role:"status",children:f}),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:o??n.defaultTitle,onChange:d=>a(d.target.value),disabled:E||g}),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:E||g}),i.jsxs("div",{className:"row between",children:[i.jsxs("span",{className:"muted",style:{fontSize:14},children:[j.length," / ",n.maxLength," caractères · 1 campagne toutes les ",n.minIntervalHours," h maximum"]}),i.jsx("button",{className:"btn",disabled:E||g||j.length<5,onClick:p,children:g?"Envoi…":"Envoyer la campagne"})]}),n.nextAllowedAt&&i.jsxs("div",{className:"alert warn",children:["Prochain envoi possible le ",Fu(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:Fu(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))})]})})]})]})}function My({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 Ay({f:e,value:t,onChange:n}){var a;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&&((a=e.variables)!=null&&a.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,o=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:o,onChange:u=>n(u.target.value)}):i.jsx("input",{id:r,className:"input",type:s.type==="url"?"url":"text",maxLength:s.maxLength,value:o,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:[o.length," / ",s.maxLength]})]}),s.type!=="url"&&o!==s.default&&i.jsx("button",{type:"button",className:"link",style:{fontSize:14},onClick:()=>n(s.default),children:"Remettre le texte par défaut"})]})}function zy({storeId:e,storeName:t,initial:n,onChanged:r}){const[l,s]=w.useState(n),[o,a]=w.useState(n.config),[u,c]=w.useState(!1),[f,h]=w.useState(!1),[g,v]=w.useState(null),[y,j]=w.useState(null),E=`/api/admin/stores/${e}/modules/${l.id}`,p=x=>{s(x),a(x.config)};w.useEffect(()=>{u&&b.get(E).then(p).catch(x=>v(x.message))},[u,E]);async function d(x,C){h(!0),v(null),j(null);try{p(await x()),j(C),r()}catch(S){v(S.message)}finally{h(!1)}}const m=JSON.stringify(o)!==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"},children:[i.jsxs("div",{className:"row",style:{gap:10,alignItems:"center"},children:[i.jsx("h2",{style:{margin:0},children:l.name}),i.jsx(My,{m:l}),l.available&&i.jsx("span",{className:`badge ${l.config.enabled?"ACTIVE":"DRAFT"}`,children:l.config.enabled?"Activé":"Désactivé"})]}),i.jsx("p",{className:"muted",style:{margin:"6px 0 0"},children:l.description})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[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:f,value:l.override===null?"plan":l.override?"add":"remove",onChange:x=>{const C=x.target.value==="plan"?null:x.target.value==="add";d(()=>b.put(`${E}/override`,{value:C}),C===null?"Module remis selon la formule.":C?"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"})]})]}),g&&i.jsx("div",{className:"alert error",role:"alert",children:g}),y&&i.jsx("div",{className:"alert ok",role:"status",children:y}),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."}),i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontWeight:700},children:[i.jsx("input",{type:"checkbox",checked:!!o.enabled,onChange:x=>a({...o,enabled:x.target.checked})}),"Module activé"]}),l.fields.map(x=>i.jsx(Ay,{f:x,value:o[x.key],onChange:C=>a({...o,[x.key]:C})},x.key)),l.stats&&i.jsx("div",{className:"row",style:{gap:24},children:Object.entries(l.stats).map(([x,C])=>i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:22,fontWeight:800},children:C??"—"}),i.jsx("div",{className:"muted",style:{fontSize:14},children:x})]},x))}),l.id==="stats"&&i.jsx(We,{to:"../statistiques",children:"Voir les statistiques du magasin →"}),i.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[m&&i.jsx("button",{type:"button",className:"btn secondary",disabled:f,onClick:()=>a(l.config),children:"Annuler"}),i.jsx("button",{type:"button",className:"btn",disabled:f||!m,onClick:()=>d(()=>b.put(E,o),"Réglages enregistrés."),children:f?"Enregistrement…":"Enregistrer"})]}),l.id==="campaigns"&&l.available&&l.config.enabled&&i.jsx(_y,{storeId:e,storeName:t})]})]})}function Iy({storeId:e,storeName:t}){const[n,r]=w.useState(null),[l,s]=w.useState(null),o=w.useCallback(()=>{b.get(`/api/admin/stores/${e}/modules`).then(r).catch(u=>s(u.message))},[e]);if(w.useEffect(o,[o]),!n)return l?i.jsx("div",{className:"alert error",children:l}):i.jsx("p",{className:"muted",children:"Chargement…"});const a=n.filter(u=>u.available&&u.config.enabled).length;return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"muted",style:{margin:0},children:[a," module(s) actif(s) sur ",n.length,". Chaque module est inclus ou non dans la formule ; vous pouvez l'ajouter ou le retirer sur mesure, et tous ses textes et réglages sont personnalisables. Le dirigeant peut aussi les régler depuis l'app Pro."]}),n.map(u=>i.jsx(zy,{storeId:e,storeName:t,initial:u,onChanged:o},u.id))]})}const Fy=[[30,"30 jours"],[90,"3 mois"],[365,"12 mois"]],ti=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:e>=1e5?0:2}),rn=e=>e.toLocaleString("fr-FR");function Dy({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 Ot({label:e,value:t,hint:n,change:r}){return i.jsxs("div",{className:"card",style:{padding:16,display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{className:"muted",style:{fontSize:14},children:e}),i.jsx("span",{style:{fontSize:26,fontWeight:800},children:t}),i.jsxs("span",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[r!==void 0&&i.jsx(Dy,{value:r}),n&&i.jsx("span",{className:"muted",style:{fontSize:13},children:n})]})]})}function Uy({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 Oy({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 o=e.values[l][s];return i.jsx("td",{title:`${r} ${s} h : ${o} passage(s)`,style:{padding:0,height:26,borderRadius:4,background:o?`color-mix(in srgb, var(--primary) ${Math.round(15+o/n*85)}%, transparent)`:"var(--surface-2)"}},s)})]},r))})]})})}function By({storeId:e,storeSlug:t}){const[n,r]=w.useState(30),[l,s]=w.useState(null),[o,a]=w.useState(null),[u,c]=w.useState(null);w.useEffect(()=>{a(null),b.get(`/api/admin/stores/${e}/stats?days=${n}`).then(s).catch(v=>a(v.message))},[e,n]);async function f(v){c(v);try{const y=new Date().toISOString().slice(0,10);v==="customers"?await to(`/api/admin/stores/${e}/export/customers`,`clients-${t}-${y}.csv`):await to(`/api/admin/stores/${e}/export/transactions?days=${n}`,`operations-${t}-${n}j-${y}.csv`)}catch(y){a(y.message)}finally{c(null)}}const h=l==null?void 0:l.kpis,g=(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:"row",style:{gap:8},children:Fy.map(([v,y])=>i.jsx("button",{type:"button",className:"chip","aria-pressed":n===v,onClick:()=>r(v),children:y},v))}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>f("customers"),children:u==="customers"?"Export…":"Exporter les clients (CSV)"}),i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>f("transactions"),children:u==="transactions"?"Export…":"Exporter les opérations (CSV)"})]})]}),o&&i.jsx("div",{className:"alert error",role:"alert",children:o}),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||!h?!o&&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(Ot,{label:"Passages",value:rn(h.visits),change:h.visitsChange,hint:"vs période précédente"}),i.jsx(Ot,{label:"Nouvelles cartes",value:rn(h.newCards),change:h.newCardsChange,hint:`${rn(h.cardsTotal)} au total`}),i.jsx(Ot,{label:"Clients actifs",value:rn(h.activeCustomers),hint:`${h.visitsPerCustomer.toLocaleString("fr-FR")} passage(s) par client`}),i.jsx(Ot,{label:"Clients fidèles",value:h.returningRate===null?"—":`${h.returningRate.toLocaleString("fr-FR")} %`,hint:"venus au moins 2 fois"}),l.pointsMode==="AMOUNT"&&i.jsx(Ot,{label:"Achats enregistrés",value:ti(h.revenueCents),hint:h.averageBasketCents===null?void 0:`panier moyen ${ti(h.averageBasketCents)}`}),i.jsx(Ot,{label:"Récompenses",value:rn(h.rewardsRedeemed),hint:`${rn(h.pointsGiven)} ${g} distribués`}),i.jsx(Ot,{label:"Cartes dans Apple Wallet",value:h.appleWalletRate===null?"—":`${h.appleWalletRate.toLocaleString("fr-FR")} %`,hint:"iPhone joignables"})]}),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(Uy,{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(Oy,{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",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((v,y)=>i.jsxs("tr",{children:[i.jsx("td",{children:v.firstName}),i.jsx("td",{className:"num",children:v.visits}),l.pointsMode==="AMOUNT"&&i.jsx("td",{className:"num",children:ti(v.amountCents)}),i.jsx("td",{className:"num",children:v.balance})]},y))})]})})]})]})]})}const $y=[["infos","Infos"],["carte","Carte de fidélité"],["employes","Employés"],["modules","Modules"],["statistiques","Statistiques"],["facturation","Facturation"]];function by(){var c;const{id:e}=of(),[t,n]=w.useState(null),[r,l]=w.useState(null),[s,o]=w.useState(null),a=w.useCallback(()=>{b.get(`/api/admin/stores/${e}`).then(n).catch(f=>l(f.message))},[e]);w.useEffect(a,[a]);async function u(f,h){if(!(h&&!window.confirm(h))){l(null);try{await b.patch(`/api/admin/stores/${e}/status`,{status:f}),a()}catch(g){l(g.message)}}}return t?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx(We,{to:"/magasins",children:"← Magasins"}),i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("h1",{children:t.name}),i.jsx(hf,{status:t.status}),((c=t.subscription)==null?void 0:c.stripeSubscriptionId)&&t.subscription.status!=="CANCELED"&&i.jsx(vl,{to:"facturation",className:"badge DRAFT",style:{textDecoration:"none"},title:"Formule d'abonnement",children:_n[t.subscription.plan]})]}),i.jsxs("p",{className:"muted",style:{margin:0},children:[t.city," · ",t.counts.cards," clients · ",t.counts.staff," employés"]})]}),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"})]})]}),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(vl,{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:$y.map(([f,h])=>i.jsx(vl,{to:f,children:h},f))}),i.jsxs(qi,{children:[i.jsx(G,{index:!0,element:i.jsx(yl,{to:"infos",replace:!0})}),i.jsx(G,{path:"infos",element:i.jsx(mf,{initial:t,submitLabel:"Enregistrer",onSubmit:async f=>{const{name:h,siret:g,addressLine:v,postalCode:y,city:j,contactName:E,contactEmail:p,contactPhone:d,maxAmountEuros:m,minScanIntervalMin:x}=f;await b.patch(`/api/admin/stores/${e}`,{name:h,siret:g,addressLine:v,postalCode:y,city:j,contactName:E,contactEmail:p,contactPhone:d,maxAmountEuros:m,minScanIntervalMin:x}),o("Modifications enregistrées."),a()}},t.id)}),i.jsx(G,{path:"carte",element:i.jsx(Df,{store:t,onSaved:a})}),i.jsx(G,{path:"employes",element:i.jsx(Py,{storeId:t.id})}),i.jsx(G,{path:"modules",element:i.jsx(Iy,{storeId:t.id,storeName:t.name})}),i.jsx(G,{path:"statistiques",element:i.jsx(By,{storeId:t.id,storeSlug:t.slug})}),i.jsx(G,{path:"facturation",element:i.jsx(Ly,{storeId:t.id,contactEmail:t.contactEmail,onChange:a})})]})]}):r?i.jsx("div",{className:"alert error",children:r}):i.jsx("p",{className:"muted",children:"Chargement…"})}function Du({merchant:e=!1}){const{id:t}=of(),n=e?"/api/staff/store":`/api/admin/stores/${t}`,r=e?"/api/staff/card-design":`/api/admin/stores/${t}/card-design`,[l,s]=ra(),o=l.get("format")==="A6"?"A6":"A5",[a,u]=w.useState(null),[c,f]=w.useState(null),[h,g]=w.useState(null);return w.useEffect(()=>{Promise.all([b.get(n),b.get(r)]).then(([v,y])=>{u(v),f(y)}).catch(v=>g(v.message))},[n,r]),h?i.jsx("div",{className:"alert error",style:{margin:24},children:h}):a?c?i.jsxs("div",{className:"poster-page",children:[i.jsx("style",{children:`@page{size:${o};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(We,{to:e?"/espace":`/magasins/${t}/carte`,children:"← Retour à la carte"}),i.jsxs("div",{className:"row",style:{gap:8},children:[["A5","A6"].map(v=>i.jsx("button",{type:"button",className:"chip","aria-pressed":o===v,onClick:()=>s({format:v}),children:v},v)),i.jsx("button",{type:"button",className:"btn",onClick:()=>window.print(),children:"Imprimer"})]})]}),a.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(zf,{format:o,url:a.enrollUrl,storeName:a.name,programName:c.programName,logoUrl:eo(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:a.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 Wy=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),Uu=["ESSENTIEL","PRO","RESEAU"],Vy=[["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 du dirigeant",{autoComplete:"name",maxLength:120}],["contactPhone","Téléphone",{autoComplete:"tel",type:"tel"}],["contactEmail","E-mail (votre identifiant)",{autoComplete:"email",type:"email"}]];function Hy(){const[e]=ra(),t=(e.get("formule")??"").toUpperCase(),[n,r]=w.useState(Uu.includes(t)?t:"PRO"),[l,s]=w.useState(e.get("periode")==="annuel"?"YEAR":"MONTH"),[o,a]=w.useState([]),[u,c]=w.useState({name:"",siret:"",addressLine:"",postalCode:"",city:"",contactName:"",contactPhone:"",contactEmail:"",password:""}),[f,h]=w.useState(!1),[g,v]=w.useState(e.get("annule")?"Paiement annulé : rien n’a été prélevé. Vous pouvez reprendre quand vous voulez.":null),[y,j]=w.useState(!1);w.useEffect(()=>{const d=m=>m.persisted&&j(!1);return window.addEventListener("pageshow",d),()=>window.removeEventListener("pageshow",d)},[]),w.useEffect(()=>{Tu.get("/api/public/signup/plans").then(a).catch(()=>{})},[]);async function E(d){d.preventDefault(),j(!0),v(null);try{const{url:m}=await Tu.post("/api/public/signup",{...u,plan:n,interval:l,cgv:f});window.location.assign(m)}catch(m){v(m.message),j(!1),window.scrollTo({top:0,behavior:"smooth"})}}const p=o.find(d=>d.plan===n);return i.jsx("main",{style:{minHeight:"100vh",padding:"32px 16px"},children:i.jsxs("form",{onSubmit:E,style:{maxWidth:720,margin:"0 auto",display:"flex",flexDirection:"column",gap:24},children:[i.jsx("a",{href:"https://monespacepro.eu/tarif/",style:{textDecoration:"none",color:"inherit"},children:i.jsx(Fr,{admin:!1})}),i.jsxs("div",{children:[i.jsx("h1",{children:"Créer mon programme de fidélité"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Sans engagement, résiliable à tout moment. Votre espace est prêt dès le paiement validé."})]}),g&&i.jsx("div",{className:"alert error",role:"alert",children:g}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsx("h2",{children:"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":l==="MONTH",onClick:()=>s("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":l==="YEAR",onClick:()=>s("YEAR"),children:"Annuel — 2 mois offerts"})]}),i.jsx("div",{className:"mode-cards",role:"radiogroup","aria-label":"Formule",children:(o.length?o:Uu.map(d=>({plan:d,name:_n[d],tagline:"",priceCents:{MONTH:0,YEAR:0},modules:[],limits:{maxStaff:null}}))).map(d=>i.jsxs("label",{className:"mode-card",style:{flexDirection:"column",gap:6},children:[i.jsxs("span",{className:"row",style:{gap:10},children:[i.jsx("input",{type:"radio",name:"plan",checked:n===d.plan,onChange:()=>r(d.plan)}),i.jsx("strong",{style:{fontSize:18},children:d.name})]}),d.priceCents[l]>0&&i.jsxs("span",{style:{fontSize:22,fontWeight:800},children:[Wy(d.priceCents[l]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",l==="YEAR"?"an":"mois"]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:d.tagline})]},d.plan))}),p&&i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14},children:[p.limits.maxStaff?`${p.limits.maxStaff} employés`:"Employés illimités"," ·"," ",p.modules.length?`Modules : ${p.modules.map(d=>d.name).join(", ")}`:"Sans module complémentaire"]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsx("h2",{children:"Votre commerce"}),Vy.map(([d,m,x])=>i.jsxs("div",{className:"field",children:[i.jsxs("label",{htmlFor:`s-${d}`,children:[m," *"]}),i.jsx("input",{id:`s-${d}`,className:"input",required:!0,value:u[d],onChange:C=>c({...u,[d]:C.target.value}),...x})]},d)),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:d=>c({...u,password:d.target.value})}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"10 caractères minimum. Il ouvre votre espace web et l’app MonEspacePro Pro."})]})]}),i.jsxs("label",{className:"row",style:{gap:10,alignItems:"flex-start"},children:[i.jsx("input",{type:"checkbox",required:!0,checked:f,onChange:d=>h(d.target.checked),style:{marginTop:4}}),i.jsxs("span",{children:["J’accepte les ",i.jsx("a",{href:"https://monespacepro.eu/cgv/",target:"_blank",rel:"noreferrer",children:"conditions générales de vente"})," et la"," ",i.jsx("a",{href:"https://monespacepro.eu/confidentialite/",target:"_blank",rel:"noreferrer",children:"politique de confidentialité"}),"."]})]}),i.jsx("button",{className:"btn",disabled:y,children:y?"Redirection vers le paiement…":"Continuer vers le paiement"}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14,textAlign:"center"},children:["Paiement sécurisé par Stripe (carte ou prélèvement SEPA). Déjà inscrit ? ",i.jsx(We,{to:"/espace",children:"Se connecter"})]})]})})}function Qy({onLogin:e}){const t=en(),[n]=ra(),r=n.has("bienvenue"),[l,s]=w.useState(""),[o,a]=w.useState(""),[u,c]=w.useState(null),[f,h]=w.useState(!1);async function g(v){v.preventDefault(),h(!0),c(null);try{await Sg(l,o),e(),t("/espace",{replace:!0})}catch(y){c(r&&y instanceof ms&&y.status===401?"Votre espace est en cours de création. Réessayez dans quelques secondes.":y.message)}finally{h(!1)}}return i.jsx("main",{style:{minHeight:"100vh",display:"grid",placeItems:"center",padding:16},children:i.jsxs("form",{className:"card",onSubmit:g,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 Pro."})]}),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:v=>s(v.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:o,onChange:v=>a(v.target.value)})]}),i.jsx("button",{className:"btn",disabled:f,children:f?"Connexion…":"Se connecter"}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14,textAlign:"center"},children:["Pas encore client ? ",i.jsx(We,{to:"/inscription",children:"Créer mon programme"})]})]})})}function Ky(){const[e,t]=w.useState(null),[n,r]=w.useState(null),l=w.useCallback(()=>{b.get("/api/staff/store").then(t).catch(s=>r(s instanceof ms&&s.status===403?"Cet espace est réservé au Dirigeant du magasin. Utilisez l’app MonEspacePro Pro pour scanner les cartes.":s.message))},[]);return w.useEffect(l,[l]),i.jsxs("div",{style:{minHeight:"100vh"},children:[i.jsxs("header",{className:"row between",style:{padding:"16px 24px",borderBottom:"1px solid var(--border)"},children:[i.jsx(Fr,{admin:!1}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:ia,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("div",{children:[i.jsx("h1",{children:e.name}),i.jsxs("p",{className:"muted",style:{margin:0},children:[e.subscription?`Formule ${_n[e.subscription.plan]}`:"Aucune formule"," ·"," ",e.status==="ACTIVE"?"Programme ouvert à vos clients":e.status==="DRAFT"?"Programme pas encore ouvert":"Programme suspendu"]})]}),e.subscribeUrl&&i.jsxs("div",{className:"alert warn row between",style:{gap:12},children:[i.jsx("span",{children:"Votre abonnement n’est pas encore actif : le programme s’ouvrira dès le paiement validé."}),i.jsx("a",{className:"btn small",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é."}),e.status==="ACTIVE"&&i.jsxs("div",{className:"alert ok",children:["Vos clients s’inscrivent sur ",i.jsx("a",{href:e.enrollUrl,target:"_blank",rel:"noreferrer",children:e.enrollUrl})," (QR code de l’affichette)."]}),i.jsx("p",{className:"muted",style:{margin:0},children:"Employés, modules (campagnes, anniversaire, relances…) et statistiques : dans l’app MonEspacePro Pro, avec les mêmes identifiants."}),i.jsx(Df,{store:e,onSaved:l,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 Yy(){const e=en(),t=It(),[n,r]=w.useState(wg()),l=t.pathname.startsWith("/espace");w.useEffect(()=>{xg(()=>{r(null),e(l?"/espace":"/connexion")})},[e,l]);const s=i.jsx(Qy,{onLogin:()=>r("staff")});return n!=="admin"||t.pathname==="/inscription"?i.jsxs(qi,{children:[i.jsx(G,{path:"/inscription",element:i.jsx(Hy,{})}),n==="staff"?i.jsxs(i.Fragment,{children:[i.jsx(G,{path:"/espace/affichette",element:i.jsx(Du,{merchant:!0})}),i.jsx(G,{path:"/espace",element:i.jsx(Ky,{})}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:"/espace",replace:!0})})]}):i.jsxs(i.Fragment,{children:[i.jsx(G,{path:"/espace",element:s}),i.jsx(G,{path:"/connexion",element:i.jsx(Ng,{onLogin:()=>r("admin")})}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:l?"/espace":"/connexion",replace:!0})})]})]}):i.jsxs(qi,{children:[i.jsx(G,{path:"/espace",element:s}),i.jsx(G,{path:"/magasins/:id/affichette",element:i.jsx(Du,{})}),i.jsxs(G,{element:i.jsx(Eg,{}),children:[i.jsx(G,{path:"/magasins",element:i.jsx(Tg,{})}),i.jsx(G,{path:"/magasins/nouveau",element:i.jsx(_g,{})}),i.jsx(G,{path:"/magasins/:id/*",element:i.jsx(by,{})})]}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:"/magasins",replace:!0})})]})}Jd(document.getElementById("root")).render(i.jsx(w.StrictMode,{children:i.jsx(pg,{future:{v7_startTransition:!0},children:i.jsx(Yy,{})})}));
+« ${j} »`)){v(!0),c(null);try{await b.post(`/api/admin/stores/${e}/campaigns`,{message:j,title:(o??n.defaultTitle).trim()}),s(""),h("Campagne envoyée. Les cartes se mettent à jour dans les minutes qui suivent."),y()}catch(d){c(d.message)}finally{v(!1)}}}return i.jsxs(i.Fragment,{children:[u&&i.jsx("div",{className:"alert error",role:"alert",children:u}),f&&i.jsx("div",{className:"alert ok",role:"status",children:f}),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:o??n.defaultTitle,onChange:d=>a(d.target.value),disabled:E||g}),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:E||g}),i.jsxs("div",{className:"row between",children:[i.jsxs("span",{className:"muted",style:{fontSize:14},children:[j.length," / ",n.maxLength," caractères · 1 campagne toutes les ",n.minIntervalHours," h maximum"]}),i.jsx("button",{className:"btn",disabled:E||g||j.length<5,onClick:p,children:g?"Envoi…":"Envoyer la campagne"})]}),n.nextAllowedAt&&i.jsxs("div",{className:"alert warn",children:["Prochain envoi possible le ",Fu(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:Fu(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))})]})})]})]})}function My({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 Ay({f:e,value:t,onChange:n}){var a;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&&((a=e.variables)!=null&&a.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,o=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:o,onChange:u=>n(u.target.value)}):i.jsx("input",{id:r,className:"input",type:s.type==="url"?"url":"text",maxLength:s.maxLength,value:o,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:[o.length," / ",s.maxLength]})]}),s.type!=="url"&&o!==s.default&&i.jsx("button",{type:"button",className:"link",style:{fontSize:14},onClick:()=>n(s.default),children:"Remettre le texte par défaut"})]})}function zy({storeId:e,storeName:t,initial:n,onChanged:r}){const[l,s]=w.useState(n),[o,a]=w.useState(n.config),[u,c]=w.useState(!1),[f,h]=w.useState(!1),[g,v]=w.useState(null),[y,j]=w.useState(null),E=`/api/admin/stores/${e}/modules/${l.id}`,p=x=>{s(x),a(x.config)};w.useEffect(()=>{u&&b.get(E).then(p).catch(x=>v(x.message))},[u,E]);async function d(x,C){h(!0),v(null),j(null);try{p(await x()),j(C),r()}catch(S){v(S.message)}finally{h(!1)}}const m=JSON.stringify(o)!==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"},children:[i.jsxs("div",{className:"row",style:{gap:10,alignItems:"center"},children:[i.jsx("h2",{style:{margin:0},children:l.name}),i.jsx(My,{m:l}),l.available&&i.jsx("span",{className:`badge ${l.config.enabled?"ACTIVE":"DRAFT"}`,children:l.config.enabled?"Activé":"Désactivé"})]}),i.jsx("p",{className:"muted",style:{margin:"6px 0 0"},children:l.description})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[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:f,value:l.override===null?"plan":l.override?"add":"remove",onChange:x=>{const C=x.target.value==="plan"?null:x.target.value==="add";d(()=>b.put(`${E}/override`,{value:C}),C===null?"Module remis selon la formule.":C?"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"})]})]}),g&&i.jsx("div",{className:"alert error",role:"alert",children:g}),y&&i.jsx("div",{className:"alert ok",role:"status",children:y}),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."}),i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontWeight:700},children:[i.jsx("input",{type:"checkbox",checked:!!o.enabled,onChange:x=>a({...o,enabled:x.target.checked})}),"Module activé"]}),l.fields.map(x=>i.jsx(Ay,{f:x,value:o[x.key],onChange:C=>a({...o,[x.key]:C})},x.key)),l.stats&&i.jsx("div",{className:"row",style:{gap:24},children:Object.entries(l.stats).map(([x,C])=>i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:22,fontWeight:800},children:C??"—"}),i.jsx("div",{className:"muted",style:{fontSize:14},children:x})]},x))}),l.id==="stats"&&i.jsx(We,{to:"../statistiques",children:"Voir les statistiques du magasin →"}),i.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[m&&i.jsx("button",{type:"button",className:"btn secondary",disabled:f,onClick:()=>a(l.config),children:"Annuler"}),i.jsx("button",{type:"button",className:"btn",disabled:f||!m,onClick:()=>d(()=>b.put(E,o),"Réglages enregistrés."),children:f?"Enregistrement…":"Enregistrer"})]}),l.id==="campaigns"&&l.available&&l.config.enabled&&i.jsx(_y,{storeId:e,storeName:t})]})]})}function Iy({storeId:e,storeName:t}){const[n,r]=w.useState(null),[l,s]=w.useState(null),o=w.useCallback(()=>{b.get(`/api/admin/stores/${e}/modules`).then(r).catch(u=>s(u.message))},[e]);if(w.useEffect(o,[o]),!n)return l?i.jsx("div",{className:"alert error",children:l}):i.jsx("p",{className:"muted",children:"Chargement…"});const a=n.filter(u=>u.available&&u.config.enabled).length;return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"muted",style:{margin:0},children:[a," module(s) actif(s) sur ",n.length,". Chaque module est inclus ou non dans la formule ; vous pouvez l'ajouter ou le retirer sur mesure, et tous ses textes et réglages sont personnalisables. Le dirigeant peut aussi les régler depuis l'app Pro."]}),n.map(u=>i.jsx(zy,{storeId:e,storeName:t,initial:u,onChanged:o},u.id))]})}const Fy=[[30,"30 jours"],[90,"3 mois"],[365,"12 mois"]],ti=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:e>=1e5?0:2}),rn=e=>e.toLocaleString("fr-FR");function Dy({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 Ot({label:e,value:t,hint:n,change:r}){return i.jsxs("div",{className:"card",style:{padding:16,display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{className:"muted",style:{fontSize:14},children:e}),i.jsx("span",{style:{fontSize:26,fontWeight:800},children:t}),i.jsxs("span",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[r!==void 0&&i.jsx(Dy,{value:r}),n&&i.jsx("span",{className:"muted",style:{fontSize:13},children:n})]})]})}function Uy({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 Oy({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 o=e.values[l][s];return i.jsx("td",{title:`${r} ${s} h : ${o} passage(s)`,style:{padding:0,height:26,borderRadius:4,background:o?`color-mix(in srgb, var(--primary) ${Math.round(15+o/n*85)}%, transparent)`:"var(--surface-2)"}},s)})]},r))})]})})}function By({storeId:e,storeSlug:t}){const[n,r]=w.useState(30),[l,s]=w.useState(null),[o,a]=w.useState(null),[u,c]=w.useState(null);w.useEffect(()=>{a(null),b.get(`/api/admin/stores/${e}/stats?days=${n}`).then(s).catch(v=>a(v.message))},[e,n]);async function f(v){c(v);try{const y=new Date().toISOString().slice(0,10);v==="customers"?await to(`/api/admin/stores/${e}/export/customers`,`clients-${t}-${y}.csv`):await to(`/api/admin/stores/${e}/export/transactions?days=${n}`,`operations-${t}-${n}j-${y}.csv`)}catch(y){a(y.message)}finally{c(null)}}const h=l==null?void 0:l.kpis,g=(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:"row",style:{gap:8},children:Fy.map(([v,y])=>i.jsx("button",{type:"button",className:"chip","aria-pressed":n===v,onClick:()=>r(v),children:y},v))}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>f("customers"),children:u==="customers"?"Export…":"Exporter les clients (CSV)"}),i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>f("transactions"),children:u==="transactions"?"Export…":"Exporter les opérations (CSV)"})]})]}),o&&i.jsx("div",{className:"alert error",role:"alert",children:o}),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||!h?!o&&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(Ot,{label:"Passages",value:rn(h.visits),change:h.visitsChange,hint:"vs période précédente"}),i.jsx(Ot,{label:"Nouvelles cartes",value:rn(h.newCards),change:h.newCardsChange,hint:`${rn(h.cardsTotal)} au total`}),i.jsx(Ot,{label:"Clients actifs",value:rn(h.activeCustomers),hint:`${h.visitsPerCustomer.toLocaleString("fr-FR")} passage(s) par client`}),i.jsx(Ot,{label:"Clients fidèles",value:h.returningRate===null?"—":`${h.returningRate.toLocaleString("fr-FR")} %`,hint:"venus au moins 2 fois"}),l.pointsMode==="AMOUNT"&&i.jsx(Ot,{label:"Achats enregistrés",value:ti(h.revenueCents),hint:h.averageBasketCents===null?void 0:`panier moyen ${ti(h.averageBasketCents)}`}),i.jsx(Ot,{label:"Récompenses",value:rn(h.rewardsRedeemed),hint:`${rn(h.pointsGiven)} ${g} distribués`}),i.jsx(Ot,{label:"Cartes dans Apple Wallet",value:h.appleWalletRate===null?"—":`${h.appleWalletRate.toLocaleString("fr-FR")} %`,hint:"iPhone joignables"})]}),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(Uy,{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(Oy,{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",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((v,y)=>i.jsxs("tr",{children:[i.jsx("td",{children:v.firstName}),i.jsx("td",{className:"num",children:v.visits}),l.pointsMode==="AMOUNT"&&i.jsx("td",{className:"num",children:ti(v.amountCents)}),i.jsx("td",{className:"num",children:v.balance})]},y))})]})})]})]})]})}const $y=[["infos","Infos"],["carte","Carte de fidélité"],["employes","Employés"],["modules","Modules"],["statistiques","Statistiques"],["facturation","Facturation"]];function by(){var c;const{id:e}=of(),[t,n]=w.useState(null),[r,l]=w.useState(null),[s,o]=w.useState(null),a=w.useCallback(()=>{b.get(`/api/admin/stores/${e}`).then(n).catch(f=>l(f.message))},[e]);w.useEffect(a,[a]);async function u(f,h){if(!(h&&!window.confirm(h))){l(null);try{await b.patch(`/api/admin/stores/${e}/status`,{status:f}),a()}catch(g){l(g.message)}}}return t?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx(We,{to:"/magasins",children:"← Magasins"}),i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("h1",{children:t.name}),i.jsx(hf,{status:t.status}),((c=t.subscription)==null?void 0:c.stripeSubscriptionId)&&t.subscription.status!=="CANCELED"&&i.jsx(vl,{to:"facturation",className:"badge DRAFT",style:{textDecoration:"none"},title:"Formule d'abonnement",children:_n[t.subscription.plan]})]}),i.jsxs("p",{className:"muted",style:{margin:0},children:[t.city," · ",t.counts.cards," clients · ",t.counts.staff," employés"]})]}),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"})]})]}),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(vl,{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:$y.map(([f,h])=>i.jsx(vl,{to:f,children:h},f))}),i.jsxs(qi,{children:[i.jsx(G,{index:!0,element:i.jsx(yl,{to:"infos",replace:!0})}),i.jsx(G,{path:"infos",element:i.jsx(mf,{initial:t,submitLabel:"Enregistrer",onSubmit:async f=>{const{name:h,siret:g,addressLine:v,postalCode:y,city:j,contactName:E,contactEmail:p,contactPhone:d,maxAmountEuros:m,minScanIntervalMin:x}=f;await b.patch(`/api/admin/stores/${e}`,{name:h,siret:g,addressLine:v,postalCode:y,city:j,contactName:E,contactEmail:p,contactPhone:d,maxAmountEuros:m,minScanIntervalMin:x}),o("Modifications enregistrées."),a()}},t.id)}),i.jsx(G,{path:"carte",element:i.jsx(Df,{store:t,onSaved:a})}),i.jsx(G,{path:"employes",element:i.jsx(Py,{storeId:t.id})}),i.jsx(G,{path:"modules",element:i.jsx(Iy,{storeId:t.id,storeName:t.name})}),i.jsx(G,{path:"statistiques",element:i.jsx(By,{storeId:t.id,storeSlug:t.slug})}),i.jsx(G,{path:"facturation",element:i.jsx(Ly,{storeId:t.id,contactEmail:t.contactEmail,onChange:a})})]})]}):r?i.jsx("div",{className:"alert error",children:r}):i.jsx("p",{className:"muted",children:"Chargement…"})}function Du({merchant:e=!1}){const{id:t}=of(),n=e?"/api/staff/store":`/api/admin/stores/${t}`,r=e?"/api/staff/card-design":`/api/admin/stores/${t}/card-design`,[l,s]=ra(),o=l.get("format")==="A6"?"A6":"A5",[a,u]=w.useState(null),[c,f]=w.useState(null),[h,g]=w.useState(null);return w.useEffect(()=>{Promise.all([b.get(n),b.get(r)]).then(([v,y])=>{u(v),f(y)}).catch(v=>g(v.message))},[n,r]),h?i.jsx("div",{className:"alert error",style:{margin:24},children:h}):a?c?i.jsxs("div",{className:"poster-page",children:[i.jsx("style",{children:`@page{size:${o};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(We,{to:e?"/espace":`/magasins/${t}/carte`,children:"← Retour à la carte"}),i.jsxs("div",{className:"row",style:{gap:8},children:[["A5","A6"].map(v=>i.jsx("button",{type:"button",className:"chip","aria-pressed":o===v,onClick:()=>s({format:v}),children:v},v)),i.jsx("button",{type:"button",className:"btn",onClick:()=>window.print(),children:"Imprimer"})]})]}),a.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(zf,{format:o,url:a.enrollUrl,storeName:a.name,programName:c.programName,logoUrl:eo(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:a.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 Wy=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),Uu=["ESSENTIEL","PRO","RESEAU"],Vy=[["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 du dirigeant",{autoComplete:"name",maxLength:120}],["contactPhone","Téléphone",{autoComplete:"tel",type:"tel"}],["contactEmail","E-mail (votre identifiant)",{autoComplete:"email",type:"email"}]];function Hy(){const[e]=ra(),t=(e.get("formule")??"").toUpperCase(),[n,r]=w.useState(Uu.includes(t)?t:"PRO"),[l,s]=w.useState(e.get("periode")==="annuel"?"YEAR":"MONTH"),[o,a]=w.useState([]),[u,c]=w.useState({name:"",siret:"",addressLine:"",postalCode:"",city:"",contactName:"",contactPhone:"",contactEmail:"",password:""}),[f,h]=w.useState(!1),[g,v]=w.useState(e.get("annule")?"Paiement annulé : rien n’a été prélevé. Vous pouvez reprendre quand vous voulez.":null),[y,j]=w.useState(!1);w.useEffect(()=>{const d=m=>m.persisted&&j(!1);return window.addEventListener("pageshow",d),()=>window.removeEventListener("pageshow",d)},[]),w.useEffect(()=>{Tu.get("/api/public/signup/plans").then(a).catch(()=>{})},[]);async function E(d){d.preventDefault(),j(!0),v(null);try{const{url:m}=await Tu.post("/api/public/signup",{...u,plan:n,interval:l,cgv:f});window.location.assign(m)}catch(m){v(m.message),j(!1),window.scrollTo({top:0,behavior:"smooth"})}}const p=o.find(d=>d.plan===n);return i.jsx("main",{style:{minHeight:"100vh",padding:"32px 16px"},children:i.jsxs("form",{onSubmit:E,style:{maxWidth:720,margin:"0 auto",display:"flex",flexDirection:"column",gap:24},children:[i.jsx("a",{href:"https://monespacepro.eu/tarif/",style:{textDecoration:"none",color:"inherit"},children:i.jsx(Fr,{admin:!1})}),i.jsxs("div",{children:[i.jsx("h1",{children:"Créer mon programme de fidélité"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Sans engagement, résiliable à tout moment. Votre espace est prêt dès le paiement validé."})]}),g&&i.jsx("div",{className:"alert error",role:"alert",children:g}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsx("h2",{children:"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":l==="MONTH",onClick:()=>s("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":l==="YEAR",onClick:()=>s("YEAR"),children:"Annuel — 2 mois offerts"})]}),i.jsx("div",{className:"mode-cards",role:"radiogroup","aria-label":"Formule",children:(o.length?o:Uu.map(d=>({plan:d,name:_n[d],tagline:"",priceCents:{MONTH:0,YEAR:0},modules:[],limits:{maxStaff:null}}))).map(d=>i.jsxs("label",{className:"mode-card",style:{flexDirection:"column",gap:6},children:[i.jsxs("span",{className:"row",style:{gap:10},children:[i.jsx("input",{type:"radio",name:"plan",checked:n===d.plan,onChange:()=>r(d.plan)}),i.jsx("strong",{style:{fontSize:18},children:d.name})]}),d.priceCents[l]>0&&i.jsxs("span",{style:{fontSize:22,fontWeight:800},children:[Wy(d.priceCents[l]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",l==="YEAR"?"an":"mois"]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:d.tagline})]},d.plan))}),p&&i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14},children:[p.limits.maxStaff?`${p.limits.maxStaff} employés`:"Employés illimités"," ·"," ",p.modules.length?`Modules : ${p.modules.map(d=>d.name).join(", ")}`:"Sans module complémentaire"]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsx("h2",{children:"Votre commerce"}),Vy.map(([d,m,x])=>i.jsxs("div",{className:"field",children:[i.jsxs("label",{htmlFor:`s-${d}`,children:[m," *"]}),i.jsx("input",{id:`s-${d}`,className:"input",required:!0,value:u[d],onChange:C=>c({...u,[d]:C.target.value}),...x})]},d)),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:d=>c({...u,password:d.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.jsxs("label",{className:"row",style:{gap:10,alignItems:"flex-start"},children:[i.jsx("input",{type:"checkbox",required:!0,checked:f,onChange:d=>h(d.target.checked),style:{marginTop:4}}),i.jsxs("span",{children:["J’accepte les ",i.jsx("a",{href:"https://monespacepro.eu/cgv/",target:"_blank",rel:"noreferrer",children:"conditions générales de vente"})," et la"," ",i.jsx("a",{href:"https://monespacepro.eu/confidentialite/",target:"_blank",rel:"noreferrer",children:"politique de confidentialité"}),"."]})]}),i.jsx("button",{className:"btn",disabled:y,children:y?"Redirection vers le paiement…":"Continuer vers le paiement"}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14,textAlign:"center"},children:["Paiement sécurisé par Stripe (carte ou prélèvement SEPA). Déjà inscrit ? ",i.jsx(We,{to:"/espace",children:"Se connecter"})]})]})})}function Qy({onLogin:e}){const t=en(),[n]=ra(),r=n.has("bienvenue"),[l,s]=w.useState(""),[o,a]=w.useState(""),[u,c]=w.useState(null),[f,h]=w.useState(!1);async function g(v){v.preventDefault(),h(!0),c(null);try{await Sg(l,o),e(),t("/espace",{replace:!0})}catch(y){c(r&&y instanceof ms&&y.status===401?"Votre espace est en cours de création. Réessayez dans quelques secondes.":y.message)}finally{h(!1)}}return i.jsx("main",{style:{minHeight:"100vh",display:"grid",placeItems:"center",padding:16},children:i.jsxs("form",{className:"card",onSubmit:g,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:v=>s(v.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:o,onChange:v=>a(v.target.value)})]}),i.jsx("button",{className:"btn",disabled:f,children:f?"Connexion…":"Se connecter"}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14,textAlign:"center"},children:["Pas encore client ? ",i.jsx(We,{to:"/inscription",children:"Créer mon programme"})]})]})})}function Ky(){const[e,t]=w.useState(null),[n,r]=w.useState(null),l=w.useCallback(()=>{b.get("/api/staff/store").then(t).catch(s=>r(s instanceof ms&&s.status===403?"Cet espace est réservé au Dirigeant du magasin. Utilisez l’app MonEspacePro pour scanner les cartes.":s.message))},[]);return w.useEffect(l,[l]),i.jsxs("div",{style:{minHeight:"100vh"},children:[i.jsxs("header",{className:"row between",style:{padding:"16px 24px",borderBottom:"1px solid var(--border)"},children:[i.jsx(Fr,{admin:!1}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:ia,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("div",{children:[i.jsx("h1",{children:e.name}),i.jsxs("p",{className:"muted",style:{margin:0},children:[e.subscription?`Formule ${_n[e.subscription.plan]}`:"Aucune formule"," ·"," ",e.status==="ACTIVE"?"Programme ouvert à vos clients":e.status==="DRAFT"?"Programme pas encore ouvert":"Programme suspendu"]})]}),e.subscribeUrl&&i.jsxs("div",{className:"alert warn row between",style:{gap:12},children:[i.jsx("span",{children:"Votre abonnement n’est pas encore actif : le programme s’ouvrira dès le paiement validé."}),i.jsx("a",{className:"btn small",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é."}),e.status==="ACTIVE"&&i.jsxs("div",{className:"alert ok",children:["Vos clients s’inscrivent sur ",i.jsx("a",{href:e.enrollUrl,target:"_blank",rel:"noreferrer",children:e.enrollUrl})," (QR code de l’affichette)."]}),i.jsx("p",{className:"muted",style:{margin:0},children:"Employés, modules (campagnes, anniversaire, relances…) et statistiques : dans l’app MonEspacePro, avec les mêmes identifiants."}),i.jsx(Df,{store:e,onSaved:l,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 Yy(){const e=en(),t=It(),[n,r]=w.useState(wg()),l=t.pathname.startsWith("/espace");w.useEffect(()=>{xg(()=>{r(null),e(l?"/espace":"/connexion")})},[e,l]);const s=i.jsx(Qy,{onLogin:()=>r("staff")});return n!=="admin"||t.pathname==="/inscription"?i.jsxs(qi,{children:[i.jsx(G,{path:"/inscription",element:i.jsx(Hy,{})}),n==="staff"?i.jsxs(i.Fragment,{children:[i.jsx(G,{path:"/espace/affichette",element:i.jsx(Du,{merchant:!0})}),i.jsx(G,{path:"/espace",element:i.jsx(Ky,{})}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:"/espace",replace:!0})})]}):i.jsxs(i.Fragment,{children:[i.jsx(G,{path:"/espace",element:s}),i.jsx(G,{path:"/connexion",element:i.jsx(Ng,{onLogin:()=>r("admin")})}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:l?"/espace":"/connexion",replace:!0})})]})]}):i.jsxs(qi,{children:[i.jsx(G,{path:"/espace",element:s}),i.jsx(G,{path:"/magasins/:id/affichette",element:i.jsx(Du,{})}),i.jsxs(G,{element:i.jsx(Eg,{}),children:[i.jsx(G,{path:"/magasins",element:i.jsx(Tg,{})}),i.jsx(G,{path:"/magasins/nouveau",element:i.jsx(_g,{})}),i.jsx(G,{path:"/magasins/:id/*",element:i.jsx(by,{})})]}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:"/magasins",replace:!0})})]})}Jd(document.getElementById("root")).render(i.jsx(w.StrictMode,{children:i.jsx(pg,{future:{v7_startTransition:!0},children:i.jsx(Yy,{})})}));
diff --git a/site/comment-ca-marche/index.html b/site/comment-ca-marche/index.html
index a3d540f..d9e6a19 100644
--- a/site/comment-ca-marche/index.html
+++ b/site/comment-ca-marche/index.html
@@ -107,7 +107,7 @@
3
-
Durée estimée : [durée]
Comptes employés et app Pro Vous créez les comptes de votre équipe. Chacun installe l’app MonEspacePro Pro sur son téléphone.
Vous : inviter l’équipe Employés : installer l’app
+
Durée estimée : [durée]
Comptes employés et app Pro Vous créez les comptes de votre équipe. Chacun installe l’app MonEspacePro sur son téléphone.
Vous : inviter l’équipe Employés : installer l’app
[Employé 1] Dirigeant
[Employé 2] Employé
diff --git a/site/espace/affichette/index.html b/site/espace/affichette/index.html
index b26742a..37b2544 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 a889e31..2bd9a63 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 d5cb86d..0b3a488 100644
--- a/site/faq/index.html
+++ b/site/faq/index.html
@@ -107,7 +107,7 @@
Pour vous
-
De quel matériel ai-je besoin ? Un téléphone pour l’app MonEspacePro Pro, et de quoi imprimer l’affichette A5 ou A6 que nous fournissons. [Réponse à confirmer]
+
De quel matériel ai-je besoin ? Un téléphone pour l’app MonEspacePro, et de quoi imprimer l’affichette A5 ou A6 que nous fournissons. [Réponse à confirmer]
Combien d’employés puis-je ajouter ? [Réponse à compléter]
Et si j’ai plusieurs magasins ? Chaque magasin a sa formule. À partir de 3 magasins, la formule Réseau revient à 29 € par mois et par magasin. Voir les formules .
Puis-je modifier la carte après coup ? [Réponse à compléter]
diff --git a/site/fonctionnalites/index.html b/site/fonctionnalites/index.html
index a290ae3..166c6d9 100644
--- a/site/fonctionnalites/index.html
+++ b/site/fonctionnalites/index.html
@@ -146,12 +146,12 @@
L’app Pro pour vos employés
Scan, montant, récompenses, historique.
-
L’app mobile MonEspacePro Pro tient dans la poche de l’équipe. Deux rôles : dirigeant et employé.
+
L’app mobile MonEspacePro tient dans la poche de l’équipe. Deux rôles : dirigeant et employé.
Scanner la carte du client Saisir le montant, valider une récompense Retrouver chaque opération dans l’historique
-
MonEspacePro Pro
+
MonEspacePro
Employé Dirigeant
Scanner
diff --git a/site/index.html b/site/index.html
index b00a398..ff8301c 100644
--- a/site/index.html
+++ b/site/index.html
@@ -134,7 +134,7 @@
1
Le client scanne Il scanne le QR de l’affichette, saisit son prénom et son e-mail.
2
La carte s’ajoute au Wallet Apple Wallet ou Google Wallet, en un geste. Elle est à vos couleurs.
-
3
L’employé crédite en un scan Il scanne la carte du client avec l’app MonEspacePro Pro. Le solde se met à jour tout seul.
+
3
L’employé crédite en un scan Il scanne la carte du client avec l’app MonEspacePro. Le solde se met à jour tout seul.
@@ -202,7 +202,7 @@
L’app Pro
-
MonEspacePro Pro : le scan, le montant, c’est tout.
+
MonEspacePro : le scan, le montant, c’est tout.
L’app mobile de vos employés. On scanne la carte, on saisit le montant, on valide une récompense. L’historique garde la trace de tout.
Scanner la carte du client
@@ -243,7 +243,7 @@
La carte à vos couleurs, dans le Wallet
- L’app MonEspacePro Pro pour vos employés
+ L’app MonEspacePro pour vos employés
L’affichette de comptoir A5 / A6
3 formules au choix
Sans engagement, mensuel ou annuel
diff --git a/site/inscription/index.html b/site/inscription/index.html
index 18d3851..5a7a504 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/tarif/index.html b/site/tarif/index.html
index baa3fe3..c8f9662 100644
--- a/site/tarif/index.html
+++ b/site/tarif/index.html
@@ -101,7 +101,7 @@
La carte à vos couleurs, dans Apple Wallet et Google Wallet
Points ou tampons, récompenses définies par vous
Solde et récompenses mis à jour en direct dans le Wallet
-App MonEspacePro Pro pour 3 employés
+App MonEspacePro pour 3 employés
Anti-triche : plafond, délai, historique par employé
Affichette de comptoir A5 / A6