gigafibre-fsm/services/targo-hub/lib/ui/index.js
louispaulb 169426a6d8 refactor(targo-hub): extract ui/ kit, migrate tech-mobile to it
Introduces services/targo-hub/lib/ui/ as the shared kit for every magic-link
page served from the hub (tech mobile, acceptance, payments):

  design.css    tokens (--brand, --success, etc) + reset + all primitives
  components.js server-side HTML builders (badge/section/card/panel/statRow/
                tabBar) + shared date helpers (fmtTime/dateLabelFr/montrealDate)
                + canonical STATUS_META
  client.js     client-side api wrapper ($, toast, api.get/post, router.on/go)
                baked into every page — no more hand-rolled fetch+hashchange
  scanner.js    Gemini field-scan overlay (window.scanner.open(field,label,cb,ctx))
  shell.js      ui.page({title, body, bootVars, cfg, script, includeScanner})
                inlines everything into one self-contained HTML doc
  index.js      barrel

Migrates tech-mobile.js to the kit:
  - drops inline esc/toast/fmtTime/dlbl/STATUS_META/badge helpers
  - api.post('/status', {...}) instead of fetch(H+'/t/'+T+'/status', {...})
  - router.on('#job/:name', handler) instead of hand-rolled route()
  - scanner.open(field, label, cb, ctx) instead of ~60 lines of field-scan logic

Behavior preserved — rendered HTML keeps tabs, detail view, notes editor,
photo upload, per-field Gemini scans, Montreal-TZ date labels, v16 link-label
resolution. Verified live at msg.gigafibre.ca with a real TECH-4 token.

Sets up acceptance.js and payments.js to drop from ~700 → ~300 lines each
in the next commits by consuming the same primitives.
2026-04-22 22:47:19 -04:00

40 lines
1.4 KiB
JavaScript

'use strict'
// ─────────────────────────────────────────────────────────────────────────────
// Barrel export for the magic-link UI kit.
// const ui = require('../ui')
// ui.page({ ... })
// ui.badge('In Progress')
// ui.section('En retard', cards, 'danger')
// ─────────────────────────────────────────────────────────────────────────────
const shell = require('./shell')
const comp = require('./components')
module.exports = {
// shell
page: shell.page,
pageExpired: shell.pageExpired,
pageError: shell.pageError,
html: shell.html,
htmlHeaders: shell.htmlHeaders,
// components
esc: comp.esc,
jsonScript: comp.jsonScript,
STATUS_META: comp.STATUS_META,
statusMeta: comp.statusMeta,
badge: comp.badge,
section: comp.section,
card: comp.card,
panel: comp.panel,
emptyState: comp.emptyState,
placeholder: comp.placeholder,
button: comp.button,
statRow: comp.statRow,
tabBar: comp.tabBar,
fmtTime: comp.fmtTime,
fmtDate: comp.fmtDate,
dateLabelFr: comp.dateLabelFr,
todayFr: comp.todayFr,
montrealDate: comp.montrealDate,
}