app.js 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816
  1. /* Audit Express Self - Livinweb */
  2. const appEl = document.getElementById('app');
  3. const API_BASE = appEl?.dataset?.apiBase || '/api';
  4. const BOOKING_URL = appEl?.dataset?.bookingUrl || '';
  5. const DEVIS_URL = appEl?.dataset?.devisUrl || '';
  6. /* ── Catalogue packs ── */
  7. const PACK_CATALOGUE = [
  8. {
  9. id: 'onboarding-v1',
  10. title: 'Onboarding collaborateur',
  11. desc: "Clarté du flux, traçabilité, continuité — auditez votre process d'intégration.",
  12. tag: 'Pré-configuré',
  13. tagStyle: 'tag--pre',
  14. },
  15. {
  16. id: 'validation-facture',
  17. title: 'Validation de facture',
  18. desc: 'Contrôles, séparation des tâches, preuve — évaluez votre circuit factures.',
  19. tag: 'Pré-configuré',
  20. tagStyle: 'tag--pre',
  21. },
  22. {
  23. id: 'process-generique',
  24. title: 'Process générique',
  25. desc: 'Applicable à tout process opérationnel : achat, production, relation client, support, projet…',
  26. tag: 'Universel',
  27. tagStyle: 'tag--new',
  28. },
  29. {
  30. id: 'process-generique-v2',
  31. title: 'Diagnostic d\'opportunité',
  32. desc: 'Évaluez sur 8 axes si ce process est prioritaire à automatiser : friction, volume, risque, données, outils, variabilité, collaboration, déploiement.',
  33. tag: 'Diagnostic d\'opportunité',
  34. tagStyle: 'tag--v2',
  35. },
  36. {
  37. id: 'transformation-excel',
  38. title: 'Transformation fichier Excel',
  39. desc: 'Votre fichier Excel vous coûte-t-il du temps, des erreurs ou de la maîtrise ? 14 questions pour savoir s\'il faut le garder, l\'optimiser ou le transformer en application web.',
  40. tag: 'Transformation Excel',
  41. tagStyle: 'tag--excel',
  42. },
  43. {
  44. id: 'intervention-sav-maintenance-terrain-v2-compact',
  45. title: 'Intervention SAV / Maintenance terrain',
  46. desc: '16 questions pour auditer votre process d\'interventions terrain : canal d\'entrée, affectation, traçabilité, KPI, résilience et coût caché.',
  47. tag: 'Pré-configuré',
  48. tagStyle: 'tag--pre',
  49. },
  50. {
  51. id: 'internal-requests-validations-v2',
  52. title: 'Demandes internes & validations',
  53. desc: '16 questions pour auditer votre process de demandes internes (achats, RH, IT, juridique, marketing…) : point d\'entrée, catégorisation, règles de validation, traçabilité, résilience et coût.',
  54. tag: 'Pré-configuré',
  55. tagStyle: 'tag--pre',
  56. },
  57. {
  58. id: 'collecte-terrain-qualite-conformite-v2',
  59. title: 'Collecte terrain / qualité / conformité',
  60. desc: '16 questions pour auditer checklists, contrôles, non-conformités et traçabilité audit : clarté, fiabilité, preuve, résilience et coût.',
  61. tag: 'Pré-configuré',
  62. tagStyle: 'tag--pre',
  63. },
  64. ];
  65. /* ── Outils à venir ── */
  66. const COMING_SOON_TOOLS = [
  67. {
  68. id: 'process-mapper',
  69. title: 'Process Mapper',
  70. desc: 'Cartographiez visuellement votre process étape par étape, identifiez les goulots d\'étranglement et générez une documentation structurée prête à partager.',
  71. },
  72. ];
  73. const state = {
  74. view: 'landing',
  75. packId: null,
  76. pack: null,
  77. idx: 0,
  78. answers: {},
  79. optional: {},
  80. result: null,
  81. emailUnlocked: false,
  82. unlockExiting: false,
  83. captureEmail: '',
  84. notifyTool: '',
  85. roiInputs: { volume: '', tempsActuel: '', tempsCible: '', salaireNet: '', tauxErreurs: '', tempsErreur: '', delaiActuel: '', delaiCible: '' },
  86. roiResult: null,
  87. qwfSignals: {},
  88. qwfResult: null,
  89. excelSignals: {},
  90. excelResult: null,
  91. excelQual: { outil: null, personnes: null, consequence: [] },
  92. excelStep: 1,
  93. excelNotified: false,
  94. excelSubmitting: false,
  95. excelCaptureEmail: '',
  96. };
  97. let autoAdvanceTimer = null;
  98. /* ── DOM helpers ── */
  99. function h(tag, attrs = {}, children = []) {
  100. const el = document.createElement(tag);
  101. for (const [k, v] of Object.entries(attrs || {})) {
  102. if (k === 'class') el.className = v;
  103. else if (k.startsWith('on') && typeof v === 'function') el.addEventListener(k.slice(2).toLowerCase(), v);
  104. else if (v !== undefined && v !== null && v !== false) el.setAttribute(k, String(v));
  105. }
  106. for (const child of (Array.isArray(children) ? children : [children])) {
  107. if (child == null) continue;
  108. el.appendChild(typeof child === 'string' ? document.createTextNode(child) : child);
  109. }
  110. return el;
  111. }
  112. function storageKey(packId) { return `aes_${packId}_v1`; }
  113. function saveProgress() {
  114. if (!state.packId) return;
  115. localStorage.setItem(storageKey(state.packId), JSON.stringify({ answers: state.answers, optional: state.optional }));
  116. }
  117. function loadProgress(packId) {
  118. try {
  119. const obj = JSON.parse(localStorage.getItem(storageKey(packId)) || '{}');
  120. return {
  121. answers: typeof obj?.answers === 'object' ? obj.answers : {},
  122. optional: typeof obj?.optional === 'object' ? obj.optional : {},
  123. };
  124. } catch { return { answers: {}, optional: {} }; }
  125. }
  126. async function apiJson(path, { method = 'GET', body } = {}) {
  127. const headers = {};
  128. if (body) {
  129. headers['Content-Type'] = 'application/json';
  130. const csrf = appEl?.dataset?.csrfToken;
  131. if (csrf) headers['X-CSRF-Token'] = csrf;
  132. }
  133. const res = await fetch(`${API_BASE}${path}`, {
  134. method,
  135. headers: Object.keys(headers).length ? headers : undefined,
  136. body: body ? JSON.stringify(body) : undefined,
  137. credentials: 'same-origin',
  138. });
  139. const data = await res.json().catch(() => ({}));
  140. if (!res.ok) throw new Error(data?.error || 'Erreur API');
  141. return data;
  142. }
  143. function setView(v) { state.view = v; render(); }
  144. /* ── Navigation globale (exposée pour la navbar) ── */
  145. const VIEW_TO_NAV = {
  146. select: 'nav-diag',
  147. intro: 'nav-diag',
  148. quiz: 'nav-diag',
  149. computing: 'nav-diag',
  150. optional: 'nav-diag',
  151. results: 'nav-diag',
  152. roi: 'nav-roi',
  153. 'roi-results': 'nav-roi',
  154. qwf: 'nav-qwf',
  155. 'qwf-results': 'nav-qwf',
  156. excel: 'nav-excel',
  157. 'excel-results': 'nav-excel',
  158. };
  159. const VIEW_LABELS = {
  160. select: 'Diagnostic process',
  161. intro: null,
  162. quiz: null,
  163. computing: null,
  164. optional: null,
  165. results: null,
  166. roi: 'ROI Calculator',
  167. 'roi-results': 'ROI Calculator',
  168. qwf: 'Quick Wins Finder',
  169. 'qwf-results': 'Quick Wins Finder',
  170. excel: 'Excel → Application',
  171. 'excel-results': 'Excel → Application',
  172. };
  173. function getNavLabel() {
  174. if (['intro', 'quiz', 'computing', 'optional', 'results'].includes(state.view)) {
  175. return state.pack?.pack_title || 'Diagnostic process';
  176. }
  177. return VIEW_LABELS[state.view] || null;
  178. }
  179. function updateNavbar() {
  180. const crumb = document.getElementById('navBreadcrumb');
  181. if (crumb) crumb.textContent = getNavLabel() || '';
  182. document.querySelectorAll('.navbar__dropdown-item').forEach(el => el.classList.remove('active'));
  183. if (state.view !== 'landing') {
  184. let navId = VIEW_TO_NAV[state.view];
  185. if (!navId && state.packId === 'process-generique-v2') navId = 'nav-v2';
  186. if (navId) document.getElementById(navId)?.classList.add('active');
  187. }
  188. }
  189. window._ae = {
  190. goStart,
  191. goDiag: () => setView('select'),
  192. goV2: () => selectPack('process-generique-v2'),
  193. goRoi: () => setView('roi'),
  194. goQwf: () => setView('qwf'),
  195. goExcel: () => { state.excelStep = 1; setView('excel'); },
  196. };
  197. function hasOptionalQuestions() {
  198. const opt = state.pack?.optional_questions || {};
  199. return Object.keys(opt).length > 0;
  200. }
  201. function goStart() {
  202. Object.assign(state, { packId: null, pack: null, idx: 0, answers: {}, optional: {}, result: null, emailUnlocked: false, unlockExiting: false, captureEmail: '' });
  203. setView('landing');
  204. }
  205. async function selectPack(packId) {
  206. state.packId = packId;
  207. const saved = loadProgress(packId);
  208. state.answers = saved.answers;
  209. state.optional = saved.optional;
  210. try {
  211. const data = await apiJson(`/pack.php?pack=${encodeURIComponent(packId)}`);
  212. state.pack = data.pack;
  213. state.idx = 0;
  214. setView('intro');
  215. } catch (e) {
  216. alert('Impossible de charger le pack : ' + (e.message || ''));
  217. }
  218. }
  219. function levelColor(level) {
  220. return { A: '#1e8a5e', B: '#1e8a5e', C: '#c07c10', D: '#b83040' }[level] || '#2F506D';
  221. }
  222. /* ── COMING-SOON card helper ── */
  223. function makeComingSoonCard(tool) {
  224. return h('div', {
  225. class: 'pack-card pack-card--soon',
  226. onClick: () => {
  227. state.notifyTool = tool.id;
  228. document.getElementById('notifyDialog')?.showModal();
  229. },
  230. }, [
  231. h('span', { class: 'tag tag--soon' }, ['Bientôt disponible']),
  232. h('div', { class: 'title', style: 'margin-top:8px' }, [tool.title]),
  233. h('div', { class: 'desc' }, [tool.desc]),
  234. h('div', { class: 'soon-overlay' }, [
  235. h('div', { class: 'soon-overlay__label' }, ['Bientôt disponible']),
  236. h('div', { class: 'soon-overlay__text' }, ['Me notifier du lancement →']),
  237. ]),
  238. ]);
  239. }
  240. /* ── NOTIFY DIALOG (Coming soon) ── */
  241. function renderNotifyDialog() {
  242. const toolMeta = COMING_SOON_TOOLS.find(t => t.id === state.notifyTool);
  243. const toolName = toolMeta?.title || 'cet outil';
  244. const onSubmit = async (e) => {
  245. e.preventDefault();
  246. const email = e.target.querySelector('input[type="email"]').value.trim();
  247. if (!email) return;
  248. const btn = e.target.querySelector('button[type="submit"]');
  249. btn.disabled = true;
  250. btn.textContent = 'Envoi…';
  251. try {
  252. await apiJson('/notify.php', { method: 'POST', body: { email, tool: state.notifyTool } });
  253. const body = document.querySelector('#notifyDialog .dialog__body');
  254. if (body) {
  255. body.innerHTML = '';
  256. body.appendChild(h('div', { style: 'text-align:center;padding:20px 0' }, [
  257. h('div', { class: 'h2', style: 'color:var(--good);margin-bottom:8px' }, ['C\'est noté !']),
  258. h('p', { class: 'lead' }, [`Vous serez parmi les premiers informés du lancement de ${toolName}.`]),
  259. h('button', {
  260. class: 'btn btn--primary', style: 'margin-top:16px',
  261. onClick: () => document.getElementById('notifyDialog')?.close(),
  262. }, ['Fermer']),
  263. ]));
  264. }
  265. } catch (err) {
  266. btn.disabled = false;
  267. btn.textContent = 'Me prévenir au lancement →';
  268. alert('Erreur : ' + (err.message || 'Réessayez.'));
  269. }
  270. };
  271. return h('dialog', { id: 'notifyDialog', class: 'dialog' }, [
  272. h('div', { class: 'dialog__inner' }, [
  273. h('div', { class: 'dialog__head' }, [
  274. h('strong', {}, [`Soyez informé : ${toolName}`]),
  275. h('button', {
  276. class: 'btn btn--outline', style: 'padding:6px 12px;font-size:13px', type: 'button',
  277. onClick: () => document.getElementById('notifyDialog')?.close(),
  278. }, ['Fermer']),
  279. ]),
  280. h('div', { class: 'dialog__body' }, [
  281. h('p', { class: 'lead', style: 'margin-bottom:16px' }, [
  282. `${toolName} est en cours de développement. Laissez votre email et on vous prévient en priorité au lancement.`,
  283. ]),
  284. h('form', { onSubmit }, [
  285. h('div', { class: 'field' }, [
  286. h('label', { for: 'notifyEmail' }, ['Email professionnel']),
  287. h('input', {
  288. id: 'notifyEmail', type: 'email', required: 'required',
  289. placeholder: 'vous@entreprise.com', autocomplete: 'email',
  290. }),
  291. ]),
  292. h('div', { class: 'btnrow', style: 'margin-top:14px' }, [
  293. h('button', { class: 'btn btn--primary', type: 'submit' }, ['Me prévenir au lancement →']),
  294. ]),
  295. h('p', { class: 'hint' }, ['Aucun spam. Désabonnement en 1 clic.']),
  296. ]),
  297. ]),
  298. ]),
  299. ]);
  300. }
  301. /* ── LANDING (page d'accueil) ── */
  302. function renderLanding() {
  303. const diagnosticV2 = PACK_CATALOGUE.find(p => p.id === 'process-generique-v2');
  304. const makeCard = (attrs, children) => h('div', attrs, children);
  305. /* Audits & Diagnostics */
  306. const auditCards = [
  307. makeCard({ class: 'pack-card', onClick: () => setView('select') }, [
  308. h('span', { class: 'tag tag--pre' }, ['Diagnostic']),
  309. h('div', { class: 'title' }, ['Diagnostic process', h('span', { class: 'arrow' }, [' →'])]),
  310. h('div', { class: 'desc' }, ['Évaluez votre process sur 5 piliers en 20 questions. Packs pré-configurés (onboarding, facture) ou questionnaire universel.']),
  311. ]),
  312. diagnosticV2 ? makeCard({ class: 'pack-card', onClick: () => selectPack(diagnosticV2.id) }, [
  313. h('span', { class: `tag ${diagnosticV2.tagStyle}` }, [diagnosticV2.tag]),
  314. h('div', { class: 'title' }, [diagnosticV2.title, h('span', { class: 'arrow' }, [' →'])]),
  315. h('div', { class: 'desc' }, [diagnosticV2.desc]),
  316. ]) : null,
  317. makeCard({ class: 'pack-card', onClick: () => { state.excelStep = 1; setView('excel'); } }, [
  318. h('span', { class: 'tag tag--excel' }, ['Excel → Application']),
  319. h('div', { class: 'title' }, ['Dois-je transformer mon Excel ?', h('span', { class: 'arrow' }, [' →'])]),
  320. h('div', { class: 'desc' }, ['15 signaux pour savoir si votre fichier Excel a atteint ses limites et si une application web est justifiée.']),
  321. ]),
  322. ].filter(Boolean);
  323. /* Calculateurs rapides */
  324. const calcCards = [
  325. makeCard({ class: 'pack-card', onClick: () => setView('roi') }, [
  326. h('span', { class: 'tag tag--roi' }, ['ROI Calculator']),
  327. h('div', { class: 'title' }, ['ROI Calculator', h('span', { class: 'arrow' }, [' →'])]),
  328. h('div', { class: 'desc' }, ['Chiffrez le gain mensuel et le ROI annuel. Identifiez les 2 leviers qui pèsent le plus sur votre process.']),
  329. ]),
  330. makeCard({ class: 'pack-card', onClick: () => setView('qwf') }, [
  331. h('span', { class: 'tag tag--qwf' }, ['Quick Wins Finder']),
  332. h('div', { class: 'title' }, ['Quick Wins Finder', h('span', { class: 'arrow' }, [' →'])]),
  333. h('div', { class: 'desc' }, ['7 signaux → 3 actions concrètes et priorisées avec résultat attendu, effort et délai typique.']),
  334. ]),
  335. ];
  336. return h('div', { class: 'grid' }, [
  337. h('div', { class: 'card' }, [
  338. h('h1', { class: 'h1' }, ['Choisissez un outil']),
  339. h('p', { class: 'lead' }, ['Diagnostiquez et optimisez vos process opérationnels.']),
  340. /* Section 1 : Audits & Diagnostics */
  341. h('div', { class: 'landing-section' }, [
  342. h('div', { class: 'section-label section-label--audit' }, ['Audits & Diagnostics']),
  343. h('div', { class: 'grid grid--2' }, auditCards),
  344. ]),
  345. /* Section 2 : Calculateurs rapides */
  346. h('div', { class: 'landing-section' }, [
  347. h('div', { class: 'section-label section-label--calc' }, ['Calculateurs rapides']),
  348. h('div', { class: 'grid grid--2' }, calcCards),
  349. ]),
  350. /* Section 3 : Conseil (booking) */
  351. BOOKING_URL ? h('div', { class: 'landing-section' }, [
  352. h('div', { class: 'section-label section-label--conseil' }, ['Conseil & accompagnement']),
  353. h('div', { class: 'grid grid--2' }, [
  354. h('a', {
  355. class: 'pack-card pack-card--link',
  356. href: BOOKING_URL,
  357. target: '_blank',
  358. rel: 'noreferrer',
  359. }, [
  360. h('span', { class: 'tag tag--booking' }, ['Prise de décision']),
  361. h('div', { class: 'title' }, ['Faisabilité d\'automatisation d\'un process', h('span', { class: 'arrow' }, [' →'])]),
  362. h('div', { class: 'desc' }, ['Moins d\'une heure. Prenez rendez-vous pour évaluer ensemble si votre process est prioritaire à automatiser.']),
  363. ]),
  364. ]),
  365. ]) : null,
  366. /* Section 4 : Bientôt disponible */
  367. h('div', { class: 'landing-section' }, [
  368. h('div', { class: 'section-label' }, ['Bientôt disponible']),
  369. h('div', { class: 'grid grid--2' }, COMING_SOON_TOOLS.map(makeComingSoonCard)),
  370. ]),
  371. ]),
  372. renderNotifyDialog(),
  373. ]);
  374. }
  375. /* ── SELECT (page Diagnostic process) ── */
  376. function renderSelect() {
  377. const makeCard = (p, featured = false) =>
  378. h('div', { class: `pack-card${featured ? ' pack-card--featured' : ''}`, onClick: () => selectPack(p.id) }, [
  379. h('span', { class: `tag ${p.tagStyle}` }, [p.tag]),
  380. h('div', { class: 'title' }, [p.title, h('span', { class: 'arrow' }, [' →'])]),
  381. h('div', { class: 'desc' }, [p.desc]),
  382. ]);
  383. const preConfigured = PACK_CATALOGUE.filter(p => p.tag === 'Pré-configuré');
  384. const generic = PACK_CATALOGUE.find(p => p.id === 'process-generique');
  385. return h('div', { class: 'grid' }, [
  386. h('div', { class: 'card' }, [
  387. h('h1', { class: 'h1' }, ['Choisissez le process à diagnostiquer']),
  388. h('p', { class: 'lead' }, ['Utilisez le questionnaire universel ou un pack pré-configuré.']),
  389. h('div', { class: 'section-label section-label--featured', style: 'margin-top:18px' }, ['Process universel']),
  390. h('div', { class: 'grid grid--2' }, generic ? [makeCard(generic, true)] : []),
  391. h('div', { class: 'section-label', style: 'margin-top:24px' }, ['Packs pré-configurés']),
  392. h('div', { class: 'grid grid--2' }, preConfigured.map(makeCard)),
  393. h('div', { class: 'btnrow', style: 'margin-top:18px' }, [
  394. h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Retour']),
  395. ]),
  396. ]),
  397. ]);
  398. }
  399. /* ── INTRO ── */
  400. function renderIntro() {
  401. const meta = PACK_CATALOGUE.find(p => p.id === state.packId);
  402. const answeredCount = Object.keys(state.answers).length;
  403. const total = state.pack?.questions?.length || 20;
  404. const hasSaved = answeredCount > 0;
  405. const startFresh = () => {
  406. state.answers = {};
  407. state.optional = {};
  408. state.idx = 0;
  409. state.emailUnlocked = false;
  410. state.unlockExiting = false;
  411. state.captureEmail = '';
  412. saveProgress();
  413. setView('quiz');
  414. };
  415. const resume = () => {
  416. const qs = state.pack?.questions || [];
  417. let resumeIdx = 0;
  418. for (let i = 0; i < qs.length; i++) {
  419. if (state.answers[qs[i].id]) resumeIdx = i;
  420. }
  421. state.idx = Math.min(resumeIdx + 1, qs.length - 1);
  422. setView('quiz');
  423. };
  424. return h('div', { class: 'grid' }, [
  425. h('div', { class: 'card' }, [
  426. h('span', { class: `tag ${meta?.tagStyle || ''}`, style: 'margin-bottom:12px;display:inline-block' }, [
  427. state.pack?.pack_title || '',
  428. ]),
  429. h('h1', { class: 'h1' }, ['Avant de commencer']),
  430. h('p', { class: 'lead' }, [
  431. 'Répondez franchement. Le score sert à prioriser, pas à juger. ',
  432. `Temps estimé : ${total <= 15 ? 5 : 7} minutes. Questions : ${total}.`,
  433. ]),
  434. state.pack?.pack_description
  435. ? h('p', { style: 'color:var(--muted);font-size:14px;margin-top:0' }, [state.pack.pack_description])
  436. : null,
  437. hasSaved
  438. ? h('div', { class: 'resume-notice' }, [
  439. h('span', {}, [`Progression sauvegardée : ${answeredCount} / ${total} questions`]),
  440. ])
  441. : null,
  442. h('div', { class: 'btnrow' }, [
  443. h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Choisir un autre outil']),
  444. hasSaved
  445. ? h('button', { class: 'btn btn--outline', onClick: startFresh }, ['Recommencer à zéro'])
  446. : null,
  447. h('button', { class: 'btn btn--primary', onClick: hasSaved ? resume : startFresh }, [
  448. hasSaved ? `Reprendre (Q${Math.min(Object.keys(state.answers).length + 1, total)}) →` : 'Commencer →',
  449. ]),
  450. ]),
  451. ]),
  452. ]);
  453. }
  454. /* ── QUIZ ── */
  455. function renderQuiz() {
  456. const q = state.pack?.questions?.[state.idx];
  457. if (!q) return h('div', { class: 'card' }, ['Chargement…']);
  458. const total = state.pack.questions.length;
  459. const pos = state.idx + 1;
  460. const pct = Math.round(((pos - 1) / total) * 100);
  461. const selected = state.answers[q.id] || '';
  462. const opts = (q.options || []).map(opt => {
  463. const id = `opt_${q.id}_${opt.id}`;
  464. const isSelected = selected === opt.id;
  465. const isNa = opt.id === 'NA' || opt.id === 'DK' || opt.id.toLowerCase().endsWith('_na') || opt.id.toLowerCase().endsWith('_dk');
  466. return h('label', { class: `opt${isSelected ? ' opt--selected' : ''}${isNa ? ' opt--na' : ''}`, for: id }, [
  467. h('input', {
  468. id, type: 'radio', name: q.id, value: opt.id,
  469. checked: isSelected ? 'checked' : null,
  470. onChange: (e) => {
  471. state.answers[q.id] = e.target.value;
  472. saveProgress();
  473. render();
  474. if (autoAdvanceTimer) clearTimeout(autoAdvanceTimer);
  475. autoAdvanceTimer = setTimeout(() => {
  476. autoAdvanceTimer = null;
  477. const t = state.pack?.questions?.length || 0;
  478. if (state.idx < t - 1) { state.idx++; saveProgress(); render(); }
  479. else setView(hasOptionalQuestions() ? 'optional' : 'computing');
  480. }, 380);
  481. },
  482. }),
  483. h('div', {}, [h('strong', {}, [opt.label])]),
  484. ]);
  485. });
  486. const canPrev = state.idx > 0;
  487. const canNext = !!selected;
  488. const isLast = state.idx === total - 1;
  489. const next = async () => {
  490. if (!canNext) return;
  491. if (!isLast) { state.idx++; saveProgress(); render(); return; }
  492. setView(hasOptionalQuestions() ? 'optional' : 'computing');
  493. };
  494. return h('div', { class: 'grid' }, [
  495. h('div', { class: 'card' }, [
  496. h('div', { class: 'quizHead' }, [
  497. h('span', { class: 'tag', style: 'font-size:11px' }, [state.pack.pack_title]),
  498. h('div', { class: 'quizStep' }, [
  499. h('strong', {}, [`${pos}`]),
  500. h('span', {}, [` / ${total}`]),
  501. ]),
  502. ]),
  503. h('div', { class: 'progressWrap' }, [
  504. h('div', { class: 'progress' }, [h('div', { style: `width:${pct}%` })]),
  505. h('div', { class: 'progressMeta' }, [
  506. h('span', { class: 'progressPct' }, [`${pct}\u00a0%`]),
  507. h('span', { class: 'progressRemain' }, [
  508. isLast ? 'Dernière question' : `encore ${total - pos} question${total - pos > 1 ? 's' : ''}`,
  509. ]),
  510. ]),
  511. ]),
  512. h('div', { class: 'qTitle' }, [q.label]),
  513. q.help ? h('p', { class: 'qHelp' }, [q.help]) : null,
  514. h('div', { class: 'options' }, opts),
  515. h('div', { class: 'btnrow', style: 'margin-top:18px' }, [
  516. h('button', { class: 'btn btn--outline', disabled: canPrev ? null : 'disabled', onClick: () => { state.idx--; saveProgress(); render(); } }, ['← Précédent']),
  517. h('button', { class: `btn ${canNext ? 'btn--primary' : 'btn--outline'}`, disabled: canNext ? null : 'disabled', onClick: next }, [
  518. isLast ? 'Voir mon résultat →' : 'Suivant →',
  519. ]),
  520. ]),
  521. h('p', { class: 'hint', style: 'margin-top:10px' }, ['Vous pouvez modifier vos réponses avant la fin.']),
  522. ]),
  523. ]);
  524. }
  525. /* ── COMPUTING (skip optional, submit directly) ── */
  526. function renderComputing() {
  527. (async () => {
  528. try {
  529. const data = await apiJson('/score.php', {
  530. method: 'POST',
  531. body: { pack_id: state.packId, answers: state.answers, optional: state.optional },
  532. });
  533. state.result = data.result;
  534. saveProgress();
  535. setView('results');
  536. } catch (e) { alert(e.message || 'Erreur'); }
  537. })();
  538. return h('div', { class: 'grid' }, [
  539. h('div', { class: 'card', style: 'text-align:center;padding:40px 20px' }, [
  540. h('div', { class: 'h2' }, ['Calcul en cours…']),
  541. h('p', { class: 'lead' }, ['Analyse de vos réponses et génération du diagnostic.']),
  542. ]),
  543. ]);
  544. }
  545. /* ── OPTIONAL ── */
  546. function renderOptional() {
  547. const opt = state.pack?.optional_questions || {};
  548. const volumeKey = Object.keys(opt).find(k => opt[k]?.required_for_cost);
  549. const volumeQ = volumeKey ? opt[volumeKey] : null;
  550. const makeRadioGroup = (q, stateKey, storeAsNumber = true) => {
  551. const cur = state.optional[stateKey];
  552. return h('div', { class: 'field' }, [
  553. h('label', {}, [q.label]),
  554. h('div', { class: 'options', style: 'margin-top:6px' }, q.options.map(o => {
  555. const id = `opt_${stateKey}_${o.id}`;
  556. const val = String(o.value ?? o.id);
  557. const onCh = (e) => {
  558. const v = e.target.value;
  559. state.optional[stateKey] = storeAsNumber && /^-?\d+(\.\d+)?$/.test(v) ? Number(v) : v;
  560. saveProgress();
  561. };
  562. return h('label', { class: 'opt', for: id }, [
  563. h('input', {
  564. id, type: 'radio', name: stateKey, value: val,
  565. checked: String(cur) === val ? 'checked' : null,
  566. onChange: onCh,
  567. }),
  568. h('div', {}, [h('strong', {}, [o.label])]),
  569. ]);
  570. })),
  571. ]);
  572. };
  573. const netSalaryInput = h('div', { class: 'field' }, [
  574. h('label', { for: 'opt_net_salary' }, ['Salaire net mensuel estimé des personnes impliquées']),
  575. h('input', {
  576. id: 'opt_net_salary', type: 'number', min: '0', step: '100',
  577. placeholder: '3500',
  578. value: state.optional.net_salary !== undefined ? String(state.optional.net_salary) : '',
  579. onInput: (e) => { state.optional.net_salary = e.target.value ? Number(e.target.value) : undefined; saveProgress(); },
  580. }),
  581. h('div', { class: 'field-hint' }, [
  582. 'Coût chargé France = salaire net × 1,82 / 152 h/mois (charges salariales + patronales).',
  583. state.optional.net_salary
  584. ? ` → ${Math.round(state.optional.net_salary * COEFF_CHARGE_FR / HEURES_MOIS)} €/h estimé.`
  585. : ' Par défaut : 3 500 €/mois → ~42 €/h.',
  586. ]),
  587. ]);
  588. const compute = async () => {
  589. try {
  590. const optWithCost = { ...state.optional };
  591. const sn = state.optional.net_salary;
  592. if (sn) {
  593. optWithCost.hourly_cost = Math.round(sn * COEFF_CHARGE_FR / HEURES_MOIS);
  594. }
  595. const data = await apiJson('/score.php', {
  596. method: 'POST',
  597. body: { pack_id: state.packId, answers: state.answers, optional: optWithCost },
  598. });
  599. state.result = data.result;
  600. saveProgress();
  601. setView('results');
  602. } catch (e) { alert(e.message || 'Erreur'); }
  603. };
  604. const qualKeys = Object.keys(opt).filter(k => k !== volumeKey && k !== 'net_salary' && opt[k]?.options);
  605. const hasCost = volumeQ || state.pack?.cost_hidden;
  606. const qualBlocks = qualKeys.map(k => makeRadioGroup(opt[k], k, false));
  607. return h('div', { class: 'grid' }, [
  608. h('div', { class: 'card' }, [
  609. h('span', { class: 'tag tag--new', style: 'margin-bottom:12px;display:inline-block' }, ['Optionnel']),
  610. h('h1', { class: 'h1' }, [hasCost ? 'Quelques infos pour le coût caché' : 'Quelques infos pour personnaliser vos résultats']),
  611. h('p', { class: 'lead' }, [hasCost ? 'Ces données servent uniquement à estimer le coût caché en heures/mois (indicatif). Vous pouvez passer.' : 'Ces données nous aident à mieux qualifier votre contexte. Vous pouvez passer.']),
  612. ...qualBlocks,
  613. volumeQ ? makeRadioGroup(volumeQ, volumeKey) : null,
  614. hasCost ? netSalaryInput : null,
  615. h('div', { class: 'btnrow', style: 'margin-top:20px' }, [
  616. h('button', { class: 'btn btn--outline', onClick: () => setView('quiz') }, ['← Retour']),
  617. h('button', { class: 'btn btn--primary', onClick: compute }, ['Voir mes résultats →']),
  618. ]),
  619. ]),
  620. ]);
  621. }
  622. /* ── RESULTS ── */
  623. function renderResults() {
  624. const r = state.result;
  625. if (!r) return h('div', { class: 'card' }, ['Calcul en cours…']);
  626. const dotColor = levelColor(r.level);
  627. const cost = r.cost_hidden;
  628. const unlocked = state.emailUnlocked;
  629. const pillarRows = (r.pillars || []).map(p => {
  630. const pct = p.max ? Math.round((p.score / p.max) * 100) : 0;
  631. return h('div', { class: 'pRow' }, [
  632. h('div', { class: 'name' }, [p.label]),
  633. h('div', { class: 'val' }, [`${p.score}/${p.max}`]),
  634. h('div', { class: 'bar' }, [h('div', { style: `width:${pct}%` })]),
  635. ]);
  636. });
  637. const riskItems = (r.risks_top3 || []).map(x =>
  638. h('li', {}, [
  639. h('strong', {}, [x.title]),
  640. h('div', { class: 'hint' }, [x.what_happens]),
  641. ])
  642. );
  643. const winItems = (r.quick_wins_preview || []).map(x =>
  644. h('li', {}, [
  645. h('strong', {}, [x.title]),
  646. h('div', { class: 'hint' }, [`${x.effect} ; Effort : ${x.effort}`]),
  647. ])
  648. );
  649. /* ── Excel Diagnostic ── */
  650. const xl = r.excel_diagnostic || null;
  651. const renderExcelDiagnostic = () => {
  652. if (!xl) return null;
  653. const doulColor = xl.douleur >= 65 ? '#b83040' : xl.douleur >= 35 ? '#c07c10' : '#1e8a5e';
  654. const cplxColor = xl.complexite >= 60 ? '#b83040' : xl.complexite >= 35 ? '#c07c10' : '#1e8a5e';
  655. const verdictColor = { transformer: '#b83040', intermediaire: '#c07c10', optimiser: '#1e8a5e' }[xl.verdict.code] || '#2F506D';
  656. const meter = (score, label, color) =>
  657. h('div', { class: 'v2-meter' }, [
  658. h('div', { class: 'v2-meter__num', style: `color:${color}` }, [String(score)]),
  659. h('div', { class: 'v2-meter__sub' }, ['/100']),
  660. h('div', { class: 'v2-meter__lbl' }, [label]),
  661. h('div', { class: 'v2-meter__track' }, [
  662. h('div', { class: 'v2-meter__fill', style: `width:${score}%;background:${color}` }),
  663. ]),
  664. ]);
  665. return h('div', { class: 'card v2-diagnostic' }, [
  666. h('div', { class: 'v2-meters' }, [
  667. meter(xl.douleur, 'Douleur actuelle (collaboration, friction, risque)', doulColor),
  668. meter(xl.complexite, 'Complexité du fichier (technique, gouvernance)', cplxColor),
  669. ]),
  670. h('div', { class: 'v2-badges' }, [
  671. h('span', { class: 'v2-verdict-badge', style: `border-color:${verdictColor};color:${verdictColor}` }, [
  672. `${xl.verdict.label} — ${xl.verdict.desc}`,
  673. ]),
  674. h('span', { class: `v2-tag-badge${xl.tag === 'optimiser' ? ' v2-tag-badge--qw' : xl.tag === 'intermediaire' ? ' v2-tag-badge--qw' : ' v2-tag-badge--proj'}` }, [
  675. xl.tag_label,
  676. ]),
  677. ]),
  678. ]);
  679. };
  680. const renderExcelMiniPlan = () => {
  681. if (!xl || !unlocked) return null;
  682. const actionList = (items, startNum) =>
  683. h('ol', { class: 'v2-plan-list', start: String(startNum) },
  684. (items || []).map(a => h('li', {}, [
  685. h('strong', {}, [a.title]),
  686. h('span', { class: 'hint' }, [` - ${a.effect} ; Effort : ${a.effort}`]),
  687. ]))
  688. );
  689. return h('div', { class: 'v2-mini-plan' }, [
  690. h('div', { class: 'v2-plan-cols' }, [
  691. h('div', { class: 'card v2-plan-section' }, [
  692. h('div', { class: 'v2-plan-title' }, ['3 actions immédiates']),
  693. actionList(xl.actions, 1),
  694. ]),
  695. h('div', { class: 'card v2-plan-section v2-plan-section--qw' }, [
  696. h('div', { class: 'v2-plan-title' }, ['2 quick wins possibles']),
  697. actionList(xl.quick_wins, 4),
  698. ]),
  699. ]),
  700. xl.risque_majeur ? h('div', { class: 'v2-plan-risk-block' }, [
  701. h('div', { class: 'v2-plan-title v2-plan-title--risk' }, ['1 risque majeur à adresser en parallèle']),
  702. h('div', { class: 'v2-plan-risk-card' }, [
  703. h('strong', {}, [xl.risque_majeur.title]),
  704. h('p', { class: 'hint', style: 'margin-top:4px' }, [xl.risque_majeur.what_happens]),
  705. ]),
  706. ]) : null,
  707. ]);
  708. };
  709. /* ── V2 Diagnostic ── */
  710. const v2 = r.v2_diagnostic || null;
  711. const renderV2Diagnostic = () => {
  712. if (!v2) return null;
  713. const potColor = v2.potentiel >= 70 ? '#1e8a5e' : v2.potentiel >= 40 ? '#c07c10' : '#b83040';
  714. const cplxColor = v2.complexite <= 35 ? '#1e8a5e' : v2.complexite <= 65 ? '#c07c10' : '#b83040';
  715. const verdictColor = { prioritaire: '#1e8a5e', candidat: '#c07c10', attente: '#5e789a' }[v2.verdict.code] || '#2F506D';
  716. const meter = (score, label, color) =>
  717. h('div', { class: 'v2-meter' }, [
  718. h('div', { class: 'v2-meter__num', style: `color:${color}` }, [String(score)]),
  719. h('div', { class: 'v2-meter__sub' }, ['/100']),
  720. h('div', { class: 'v2-meter__lbl' }, [label]),
  721. h('div', { class: 'v2-meter__track' }, [
  722. h('div', { class: 'v2-meter__fill', style: `width:${score}%;background:${color}` }),
  723. ]),
  724. ]);
  725. return h('div', { class: 'card v2-diagnostic' }, [
  726. h('div', { class: 'v2-meters' }, [
  727. meter(v2.potentiel, 'Potentiel d\'automatisation', potColor),
  728. meter(v2.complexite, 'Complexité de mise en œuvre', cplxColor),
  729. ]),
  730. h('div', { class: 'v2-badges' }, [
  731. h('span', { class: 'v2-verdict-badge', style: `border-color:${verdictColor};color:${verdictColor}` }, [
  732. `${v2.verdict.label} - ${v2.verdict.desc}`,
  733. ]),
  734. h('span', { class: `v2-tag-badge${v2.tag === 'quick_win' ? ' v2-tag-badge--qw' : ' v2-tag-badge--proj'}` }, [
  735. v2.tag_label,
  736. ]),
  737. ]),
  738. ]);
  739. };
  740. const renderMiniPlan = () => {
  741. if (!v2 || !unlocked) return null;
  742. const actionList = (items, startNum) =>
  743. h('ol', { class: 'v2-plan-list', start: String(startNum) },
  744. (items || []).map(a => h('li', {}, [
  745. h('strong', {}, [a.title]),
  746. h('span', { class: 'hint' }, [` - ${a.effect} ; Effort : ${a.effort}`]),
  747. ]))
  748. );
  749. return h('div', { class: 'v2-mini-plan' }, [
  750. h('div', { class: 'v2-plan-cols' }, [
  751. h('div', { class: 'card v2-plan-section' }, [
  752. h('div', { class: 'v2-plan-title' }, ['3 actions immédiates']),
  753. actionList(v2.actions, 1),
  754. ]),
  755. h('div', { class: 'card v2-plan-section v2-plan-section--qw' }, [
  756. h('div', { class: 'v2-plan-title' }, ['2 quick wins possibles']),
  757. actionList(v2.quick_wins, 4),
  758. ]),
  759. ]),
  760. v2.risque_majeur ? h('div', { class: 'v2-plan-risk-block' }, [
  761. h('div', { class: 'v2-plan-title v2-plan-title--risk' }, ['1 risque majeur à adresser en parallèle']),
  762. h('div', { class: 'v2-plan-risk-card' }, [
  763. h('strong', {}, [v2.risque_majeur.title]),
  764. h('p', { class: 'hint', style: 'margin-top:4px' }, [v2.risque_majeur.what_happens]),
  765. ]),
  766. ]) : null,
  767. ]);
  768. };
  769. /* ── Unlock gate ── */
  770. const renderUnlockGate = () => {
  771. const onUnlock = (e) => {
  772. e.preventDefault();
  773. const email = e.target.querySelector('input[type="email"]').value.trim();
  774. if (!email.includes('@') || email.length < 5) return;
  775. state.captureEmail = email;
  776. state.unlockExiting = true;
  777. render();
  778. setTimeout(() => {
  779. state.emailUnlocked = true;
  780. state.unlockExiting = false;
  781. saveProgress();
  782. render();
  783. setTimeout(() => document.getElementById('pdfDialog')?.showModal(), 50);
  784. }, 320);
  785. };
  786. const exiting = state.unlockExiting;
  787. return h('div', { class: 'unlock-gate' + (exiting ? ' unlock-gate--exiting' : '') }, [
  788. h('div', { class: 'unlock-gate__inner' }, [
  789. h('div', { class: 'unlock-gate__icon' }, ['↓']),
  790. h('div', { class: 'h2', style: 'margin-bottom:6px' }, ['Débloquez vos axes d\'amélioration']),
  791. h('p', { class: 'lead', style: 'margin-bottom:20px' }, [
  792. 'Entrez votre email professionnel pour accéder aux 5 actions prioritaires et télécharger votre PDF synthèse.',
  793. ]),
  794. h('form', { class: 'unlock-form', onSubmit: onUnlock }, [
  795. h('div', { class: 'unlock-row' }, [
  796. h('input', {
  797. type: 'email', required: 'required',
  798. placeholder: 'vous@entreprise.com',
  799. autocomplete: 'email',
  800. }),
  801. h('button', { class: 'btn btn--primary btn--unlock', type: 'submit' }, ['Débloquer →']),
  802. ]),
  803. h('p', { class: 'hint', style: 'margin-top:8px;text-align:center' }, [
  804. 'Aucun spam. Désinscription en 1 clic.',
  805. ]),
  806. ]),
  807. ]),
  808. ]);
  809. };
  810. /* ── CTAs débloqués ── */
  811. const renderUnlockedCtas = () =>
  812. h('div', { class: 'unlocked-ctas unlocked-ctas--entering' }, [
  813. h('div', { class: 'unlocked-ctas__inner' }, [
  814. /* En-tête */
  815. h('div', { class: 'h2', style: 'margin-bottom:6px' }, ['Et maintenant ?']),
  816. h('p', { class: 'lead', style: 'margin-bottom:24px' }, [
  817. 'Votre diagnostic révèle des opportunités concrètes. Réservez un entretien offert avec un consultant pour les prioriser et définir votre plan d\'action.',
  818. ]),
  819. /* CTAs commerciaux */
  820. h('div', { class: 'cta-block' }, [
  821. BOOKING_URL ? h('div', { style: 'display:flex;flex-direction:column;align-items:center;width:100%' }, [
  822. h('span', { class: 'cta-offert' }, ['30 min offert']),
  823. h('a', {
  824. class: 'btn btn--primary btn--cta-main',
  825. href: BOOKING_URL, target: '_blank', rel: 'noreferrer',
  826. }, ['Découvrir les opportunités suite à mon audit - Entretien de 30 min offert avec un consultant']),
  827. ]) : null,
  828. DEVIS_URL ? h('a', {
  829. class: 'btn btn--outline btn--cta-secondary',
  830. href: DEVIS_URL,
  831. }, ['Demander un devis']) : null,
  832. ]),
  833. h('p', { class: 'hint', style: 'text-align:center;margin-top:10px' }, [
  834. 'Pas d\'engagement. On analyse vos résultats ensemble et on vous propose une solution adaptée.',
  835. ]),
  836. /* Séparateur */
  837. h('hr', { style: 'border:none;border-top:1px solid var(--border,#e2e8f0);margin:24px 0' }),
  838. /* Actions secondaires */
  839. h('div', { class: 'btnrow', style: 'justify-content:center;gap:10px' }, [
  840. h('button', {
  841. class: 'btn btn--outline',
  842. onClick: () => document.getElementById('pdfDialog')?.showModal(),
  843. }, ['Télécharger mon PDF']),
  844. h('button', {
  845. class: 'btn btn--outline',
  846. style: 'font-size:13px',
  847. onClick: goStart,
  848. }, ['Diagnostiquer un autre process']),
  849. ]),
  850. ]),
  851. ]);
  852. return h('div', { class: 'grid' }, [
  853. /* Score header */
  854. h('div', { class: 'card' }, [
  855. h('div', { style: 'display:flex;align-items:center;gap:10px;margin-bottom:16px' }, [
  856. h('span', { class: 'tag' }, [state.pack?.pack_title || '']),
  857. ]),
  858. h('div', { class: 'scoreBox' }, [
  859. h('div', {}, [
  860. h('div', { class: 'scoreLabel' }, ['Score global']),
  861. h('div', { class: 'scoreBig' }, [`${r.score_total}/100`]),
  862. h('div', { class: 'level-badge', style: 'margin-top:10px' }, [
  863. h('span', { class: 'level-dot', style: `background:${dotColor}` }),
  864. h('span', {}, [`${r.level} - ${r.level_label}`]),
  865. ]),
  866. h('div', { class: 'confidence' }, [`Confiance du diagnostic : ${r.confidence?.label || ''}`]),
  867. ]),
  868. ]),
  869. h('div', { class: 'pillars' }, pillarRows),
  870. ]),
  871. /* V2 : carte diagnostic (toujours visible) */
  872. v2 ? renderV2Diagnostic() : null,
  873. /* Excel : carte diagnostic (toujours visible) */
  874. xl ? renderExcelDiagnostic() : null,
  875. /* Non-V2/Excel : risques (visibles uniquement après déblocage) */
  876. !v2 && !xl && unlocked && !state.unlockExiting ? h('div', { class: 'card' }, [
  877. h('div', { class: 'h2' }, ['3 risques probables']),
  878. riskItems.length
  879. ? h('ol', { class: 'list' }, riskItems)
  880. : h('p', { class: 'muted small' }, ['Aucun risque majeur détecté.']),
  881. ]) : null,
  882. /* Non-V2/Excel : coût caché (visible uniquement après déblocage) */
  883. !v2 && !xl && unlocked && !state.unlockExiting && cost ? h('div', { class: 'cost-block' }, [
  884. h('div', { class: 'h2' }, ['Coût caché estimé']),
  885. h('div', { class: 'cost-figures' }, [
  886. h('div', { class: 'cost-fig' }, [
  887. h('span', { class: 'val' }, [`${cost.hours_per_month} h`]),
  888. h('span', { class: 'lbl' }, ['par mois (estimé)']),
  889. ]),
  890. h('div', { class: 'cost-fig' }, [
  891. h('span', { class: 'val' }, [`~${cost.eur_per_month} €`]),
  892. h('span', { class: 'lbl' }, ['par mois (indicatif)']),
  893. ]),
  894. ]),
  895. h('p', { class: 'hint' }, ['Estimation indicative, à valider par mesure réelle.']),
  896. ]) : null,
  897. /* Gate (formulaire déblocage) ou contenu débloqué - gate visible pendant animation de sortie */
  898. !unlocked || state.unlockExiting ? renderUnlockGate() : null,
  899. /* V2 : mini plan (débloqué) */
  900. v2 ? renderMiniPlan() : null,
  901. /* Excel : mini plan (débloqué) */
  902. xl ? renderExcelMiniPlan() : null,
  903. /* Non-V2/Excel : quick wins (débloqués) */
  904. !v2 && !xl && unlocked && !state.unlockExiting ? h('div', { class: 'card' }, [
  905. h('div', { class: 'h2' }, ['5 quick wins prioritaires']),
  906. winItems.length
  907. ? h('ol', { class: 'list' }, winItems)
  908. : h('p', { class: 'muted small' }, ['-']),
  909. h('p', { class: 'hint', style: 'margin-top:8px' }, ['Le PDF contient les 5 actions avec détail effort/impact.']),
  910. ]) : null,
  911. /* CTA débloqué */
  912. unlocked && !state.unlockExiting ? renderUnlockedCtas() : null,
  913. renderPdfDialog(),
  914. ]);
  915. }
  916. /* ── PDF DIALOG ── */
  917. function renderPdfDialog() {
  918. const onSubmit = async (e) => {
  919. e.preventDefault();
  920. const email = e.target.email.value.trim();
  921. if (!email) return;
  922. try {
  923. const headers = { 'Content-Type': 'application/json' };
  924. const csrf = appEl?.dataset?.csrfToken;
  925. if (csrf) headers['X-CSRF-Token'] = csrf;
  926. const res = await fetch(`${API_BASE}/pdf.php`, {
  927. method: 'POST',
  928. headers,
  929. credentials: 'same-origin',
  930. body: JSON.stringify({
  931. pack_id: state.packId, answers: state.answers,
  932. optional: state.optional, booking_url: BOOKING_URL, email,
  933. }),
  934. });
  935. if (!res.ok) { const j = await res.json().catch(() => ({})); throw new Error(j?.error || 'Erreur PDF'); }
  936. const blob = await res.blob();
  937. const url = URL.createObjectURL(blob);
  938. const a = document.createElement('a');
  939. a.href = url; a.download = `controle-technique-${state.packId}.pdf`;
  940. document.body.appendChild(a); a.click(); a.remove(); URL.revokeObjectURL(url);
  941. document.getElementById('pdfDialog')?.close();
  942. } catch (err) { alert(err.message || 'Erreur'); }
  943. };
  944. return h('dialog', { id: 'pdfDialog', class: 'dialog' }, [
  945. h('form', { class: 'dialog__inner', onSubmit }, [
  946. h('div', { class: 'dialog__head' }, [
  947. h('strong', {}, ['Télécharger votre synthèse PDF']),
  948. h('button', { class: 'btn btn--outline', style: 'padding:6px 12px;font-size:13px', type: 'button',
  949. onClick: () => document.getElementById('pdfDialog')?.close() }, ['Fermer']),
  950. ]),
  951. h('div', { class: 'dialog__body' }, [
  952. h('div', { class: 'field' }, [
  953. h('label', { for: 'pdfEmail' }, ['Email professionnel']),
  954. h('input', {
  955. id: 'pdfEmail', name: 'email', type: 'email', required: 'required',
  956. placeholder: 'vous@entreprise.com',
  957. value: state.captureEmail || '',
  958. }),
  959. ]),
  960. h('label', { class: 'check' }, [
  961. h('input', { type: 'checkbox', required: 'required' }),
  962. h('span', {}, ['J\'accepte de recevoir mon PDF et un email de suivi éventuel.']),
  963. ]),
  964. h('div', { class: 'btnrow', style: 'margin-top:14px' }, [
  965. h('button', { class: 'btn btn--primary', type: 'submit' }, ['Télécharger mon PDF →']),
  966. ]),
  967. h('p', { class: 'hint' }, ['Désinscription en 1 clic. Suppression des données sur demande.']),
  968. ]),
  969. ]),
  970. ]);
  971. }
  972. /* ════════════════════════════════════════════════════
  973. ROI CALCULATOR - données & calcul
  974. ════════════════════════════════════════════════════ */
  975. // Coût chargé France : net → brut (÷0,78) → coût employeur (×1,42) ≈ net × 1,82
  976. // Base légale 35h : 35 × 52 / 12 ≈ 152 h/mois
  977. const COEFF_CHARGE_FR = 1.82;
  978. const HEURES_MOIS = 152;
  979. const ROI_DEFAULTS = { salaireNet: 3500, tauxErreurs: 10, tempsErreur: 15 };
  980. function computeRoi(inp) {
  981. const v = Math.max(0, parseFloat(inp.volume) || 0);
  982. const tA = Math.max(0, parseFloat(inp.tempsActuel) || 0);
  983. const tC = Math.max(0, parseFloat(inp.tempsCible) || 0);
  984. const sn = inp.salaireNet !== '' ? (parseFloat(inp.salaireNet) || 0) : ROI_DEFAULTS.salaireNet;
  985. const ch = Math.round((sn * COEFF_CHARGE_FR) / HEURES_MOIS * 100) / 100;
  986. const te = inp.tauxErreurs !== '' ? (parseFloat(inp.tauxErreurs) || 0) : ROI_DEFAULTS.tauxErreurs;
  987. const tpe = inp.tempsErreur !== '' ? (parseFloat(inp.tempsErreur) || 0) : ROI_DEFAULTS.tempsErreur;
  988. const usedDefaults = [inp.salaireNet, inp.tauxErreurs, inp.tempsErreur].filter(x => x === '').length;
  989. const confidence = usedDefaults === 0 ? 'Fort' : usedDefaults <= 1 ? 'Moyen' : 'Faible';
  990. const gainTempsMin = v * Math.max(0, tA - tC);
  991. const gainTempsH = gainTempsMin / 60;
  992. const gainTraitement = gainTempsH * ch;
  993. const nbErreurs = v * (te / 100);
  994. const gainErreursMin = nbErreurs * tpe;
  995. const gainErreursH = gainErreursMin / 60;
  996. const gainErreurs = gainErreursH * ch;
  997. const roiMensuel = gainTraitement + gainErreurs;
  998. const roiAnnuel = roiMensuel * 12;
  999. const levers = [
  1000. { label: 'Gain de traitement', euros: gainTraitement, heures: gainTempsH, detail: `${v} cas × ${Math.max(0, tA - tC)} min gagnées` },
  1001. { label: 'Réduction des erreurs', euros: gainErreurs, heures: gainErreursH, detail: `~${Math.round(nbErreurs * 10) / 10} erreurs évitées × ${tpe} min` },
  1002. ].sort((a, b) => b.euros - a.euros);
  1003. const conclusion =
  1004. roiAnnuel >= 50000 ? 'À ce niveau, l\'investissement se rentabilise en quelques semaines - difficile de ne pas le faire.' :
  1005. roiAnnuel >= 20000 ? 'À ce niveau, ça se rentabilise en moins de 3 mois sur la plupart des projets.' :
  1006. roiAnnuel >= 5000 ? 'Des gains concrets et mesurables - suffisant pour déclencher une discussion interne.' :
  1007. 'Des gains modestes en valeur absolue, mais chaque heure récupérée libère du temps à forte valeur.';
  1008. return { gainTempsH, gainTraitement, gainErreursH, gainErreurs, roiMensuel, roiAnnuel, levers, conclusion, confidence, usedDefaults, coutHoraire: ch, salaireNet: sn };
  1009. }
  1010. function renderRoi() {
  1011. const inp = state.roiInputs;
  1012. const roiField = (key, label, unit, required, placeholder, defHint) =>
  1013. h('div', { class: 'roi-field' }, [
  1014. h('label', { for: `roi_${key}` }, [
  1015. label,
  1016. h('span', { class: 'roi-unit' }, [` (${unit})`]),
  1017. ]),
  1018. h('input', {
  1019. id: `roi_${key}`, type: 'number', min: '0', step: 'any',
  1020. required: required ? 'required' : null,
  1021. placeholder: placeholder != null ? String(placeholder) : undefined,
  1022. value: inp[key] !== undefined ? String(inp[key]) : '',
  1023. onInput: (e) => { state.roiInputs[key] = e.target.value; },
  1024. }),
  1025. defHint ? h('div', { class: 'field-hint' }, [defHint]) : null,
  1026. ]);
  1027. return h('div', { class: 'grid' }, [
  1028. h('form', { class: 'card', onSubmit: (e) => { e.preventDefault(); state.roiResult = computeRoi(state.roiInputs); setView('roi-results'); } }, [
  1029. h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--roi' }, ['ROI Calculator'])]),
  1030. h('h1', { class: 'h1' }, ['Calculez le gain potentiel de votre optimisation']),
  1031. h('p', { class: 'lead' }, [
  1032. 'Renseignez vos données - les valeurs par défaut permettent d\'avancer sans avoir tous les chiffres.',
  1033. ]),
  1034. h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Données de base']),
  1035. h('p', { class: 'hint', style: 'margin:0 0 10px' }, ['Ces 3 champs sont nécessaires au calcul.']),
  1036. h('div', { class: 'roi-grid' }, [
  1037. roiField('volume', 'Volume mensuel', 'cas/mois', true, 80),
  1038. roiField('tempsActuel', 'Temps actuel par cas', 'min', true, 45),
  1039. roiField('tempsCible', 'Temps cible après opt.', 'min', true, 20),
  1040. ]),
  1041. h('div', { class: 'section-label', style: 'margin-top:20px' }, ['Paramètres de coût']),
  1042. h('p', { class: 'hint', style: 'margin:0 0 10px' }, ['Pré-remplis avec des valeurs types - modifiez si vous les connaissez.']),
  1043. h('div', { class: 'roi-grid' }, [
  1044. roiField('salaireNet', 'Salaire net mensuel estimé', '€/mois', false, null, 'Par défaut : 3 500 €/mois → ~42 €/h chargé'),
  1045. roiField('tauxErreurs', 'Taux erreurs / retours', '%', false, null, 'Par défaut : 10 %'),
  1046. roiField('tempsErreur', 'Temps perdu par erreur', 'min', false, null, 'Par défaut : 15 min'),
  1047. ]),
  1048. h('p', { class: 'hint', style: 'margin:4px 0 0;font-style:italic' }, [
  1049. 'Coût chargé France = salaire net × 1,82 / 152 h/mois (charges salariales + patronales estimées).',
  1050. ]),
  1051. h('div', { class: 'btnrow', style: 'margin-top:24px' }, [
  1052. h('button', { class: 'btn btn--outline', type: 'button', onClick: () => setView('landing') }, ['← Retour']),
  1053. h('button', { class: 'btn btn--primary', type: 'submit' }, ['Calculer mon ROI →']),
  1054. ]),
  1055. ]),
  1056. ]);
  1057. }
  1058. function renderRoiResults() {
  1059. const r = state.roiResult;
  1060. if (!r) { setView('roi'); return h('div', {}); }
  1061. const fmt = (n) => Math.round(n).toLocaleString('fr-FR');
  1062. const fmtH = (n) => n < 1 ? `${Math.round(n * 60)} min` : `${(Math.round(n * 10) / 10).toLocaleString('fr-FR')} h`;
  1063. const confClass = { Fort: 'confidence-pill--fort', Moyen: 'confidence-pill--moyen', Faible: 'confidence-pill--faible' }[r.confidence] || '';
  1064. const confLabel = {
  1065. Fort: '● Confiance forte - vos propres chiffres',
  1066. Moyen: '◐ Confiance moyenne - mix données + défauts',
  1067. Faible: '○ Confiance faible - majorité de valeurs par défaut',
  1068. }[r.confidence] || '';
  1069. return h('div', { class: 'grid' }, [
  1070. h('div', { class: 'card' }, [
  1071. h('div', { style: 'display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:10px;margin-bottom:12px' }, [
  1072. h('span', { class: 'tag tag--roi' }, ['ROI Calculator - Résultats']),
  1073. h('span', { class: `confidence-pill ${confClass}` }, [confLabel]),
  1074. ]),
  1075. h('div', { class: 'roi-hero' }, [
  1076. h('div', { class: 'roi-hero__item' }, [
  1077. h('div', { class: 'roi-hero__val' }, [`${fmt(r.roiMensuel)} €`]),
  1078. h('div', { class: 'roi-hero__lbl' }, ['ROI mensuel estimé']),
  1079. h('div', { class: 'roi-hero__sub' }, [`≈ ${fmt(r.roiAnnuel)} €/an`]),
  1080. ]),
  1081. h('div', { class: 'roi-hero__sep' }),
  1082. h('div', { class: 'roi-hero__item' }, [
  1083. h('div', { class: 'roi-hero__val' }, [fmtH(r.gainTempsH + r.gainErreursH)]),
  1084. h('div', { class: 'roi-hero__lbl' }, ['Heures récupérées / mois']),
  1085. ]),
  1086. ]),
  1087. ]),
  1088. h('div', { class: 'card' }, [
  1089. h('div', { class: 'h2' }, ['Les 2 leviers qui pèsent le plus']),
  1090. h('div', { class: 'lever-cards' }, r.levers.map((l, i) =>
  1091. h('div', { class: `lever-card${i === 0 ? ' lever-card--top' : ''}` }, [
  1092. h('div', { class: 'lever-card__lbl' }, [i === 0 ? '🏆 Levier principal' : 'Levier secondaire']),
  1093. h('div', { style: 'font-weight:700;font-size:15px;color:var(--navy);margin:4px 0 2px' }, [l.label]),
  1094. h('div', { class: 'lever-card__amt' }, [`${fmt(l.euros)} €/mois`]),
  1095. h('div', { class: 'lever-card__det' }, [`${fmtH(l.heures)} récupérées ; ${l.detail}`]),
  1096. ])
  1097. )),
  1098. ]),
  1099. h('div', { class: 'conclusion-box' }, [
  1100. h('p', {}, [r.conclusion]),
  1101. h('p', { class: 'hint' }, [
  1102. `Hypothèse coût : ${Math.round(r.coutHoraire)} €/h chargé (base ${r.salaireNet.toLocaleString('fr-FR')} € net/mois × 1,82 / 152 h — France).`,
  1103. ]),
  1104. r.usedDefaults > 0
  1105. ? h('p', { class: 'hint' }, [
  1106. `${r.usedDefaults} valeur${r.usedDefaults > 1 ? 's' : ''} par défaut utilisée${r.usedDefaults > 1 ? 's' : ''} - affinez avec vos chiffres réels pour plus de précision.`,
  1107. ])
  1108. : null,
  1109. ]),
  1110. h('div', { class: 'card' }, [
  1111. h('div', { class: 'h2' }, ['Et maintenant ?']),
  1112. h('p', { class: 'lead', style: 'margin-bottom:16px' }, [
  1113. 'Utilisez ces chiffres pour déclencher une décision. La prochaine étape : identifier les 3 actions concrètes à mettre en œuvre.',
  1114. ]),
  1115. h('div', { class: 'btnrow' }, [
  1116. BOOKING_URL ? h('a', { class: 'btn btn--primary', href: BOOKING_URL, target: '_blank', rel: 'noreferrer' }, ['Entretien 30 min offert avec un consultant']) : null,
  1117. h('button', { class: BOOKING_URL ? 'btn btn--outline' : 'btn btn--primary', onClick: () => setView('qwf') }, ['Trouver mes 3 quick wins →']),
  1118. ]),
  1119. h('div', { class: 'btnrow', style: 'margin-top:6px' }, [
  1120. h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('roi') }, ['← Modifier mes données']),
  1121. h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('landing') }, ['Autres outils']),
  1122. ]),
  1123. ]),
  1124. ]);
  1125. }
  1126. /* ════════════════════════════════════════════════════
  1127. QUICK WINS FINDER - données & calcul
  1128. ════════════════════════════════════════════════════ */
  1129. const QW_LIBRARY = [
  1130. {
  1131. id: 'statuts-notifications',
  1132. title: 'Statuts uniques + notifications ciblées',
  1133. result: 'Fin des relances et visibilité instantanée sur l\'avancement',
  1134. setup: 'Statut central (ex : "à valider", "en cours IT", "bloqué", "terminé") + notifications automatiques aux bons rôles',
  1135. prereqs: 'Définir un owner, les statuts métier, accès boîtes mail ou Teams',
  1136. effort: 'S à M', delay: '2 à 4 semaines',
  1137. impact: ['Baisse du délai global', 'Moins d\'interruptions', 'Moins de relances'],
  1138. triggers: { relancesFrequentes: 3, validationsMultiples: 1 },
  1139. },
  1140. {
  1141. id: 'formulaire-intelligent',
  1142. title: 'Formulaire intelligent de collecte',
  1143. result: 'Moins de retours arrière, dossiers complets dès le départ',
  1144. setup: 'Champs conditionnels + contrôles à la saisie + pièces demandées au bon moment + validation de cohérence',
  1145. prereqs: 'Liste des champs obligatoires, règles simples, rôles définis',
  1146. effort: 'M', delay: '3 à 6 semaines',
  1147. impact: ['Baisse des erreurs', 'Baisse du temps de traitement', 'Moins de rejets'],
  1148. triggers: { erreursFréquentes: 3, validationsMultiples: 2 },
  1149. },
  1150. {
  1151. id: 'suppression-double-saisie',
  1152. title: 'Suppression de la double saisie entre outils',
  1153. result: 'Arrêt du copier-coller Excel/email vers outil final',
  1154. setup: 'Synchronisation des champs clés (push) ou import structuré automatique entre les outils',
  1155. prereqs: 'Accès API ou export/import structuré, mapping des champs clés',
  1156. effort: 'M', delay: '4 à 8 semaines',
  1157. impact: ['Gain de temps direct', 'Moins d\'erreurs de saisie', 'Données fiables partout'],
  1158. triggers: { doubleSaisie: 3, nbOutilsEleve: 2 },
  1159. },
  1160. {
  1161. id: 'dossier-unique',
  1162. title: 'Dossier unique par dossier',
  1163. result: 'Fin du chaos documentaire - tout au même endroit',
  1164. setup: 'Convention de nommage + dépôt structuré des pièces + lien unique accessible depuis le process',
  1165. prereqs: 'Choix d\'un espace de stockage partagé, définition des règles de nommage',
  1166. effort: 'S', delay: '1 à 3 semaines',
  1167. impact: ['Moins de temps perdu à chercher', 'Moins d\'erreurs', 'Meilleure traçabilité'],
  1168. triggers: { docsEparpilles: 3, erreursFréquentes: 1 },
  1169. },
  1170. {
  1171. id: 'workflow-validation',
  1172. title: 'Workflow de validation simplifié',
  1173. result: 'Validation en un clic, délais réduits, zéro perte en route',
  1174. setup: 'Règles de validation claires + SLA définis + tableau de bord de suivi des en-cours',
  1175. prereqs: 'Matrice de validation, SLA définis, accès configuré pour les validateurs',
  1176. effort: 'M', delay: '3 à 5 semaines',
  1177. impact: ['Baisse du délai global', 'Moins de blocages', 'Meilleure traçabilité'],
  1178. triggers: { validationsMultiples: 3, relancesFrequentes: 1 },
  1179. },
  1180. {
  1181. id: 'exports-automatiques',
  1182. title: 'Exports propres automatiques',
  1183. result: 'Fin du reporting manuel - données toujours à jour',
  1184. setup: 'Export planifié + format standard + envoi automatique aux destinataires',
  1185. prereqs: 'Accès aux sources de données, liste des destinataires, fréquence définie',
  1186. effort: 'S à M', delay: '2 à 5 semaines',
  1187. impact: ['Temps récupéré sur le reporting', 'Fiabilité des données', 'Partage facilité'],
  1188. triggers: { reportingManuel: 3, nbOutilsEleve: 1 },
  1189. },
  1190. ];
  1191. const QWF_QUESTIONS = [
  1192. { id: 'doubleSaisie', label: 'Des données sont saisies manuellement dans plusieurs outils différents (copier-coller, ressaisie…)' },
  1193. { id: 'validationsMultiples', label: 'Plusieurs personnes ou étapes distinctes doivent valider chaque dossier' },
  1194. { id: 'relancesFrequentes', label: 'Des relances sont nécessaires pour savoir où en est un dossier' },
  1195. { id: 'docsEparpilles', label: 'Les documents d\'un dossier sont éparpillés (email, drive, bureau local…)' },
  1196. { id: 'reportingManuel', label: 'Du reporting est préparé manuellement (copier-coller, recomposition de données)' },
  1197. { id: 'erreursFréquentes', label: 'Des dossiers reviennent en arrière à cause d\'informations manquantes ou incorrectes' },
  1198. { id: 'nbOutilsEleve', label: 'Ce process fait intervenir 3 outils ou plus (ERP, email, tableur, outil métier…)' },
  1199. ];
  1200. function computeQuickWins(signals) {
  1201. return QW_LIBRARY
  1202. .map(qw => {
  1203. let score = 0;
  1204. for (const [trigger, weight] of Object.entries(qw.triggers)) {
  1205. if (signals[trigger]) score += weight;
  1206. }
  1207. return { ...qw, score };
  1208. })
  1209. .sort((a, b) => b.score - a.score)
  1210. .slice(0, 3);
  1211. }
  1212. function renderQwf() {
  1213. const sig = state.qwfSignals;
  1214. const makeSignalRow = (q) => {
  1215. const isOui = sig[q.id] === true;
  1216. const isNon = sig[q.id] === false;
  1217. return h('div', { class: 'signal-row' }, [
  1218. h('span', { class: 'signal-row__lbl' }, [q.label]),
  1219. h('div', { class: 'signal-row__btns' }, [
  1220. h('button', {
  1221. type: 'button',
  1222. class: `signal-btn signal-btn--oui${isOui ? ' active' : ''}`,
  1223. onClick: () => { state.qwfSignals[q.id] = isOui ? undefined : true; render(); },
  1224. }, ['Oui']),
  1225. h('button', {
  1226. type: 'button',
  1227. class: `signal-btn signal-btn--non${isNon ? ' active' : ''}`,
  1228. onClick: () => { state.qwfSignals[q.id] = isNon ? undefined : false; render(); },
  1229. }, ['Non']),
  1230. ]),
  1231. ]);
  1232. };
  1233. const answeredCount = QWF_QUESTIONS.filter(q => sig[q.id] !== undefined).length;
  1234. const canSubmit = answeredCount >= 3;
  1235. return h('div', { class: 'grid' }, [
  1236. h('div', { class: 'card' }, [
  1237. h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--qwf' }, ['Quick Wins Finder'])]),
  1238. h('h1', { class: 'h1' }, ['Identifiez vos 3 actions prioritaires']),
  1239. h('p', { class: 'lead' }, [
  1240. 'Répondez à ces 7 signaux pour recevoir 3 recommandations concrètes adaptées à votre process.',
  1241. ]),
  1242. h('div', { class: 'signal-list' }, QWF_QUESTIONS.map(makeSignalRow)),
  1243. h('div', { class: 'btnrow', style: 'margin-top:22px' }, [
  1244. h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Retour']),
  1245. h('button', {
  1246. class: 'btn btn--primary',
  1247. disabled: canSubmit ? null : 'disabled',
  1248. onClick: () => { if (canSubmit) { state.qwfResult = computeQuickWins(state.qwfSignals); setView('qwf-results'); } },
  1249. }, [canSubmit ? 'Voir mes 3 quick wins →' : `Répondre à encore ${3 - answeredCount} signal${3 - answeredCount > 1 ? 's' : ''}`]),
  1250. ]),
  1251. h('p', { class: 'hint', style: 'margin-top:8px' }, ['Répondez à au moins 3 signaux pour déverrouiller le résultat.']),
  1252. ]),
  1253. ]);
  1254. }
  1255. function renderQwfResults() {
  1256. const qws = state.qwfResult;
  1257. if (!qws || qws.length === 0) { setView('qwf'); return h('div', {}); }
  1258. const makeQwCard = (qw, idx) =>
  1259. h('div', { class: 'qw-card' }, [
  1260. h('div', { class: 'qw-card__head' }, [
  1261. h('div', { class: 'qw-card__num' }, [String(idx + 1)]),
  1262. h('div', { class: 'qw-card__head-title' }, [qw.title]),
  1263. ]),
  1264. h('div', { class: 'qw-card__body' }, [
  1265. h('div', { class: 'qw-card__result' }, [qw.result]),
  1266. h('div', { class: 'qw-section' }, [
  1267. h('div', { class: 'qw-section__lbl' }, ['Ce qu\'on met en place']),
  1268. h('div', { class: 'qw-section__val' }, [qw.setup]),
  1269. ]),
  1270. h('div', { class: 'qw-section' }, [
  1271. h('div', { class: 'qw-section__lbl' }, ['Pré-requis']),
  1272. h('div', { class: 'qw-section__val' }, [qw.prereqs]),
  1273. ]),
  1274. h('div', { class: 'qw-meta' }, [
  1275. h('span', { class: 'badge-effort' }, [`Effort : ${qw.effort}`]),
  1276. h('span', { class: 'badge-delay' }, [`Délai : ${qw.delay}`]),
  1277. ]),
  1278. h('div', { class: 'impact-chips' }, qw.impact.map(i =>
  1279. h('span', { class: 'impact-chip' }, [i])
  1280. )),
  1281. ]),
  1282. ]);
  1283. return h('div', { class: 'grid' }, [
  1284. h('div', { class: 'card' }, [
  1285. h('div', { style: 'margin-bottom:12px' }, [h('span', { class: 'tag tag--qwf' }, ['Quick Wins Finder - Résultats'])]),
  1286. h('h1', { class: 'h1' }, ['Vos 3 actions prioritaires']),
  1287. h('p', { class: 'lead' }, [
  1288. 'Commencez par la première - elle a le plus fort impact selon vos signaux. Chaque fiche contient tout ce qu\'il faut pour démarrer.',
  1289. ]),
  1290. ]),
  1291. h('div', { class: 'qw-cards' }, qws.map(makeQwCard)),
  1292. h('div', { class: 'card' }, [
  1293. h('div', { class: 'h2' }, ['Et maintenant ?']),
  1294. h('p', { class: 'lead', style: 'margin-bottom:16px' }, [
  1295. 'Ces 3 quick wins sont un point de départ solide. Un entretien offert avec un consultant permet de découvrir les opportunités et de cadrer le quick win n°1 en plan d\'action.',
  1296. ]),
  1297. h('div', { class: 'btnrow' }, [
  1298. BOOKING_URL ? h('a', {
  1299. class: 'btn btn--primary', href: BOOKING_URL, target: '_blank', rel: 'noreferrer',
  1300. }, ['Découvrir les opportunités - Entretien 30 min offert']) : null,
  1301. h('button', { class: 'btn btn--outline', onClick: () => setView('roi') }, ['Calculer le ROI →']),
  1302. ]),
  1303. h('div', { class: 'btnrow', style: 'margin-top:6px' }, [
  1304. h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('qwf') }, ['← Modifier mes signaux']),
  1305. h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('landing') }, ['Autres outils']),
  1306. ]),
  1307. ]),
  1308. ]);
  1309. }
  1310. /* ════════════════════════════════════════════════════
  1311. EXCEL → APPLICATION - données & calcul
  1312. ════════════════════════════════════════════════════ */
  1313. const EXCEL_QUESTIONS = [
  1314. { id: 'multiUsagers', label: 'Plus d\'une personne utilise ce fichier Excel' },
  1315. { id: 'simultaneite', label: 'Plusieurs personnes ont besoin de le modifier en même temps' },
  1316. { id: 'erreursSaisie', label: 'Des erreurs de saisie ont déjà causé des problèmes réels (mauvais montant, perte de données…)' },
  1317. { id: 'doubleSaisie', label: 'Des données sont copiées-collées depuis ou vers d\'autres outils (ERP, CRM, email…)' },
  1318. { id: 'partageExterne', label: 'Le fichier est partagé avec des clients, fournisseurs ou partenaires externes' },
  1319. { id: 'tracabilite', label: 'Vous avez besoin de savoir qui a modifié quoi et quand (historique, audit trail)' },
  1320. { id: 'automatisation', label: 'Vous avez besoin de notifications, rappels ou alertes automatiques' },
  1321. { id: 'complexite', label: 'Le fichier est devenu lent, fragile ou difficile à maintenir pour un non-expert' },
  1322. { id: 'processStatuts', label: 'Ce fichier sert à gérer un processus avec des étapes, statuts ou validations' },
  1323. { id: 'impactExternal', label: 'Une erreur ou un retard dans ce fichier peut impacter un client, un fournisseur ou la production' },
  1324. { id: 'tempsPerdu', label: 'Vous et votre équipe passez plus de 2 heures par semaine à saisir, vérifier, corriger ou relancer autour de ce fichier' },
  1325. { id: 'personnesCle', label: 'Une seule personne maîtrise vraiment le fonctionnement du fichier (formules, logique, macros)' },
  1326. { id: 'processStable', label: 'Le processus géré par ce fichier est stable (il ne change pas complètement tous les mois)' },
  1327. { id: 'vuesProfils', label: 'Vous avez besoin de vues différentes selon les profils (opérateur, manager, direction, client, RH…)' },
  1328. { id: 'scalabilite', label: 'Si le volume d\'activité double, ce fichier risque de ne plus tenir correctement' },
  1329. ];
  1330. const EXCEL_QUAL_OUTIL = [
  1331. { id: 'excel_local', label: 'Excel local / réseau' },
  1332. { id: 'excel_partage', label: 'Excel partagé (SharePoint / OneDrive)' },
  1333. { id: 'google_sheet', label: 'Google Sheet' },
  1334. { id: 'les_deux', label: 'Les deux' },
  1335. ];
  1336. const EXCEL_QUAL_PERSONNES = [
  1337. { id: '1', label: '1 seule' },
  1338. { id: '2_3', label: '2 à 3' },
  1339. { id: '4_10', label: '4 à 10' },
  1340. { id: 'plus10', label: 'Plus de 10' },
  1341. ];
  1342. const EXCEL_QUAL_CONSEQUENCE = [
  1343. { id: 'temps', label: 'Perte de temps' },
  1344. { id: 'erreurs', label: 'Risque d\'erreur' },
  1345. { id: 'visibilite', label: 'Manque de visibilité' },
  1346. { id: 'conformite', label: 'Conformité / audit' },
  1347. { id: 'client', label: 'Impact client / fournisseur' },
  1348. ];
  1349. function computeExcelVerdict(signals, qual = {}) {
  1350. const total = EXCEL_QUESTIONS.length;
  1351. const score = EXCEL_QUESTIONS.filter(q => signals[q.id] === true).length;
  1352. if (score <= 4) {
  1353. return {
  1354. score, total, level: 'ok', qual,
  1355. title: 'Excel reste adapté pour l\'instant',
  1356. color: '#1e8a5e',
  1357. icon: '✓',
  1358. summary: `Avec ${score} signaux sur ${total}, votre usage d'Excel est encore maîtrisable. Continuez à l'utiliser, mais documentez vos règles et anticipez l'évolution de vos besoins.`,
  1359. actions: [
  1360. 'Documentez vos formules et règles métier pour faciliter la maintenance et la transmission',
  1361. 'Mettez en place des sauvegardes automatiques et un versionnage du fichier',
  1362. 'Réévaluez dans 6 mois si le volume d\'utilisateurs ou de données augmente',
  1363. ],
  1364. };
  1365. } else if (score <= 8) {
  1366. return {
  1367. score, total, level: 'warn', qual,
  1368. title: 'Vous approchez des limites d\'Excel',
  1369. color: '#c07c10',
  1370. icon: '⚠',
  1371. summary: `Avec ${score} signaux sur ${total}, votre Excel fonctionne encore mais vous en perdez progressivement le contrôle. Une application dédiée deviendra nécessaire à court terme.`,
  1372. actions: [
  1373. 'Identifiez les 2 risques prioritaires (erreurs humaines, conflits de version, perte de données)',
  1374. 'Explorez des solutions no-code ou low-code (Airtable, AppSheet, Make) pour une transition progressive',
  1375. 'Planifiez la migration avant que la situation ne devienne critique ou coûteuse à réparer',
  1376. ],
  1377. };
  1378. } else {
  1379. return {
  1380. score, total, level: 'critical', qual,
  1381. title: 'Une application dédiée s\'impose',
  1382. color: '#b83040',
  1383. icon: '!',
  1384. summary: `Avec ${score} signaux sur ${total}, Excel ne répond plus à vos besoins. Chaque jour sans application dédiée génère des risques réels et du temps perdu.`,
  1385. actions: [
  1386. 'Priorisez ce projet : le coût de l\'inaction (erreurs, temps perdu, risques) dépasse le coût de la transformation',
  1387. 'Commencez par un MVP centré sur vos 2-3 pain points principaux — pas besoin de tout refaire d\'un coup',
  1388. 'Évaluez selon votre volume : no-code (Airtable, Notion) pour de petits volumes, développement sur mesure au-delà',
  1389. ],
  1390. };
  1391. }
  1392. }
  1393. function renderExcelTool() {
  1394. const sig = state.excelSignals;
  1395. const qual = state.excelQual;
  1396. const answeredCount = EXCEL_QUESTIONS.filter(q => sig[q.id] !== undefined).length;
  1397. const remaining = EXCEL_QUESTIONS.length - answeredCount;
  1398. const canSubmit = answeredCount >= EXCEL_QUESTIONS.length;
  1399. const makeSignalRow = (q) => {
  1400. const isOui = sig[q.id] === true;
  1401. const isNon = sig[q.id] === false;
  1402. return h('div', { class: 'signal-row' }, [
  1403. h('span', { class: 'signal-row__lbl' }, [q.label]),
  1404. h('div', { class: 'signal-row__btns' }, [
  1405. h('button', {
  1406. type: 'button',
  1407. class: `signal-btn signal-btn--oui${isOui ? ' active' : ''}`,
  1408. onClick: () => { state.excelSignals[q.id] = isOui ? undefined : true; render(); },
  1409. }, ['Oui']),
  1410. h('button', {
  1411. type: 'button',
  1412. class: `signal-btn signal-btn--non${isNon ? ' active' : ''}`,
  1413. onClick: () => { state.excelSignals[q.id] = isNon ? undefined : false; render(); },
  1414. }, ['Non']),
  1415. ]),
  1416. ]);
  1417. };
  1418. const makeQualChips = (options, field) =>
  1419. h('div', { class: 'qual-chips' }, options.map(opt =>
  1420. h('button', {
  1421. type: 'button',
  1422. class: `qual-chip${qual[field] === opt.id ? ' active' : ''}`,
  1423. onClick: () => { state.excelQual[field] = qual[field] === opt.id ? null : opt.id; render(); },
  1424. }, [opt.label])
  1425. ));
  1426. const makeQualChipsMulti = (options, field) =>
  1427. h('div', { class: 'qual-chips' }, options.map(opt => {
  1428. const arr = Array.isArray(qual[field]) ? qual[field] : [];
  1429. const isActive = arr.includes(opt.id);
  1430. return h('button', {
  1431. type: 'button',
  1432. class: `qual-chip${isActive ? ' active' : ''}`,
  1433. onClick: () => {
  1434. const next = isActive ? arr.filter(x => x !== opt.id) : [...arr, opt.id];
  1435. state.excelQual[field] = next;
  1436. render();
  1437. },
  1438. }, [opt.label]);
  1439. }));
  1440. const group1 = EXCEL_QUESTIONS.slice(0, 8);
  1441. const group2 = EXCEL_QUESTIONS.slice(8);
  1442. const step = state.excelStep || 1;
  1443. const group1Answered = group1.every(q => sig[q.id] !== undefined);
  1444. const group2Answered = group2.every(q => sig[q.id] !== undefined);
  1445. if (step === 1) {
  1446. return h('div', { class: 'grid' }, [
  1447. h('div', { class: 'card' }, [
  1448. h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--excel' }, ['Excel → Application — Étape 1'])]),
  1449. h('h1', { class: 'h1' }, ['Dois-je transformer mon fichier Excel en application ?']),
  1450. h('p', { class: 'lead' }, ['Contexte et premiers signaux.']),
  1451. h('div', { class: 'section-label', style: 'margin-top:18px' }, ['Contexte de votre usage (optionnel)']),
  1452. h('div', { class: 'qual-row' }, [
  1453. h('div', { class: 'qual-row__lbl' }, ['Outil utilisé']),
  1454. makeQualChips(EXCEL_QUAL_OUTIL, 'outil'),
  1455. ]),
  1456. h('div', { class: 'qual-row' }, [
  1457. h('div', { class: 'qual-row__lbl' }, ['Nombre de personnes impliquées']),
  1458. makeQualChips(EXCEL_QUAL_PERSONNES, 'personnes'),
  1459. ]),
  1460. h('div', { class: 'qual-row' }, [
  1461. h('div', { class: 'qual-row__lbl' }, ['Conséquences principales ressenties (choix multiple)']),
  1462. makeQualChipsMulti(EXCEL_QUAL_CONSEQUENCE, 'consequence'),
  1463. ]),
  1464. h('div', { class: 'section-label', style: 'margin-top:20px' }, ['Signaux — Usage et organisation']),
  1465. h('div', { class: 'signal-list' }, group1.map(makeSignalRow)),
  1466. h('div', { class: 'btnrow', style: 'margin-top:22px' }, [
  1467. h('button', { class: 'btn btn--outline', onClick: () => setView('landing') }, ['← Retour']),
  1468. h('button', {
  1469. class: 'btn btn--primary',
  1470. disabled: group1Answered ? null : 'disabled',
  1471. onClick: () => { if (group1Answered) { state.excelStep = 2; render(); } },
  1472. }, [group1Answered ? 'Continuer — Étape 2 →' : `Répondre aux 8 signaux ci-dessus pour continuer`]),
  1473. ]),
  1474. h('p', { class: 'hint', style: 'margin-top:8px' }, ['Étape 1 sur 2.']),
  1475. ]),
  1476. ]);
  1477. }
  1478. return h('div', { class: 'grid' }, [
  1479. h('div', { class: 'card' }, [
  1480. h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--excel' }, ['Excel → Application — Étape 2'])]),
  1481. h('h1', { class: 'h1' }, ['Signaux — Process et viabilité']),
  1482. h('p', { class: 'lead' }, ['Ces 7 derniers signaux permettent d\'affiner le verdict.']),
  1483. h('div', { class: 'signal-list', style: 'margin-top:18px' }, group2.map(makeSignalRow)),
  1484. h('div', { class: 'btnrow', style: 'margin-top:22px' }, [
  1485. h('button', { class: 'btn btn--outline', onClick: () => { state.excelStep = 1; render(); } }, ['← Étape précédente']),
  1486. h('button', {
  1487. class: 'btn btn--primary',
  1488. disabled: canSubmit ? null : 'disabled',
  1489. onClick: () => { if (canSubmit) { state.excelResult = computeExcelVerdict(state.excelSignals, state.excelQual); state.excelStep = 1; setView('excel-results'); } },
  1490. }, [canSubmit ? 'Voir mon verdict →' : `Répondre à encore ${remaining} signal${remaining > 1 ? 's' : ''}`]),
  1491. ]),
  1492. h('p', { class: 'hint', style: 'margin-top:8px' }, ['Étape 2 sur 2. Répondez aux 7 signaux pour déverrouiller le verdict.']),
  1493. ]),
  1494. ]);
  1495. }
  1496. async function submitExcelComplete(withEmail = false) {
  1497. const r = state.excelResult;
  1498. if (!r || state.excelSubmitting || state.excelNotified) return;
  1499. const email = withEmail ? (state.excelCaptureEmail || '').trim() : null;
  1500. if (withEmail && (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email))) return;
  1501. state.excelSubmitting = true;
  1502. render();
  1503. try {
  1504. const payload = {
  1505. result: {
  1506. level: r.level,
  1507. title: r.title,
  1508. summary: r.summary,
  1509. score: r.score,
  1510. total: r.total,
  1511. actions: r.actions,
  1512. qual: r.qual || {},
  1513. },
  1514. };
  1515. if (email) payload.email = email;
  1516. await apiJson('/excel-complete.php', { method: 'POST', body: payload });
  1517. state.excelNotified = true;
  1518. state.excelSubmitting = false;
  1519. } catch (err) {
  1520. state.excelSubmitting = false;
  1521. alert(err?.message || 'Erreur lors de l\'envoi.');
  1522. }
  1523. render();
  1524. }
  1525. function renderExcelResults() {
  1526. const r = state.excelResult;
  1527. if (!r) { setView('excel'); return h('div', {}); }
  1528. const qual = r.qual || {};
  1529. const outilLabels = { excel_local: 'Excel local / réseau', excel_partage: 'Excel partagé (SharePoint / OneDrive)', google_sheet: 'Google Sheet', les_deux: 'Excel et Google Sheet' };
  1530. const personnesLabels = { '1': '1 seule personne', '2_3': '2 à 3 personnes', '4_10': '4 à 10 personnes', 'plus10': 'Plus de 10 personnes' };
  1531. const consequenceLabels = { temps: 'Perte de temps', erreurs: 'Risque d\'erreur', visibilite: 'Manque de visibilité', conformite: 'Conformité / audit', client: 'Impact client / fournisseur' };
  1532. const consequenceArr = Array.isArray(qual.consequence) ? qual.consequence : (qual.consequence ? [qual.consequence] : []);
  1533. const consequenceText = consequenceArr.map(id => consequenceLabels[id] || id).join(', ');
  1534. const hasQual = qual.outil || qual.personnes || consequenceArr.length > 0;
  1535. const qualCard = hasQual ? h('div', { class: 'card' }, [
  1536. h('div', { class: 'h2' }, ['Contexte de votre usage']),
  1537. h('div', { class: 'qual-summary' }, [
  1538. qual.outil ? h('div', { class: 'qual-summary__row' }, [h('span', { class: 'qual-summary__lbl' }, ['Outil : ']), outilLabels[qual.outil] || qual.outil]) : null,
  1539. qual.personnes ? h('div', { class: 'qual-summary__row' }, [h('span', { class: 'qual-summary__lbl' }, ['Personnes impliquées : ']), personnesLabels[qual.personnes] || qual.personnes]) : null,
  1540. consequenceText ? h('div', { class: 'qual-summary__row' }, [h('span', { class: 'qual-summary__lbl' }, ['Conséquences principales : ']), consequenceText]) : null,
  1541. ].filter(Boolean)),
  1542. ]) : null;
  1543. const excelNotifyCard = state.excelNotified
  1544. ? h('div', { class: 'card' }, [
  1545. h('div', { class: 'h2' }, ['Merci !']),
  1546. h('p', { class: 'lead' }, ['Votre diagnostic a bien été enregistré.']),
  1547. ])
  1548. : h('div', { class: 'card' }, [
  1549. h('div', { class: 'h2' }, ['Recevoir les résultats par email ?']),
  1550. h('p', { style: 'margin-bottom:12px;font-size:14px;color:var(--text)' }, [
  1551. 'Optionnel : indiquez votre email pour recevoir une synthèse, ou continuez sans.',
  1552. ]),
  1553. h('div', { class: 'btnrow', style: 'gap:8px;flex-wrap:wrap;align-items:center' }, [
  1554. h('input', {
  1555. type: 'email',
  1556. placeholder: 'votre@email.fr',
  1557. value: state.excelCaptureEmail,
  1558. class: 'input',
  1559. style: 'flex:1;min-width:180px',
  1560. onInput: (e) => { state.excelCaptureEmail = e.target.value; render(); },
  1561. }),
  1562. h('button', {
  1563. class: 'btn btn--primary',
  1564. disabled: state.excelSubmitting || !(state.excelCaptureEmail || '').trim(),
  1565. onClick: () => submitExcelComplete(true),
  1566. }, [state.excelSubmitting ? 'Envoi…' : 'Recevoir par email']),
  1567. h('button', {
  1568. class: 'btn btn--outline',
  1569. disabled: state.excelSubmitting,
  1570. onClick: () => submitExcelComplete(false),
  1571. }, ['Continuer sans email']),
  1572. ]),
  1573. ]);
  1574. return h('div', { class: 'grid' }, [
  1575. h('div', { class: 'card' }, [
  1576. h('div', { style: 'margin-bottom:14px' }, [h('span', { class: 'tag tag--excel' }, ['Excel → Application - Verdict'])]),
  1577. h('h1', { class: 'h1' }, ['Votre verdict']),
  1578. h('div', { class: 'excel-verdict', style: `border-color:${r.color}` }, [
  1579. h('div', { class: 'excel-verdict__icon', style: `background:${r.color}` }, [r.icon]),
  1580. h('div', { class: 'excel-verdict__body' }, [
  1581. h('div', { class: 'excel-verdict__score' }, [`${r.score} / ${r.total} signaux d'alerte`]),
  1582. h('div', { class: 'excel-verdict__title', style: `color:${r.color}` }, [r.title]),
  1583. h('div', { class: 'excel-verdict__summary' }, [r.summary]),
  1584. ]),
  1585. ]),
  1586. ]),
  1587. qualCard,
  1588. excelNotifyCard,
  1589. h('div', { class: 'card' }, [
  1590. h('div', { class: 'h2' }, ['Nos recommandations']),
  1591. h('div', { class: 'excel-actions' }, r.actions.map((action, i) =>
  1592. h('div', { class: 'excel-action' }, [
  1593. h('div', { class: 'excel-action__num' }, [String(i + 1)]),
  1594. h('div', { class: 'excel-action__text' }, [action]),
  1595. ])
  1596. )),
  1597. ]),
  1598. h('div', { class: 'card' }, [
  1599. h('div', { class: 'h2' }, ['Et maintenant ?']),
  1600. h('p', { class: 'lead', style: 'margin-bottom:16px' }, [
  1601. r.level === 'ok'
  1602. ? 'Votre Excel est encore sous contrôle. Si vos besoins évoluent, revenez faire ce diagnostic.'
  1603. : 'Un entretien de 30 minutes permet d\'évaluer ensemble la meilleure solution pour votre situation et de chiffrer l\'effort de transformation.',
  1604. ]),
  1605. h('div', { class: 'btnrow' }, [
  1606. BOOKING_URL ? h('a', {
  1607. class: 'btn btn--primary', href: BOOKING_URL, target: '_blank', rel: 'noreferrer',
  1608. }, ['Évaluer la solution - Entretien 30 min offert']) : null,
  1609. h('button', { class: 'btn btn--outline', onClick: () => setView('roi') }, ['Calculer le ROI →']),
  1610. ]),
  1611. h('div', { class: 'btnrow', style: 'margin-top:6px' }, [
  1612. h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => { state.excelStep = 1; setView('excel'); } }, ['← Modifier mes réponses']),
  1613. h('button', { class: 'btn btn--outline', style: 'font-size:13px', onClick: () => setView('landing') }, ['Accueil']),
  1614. ]),
  1615. ]),
  1616. ].filter(Boolean));
  1617. }
  1618. /* ── RENDER ── */
  1619. function render() {
  1620. if (!appEl) return;
  1621. appEl.innerHTML = '';
  1622. const views = {
  1623. landing: renderLanding,
  1624. select: renderSelect,
  1625. intro: renderIntro,
  1626. quiz: renderQuiz,
  1627. computing: renderComputing,
  1628. optional: renderOptional,
  1629. results: renderResults,
  1630. 'roi': renderRoi,
  1631. 'roi-results': renderRoiResults,
  1632. 'qwf': renderQwf,
  1633. 'qwf-results': renderQwfResults,
  1634. 'excel': renderExcelTool,
  1635. 'excel-results': renderExcelResults,
  1636. };
  1637. appEl.appendChild((views[state.view] || renderLanding)());
  1638. updateNavbar();
  1639. }
  1640. /* ── HEADER update ── */
  1641. function initHeader() {
  1642. const header = document.querySelector('.header');
  1643. if (!header) return;
  1644. header.innerHTML = '';
  1645. const brand = document.createElement('div');
  1646. brand.innerHTML =
  1647. '<div class="brand__logo">Contrôle technique process</div>' +
  1648. '<div class="brand__sub">Diagnostic self-serve ; Livinweb</div>';
  1649. const badge = document.createElement('span');
  1650. badge.className = 'brand__badge';
  1651. badge.textContent = 'V1';
  1652. header.appendChild(brand);
  1653. header.appendChild(badge);
  1654. }
  1655. initHeader();
  1656. render();