From 1017cab6497569ceb35b36b3aa664888bc7e98b1 Mon Sep 17 00:00:00 2001 From: louispaulb Date: Sat, 4 Jul 2026 18:31:18 -0400 Subject: [PATCH] =?UTF-8?q?refactor(ui):=20T1=20audit=20=E2=80=94=20d?= =?UTF-8?q?=C3=A9dup=20formatters=20=E2=86=92=20useFormatters=20(0=20chang?= =?UTF-8?q?ement=20d'affichage)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3 formateurs canoniques ajoutés (initials [2 premiers mots, '?'], fmtClock [«8:30»→«8h30»], formatDateLong) + remplacement des copies locales IDENTIQUES (vérifiées à l'impl) : - initials : PlanificationPage + RouteMap - fmtTime → fmtClock : JobCard + TechTasksPage - formatDate → formatDateLong : ReportRevenueExplorer + ReportInternetCher Les VRAIES variantes laissées telles quelles (staffInitials 1er+dernier ; fmtDate string ; fmtDur RendezVous ; fmtMoney multi-devise ; formatDate Settings/ConversationPanel/Gifts date+heure). Build vert, leak 0. Première tranche de l'audit workflow 26 pages. Co-Authored-By: Claude Opus 4.8 --- apps/ops/src/components/shared/RouteMap.vue | 3 ++- apps/ops/src/composables/useFormatters.js | 13 +++++++++++++ apps/ops/src/modules/tech/components/JobCard.vue | 7 ++----- apps/ops/src/modules/tech/pages/TechTasksPage.vue | 7 ++----- apps/ops/src/pages/PlanificationPage.vue | 4 ++-- apps/ops/src/pages/ReportInternetCherPage.vue | 6 ++---- apps/ops/src/pages/ReportRevenueExplorerPage.vue | 6 ++---- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/apps/ops/src/components/shared/RouteMap.vue b/apps/ops/src/components/shared/RouteMap.vue index aa6db71..0e22235 100644 --- a/apps/ops/src/components/shared/RouteMap.vue +++ b/apps/ops/src/components/shared/RouteMap.vue @@ -12,6 +12,7 @@ import { watch, onMounted, onBeforeUnmount } from 'vue' import { MAPBOX_TOKEN } from 'src/config/erpnext' import * as roster from 'src/api/roster' +import { initials } from 'src/composables/useFormatters' // initiales (source unique, ex-locale dé-dupliquée) const props = defineProps({ routes: { type: Array, default: () => [] }, @@ -72,7 +73,7 @@ async function realLine (r) { // géométrie routière réelle d'une tournée (O function clearMarkers () { for (const m of stopMk) m.mk.remove(); for (const m of homeMk) m.mk.remove(); stopMk = []; homeMk = [] } // ── Positions GPS LIVE des techs (marqueur distinct des arrêts : pastille ronde à initiales + halo pulsé) ── -function initials (n) { return String(n || '?').trim().split(/\s+/).map(w => w[0]).filter(Boolean).slice(0, 2).join('').toUpperCase() } +// initials → composables/useFormatters (source unique) function clearLive () { for (const m of liveMk) m.mk.remove(); liveMk = [] } function clearPins () { for (const m of pinMk) m.mk.remove(); pinMk = [] } function renderLive (list) { diff --git a/apps/ops/src/composables/useFormatters.js b/apps/ops/src/composables/useFormatters.js index 516c4fd..7b16788 100644 --- a/apps/ops/src/composables/useFormatters.js +++ b/apps/ops/src/composables/useFormatters.js @@ -197,3 +197,16 @@ export function formatDateTimeShort (d) { if (isNaN(dt.getTime())) return '' return dt.toLocaleString('fr-CA', { dateStyle: 'short', timeStyle: 'short' }) } + +// ── Formateurs canoniques dé-dupliqués (audit T1 2026-07-04) — remplacent des copies locales IDENTIQUES ── +// Initiales = 2 PREMIERS mots (« Jean Bourdon » → « JB »), '?' si vide. ⚠ DIFFÉRENT de staffInitials (1er + DERNIER mot). +// Version « 2 premiers » = celle de la grille Planif + carte des tournées. +export function initials (name) { + return String(name || '').split(/\s+/).filter(Boolean).map(w => w[0]).slice(0, 2).join('').toUpperCase() || '?' +} +// Heure d'horloge : chaîne « 8:30 » → « 8h30 ». ⚠ DIFFÉRENT de fmtTimeHHhMM (qui prend un Date). +export function fmtClock (t) { if (!t) return ''; const [h, m] = String(t).split(':'); return `${h}h${m}` } +// Date « longue » : « 3 juillet 2026 » ; '' si absent. +export function formatDateLong (d) { + return d ? new Date(d).toLocaleDateString('fr-CA', { day: 'numeric', month: 'long', year: 'numeric' }) : '' +} diff --git a/apps/ops/src/modules/tech/components/JobCard.vue b/apps/ops/src/modules/tech/components/JobCard.vue index d052ca7..3dc99c3 100644 --- a/apps/ops/src/modules/tech/components/JobCard.vue +++ b/apps/ops/src/modules/tech/components/JobCard.vue @@ -36,6 +36,7 @@