diff --git a/services/targo-hub/lib/store.js b/services/targo-hub/lib/store.js new file mode 100644 index 0000000..f275fc5 --- /dev/null +++ b/services/targo-hub/lib/store.js @@ -0,0 +1,381 @@ +'use strict' +/** + * store.js — Boutique matériel (PAGE MODÈLE, staging, servie par le hub). + * Objectif : valider l'EXPÉRIENCE (panier optimistic + visualisation de variantes) + * avant tout branchement. Données démo en dur pour l'instant. + * + * Prochaine étape (P0.2) : remplacer DEMO_CATALOG par GET /store/catalog + * (Items + Product Bundle d'ERPNext) et prix via apply_pricing_rule. + * + * Routes publiques : + * GET /store → page modèle (Vue 3 via CDN, self-contained) + * GET /store/catalog → (à venir) catalogue réel ERPNext + * + * IMPORTANT : ce fichier est un template literal. NE PAS utiliser la séquence + * dollar-accolade dans le HTML/JS interne (Vue utilise les doubles accolades). + */ +const { json } = require('./helpers') + +const PAGE = ` + +Boutique Gigafibre + + +
+
+
GigafibreBoutique
+ +
+ +
+
⚙️ Page modèle — données démo. Branchement au catalogue ERPNext (Items + bundles + prix) à l'étape suivante.
+
+
{{ c }}
+
+
+
+
+ {{ p.icon }} + BUNDLE +
+ +
+
+
+
{{ p.cat }}
+
{{ p.name }}
+
+ + + +
+
+
+
+
+ + + +
+ + + +
+
+ + + +
+
+ +
+
+

Votre panier

+ {{ count }} article{{ count>1?'s':'' }} + × +
+
+
🛒
+
Votre panier est vide
+ +
+
+
+
{{ l.icon }}
+
+
{{ l.name }}
+
{{ l.opt }}
+ Retirer +
+
+
{{ money(l.price*l.qty) }}
+
+ + {{ l.qty }} + +
+
+
+
+
+
Sous-total{{ money(total) }}
+
Taxes (TPS+TVQ ~14,975 %){{ money(total*0.14975) }}
+
Total{{ money(total*1.14975) }}
+ +
Paiement sécurisé Stripe · livraison ou ramassage
+
+
+
+ + +
{{ toast }}
+
+
+ + +` + +async function handle (req, res, method, path) { + if (path === '/store' && method === 'GET') { + res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }) + return res.end(PAGE) + } + // À venir : GET /store/catalog → Items + Product Bundle d'ERPNext + return json(res, 404, { error: 'not found' }) +} + +module.exports = { handle } diff --git a/services/targo-hub/server.js b/services/targo-hub/server.js index b406b78..c0361b3 100644 --- a/services/targo-hub/server.js +++ b/services/targo-hub/server.js @@ -132,6 +132,8 @@ const server = http.createServer(async (req, res) => { if (path === '/book' || path.startsWith('/book/')) return require('./lib/roster').handlePublicBooking(req, res, method, path, url) // Portail self-service d'abonnement (staging) — page + submit, PUBLIC. if (path === '/signup' || path.startsWith('/signup/')) return require('./lib/signup').handle(req, res, method, path) + // Boutique matériel (page modèle, staging) — page + (à venir) catalogue ERPNext, PUBLIC. + if (path === '/store' || path.startsWith('/store/')) return require('./lib/store').handle(req, res, method, path) if (path.startsWith('/campaigns')) return require('./lib/campaigns').handle(req, res, method, path) // Gift redirect wrapper — short public URLs in campaign emails that // 302 to the underlying Giftbit shortlink (subject to our expiry/revoke).