forked from yvv/decision
- Aujourd'hui (Fil 13 sections + capture sticky) + Le chemin (tunnel 2 gestes, Q0 inline, 3 chips, dérogation asymétrique, alternatives réglage/consignation) - Registre + fiche décision (timeline, périmètre premier/second lieu auditable, affluence non-ignorable, S'instruire condensé, éléments + cartographie de clôture, épreuve du réel, Remettre en question, PV A4, gravure) - Salle de vote 5 modalités (consentement, nuancé+histogramme, binaire hérité avec jauge inertielle, Réglage collectif complet — faisceau, médiane basse, Pour moi, Explorer, cristallisation-geste —, élection à départage humain) - Textes (Pacte en clair, document vivant, diff, vue projetée, Atelier des formules porté du v1 sur le moteur unique) + Mandats (faits comptés, feux de la rampe, wizard 3 étapes) + Observatoire (consigner→observer→protocoliser) - Onboarding 7 gabarits + Données locales (export/import, attributs, atelier) - voting→framing gardé (Reformuler d'un réglage figé non cristallisé) - Pages v1 supprimées (login, documents, mandates, protocols, sanctuary, tools, decisions/new) — 342 tests verts, build zéro erreur Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
99 lines
2.8 KiB
TypeScript
99 lines
2.8 KiB
TypeScript
/**
|
|
* Shared UI helpers of the decisions screens (registry + fiche) — v2.
|
|
* Labels that complement app/lexicon.ts locally (short weight forms, chain
|
|
* kinds, circle-kind iconography) live here; the lexicon stays the single
|
|
* source for everything it already names.
|
|
*/
|
|
|
|
import type {
|
|
ChainKind,
|
|
CircleKind,
|
|
Decision,
|
|
DecisionStatus,
|
|
VoteSession,
|
|
Weight,
|
|
} from '~/types/domain'
|
|
import { FROZEN_LABEL, STATUS_LABELS } from '~/lexicon'
|
|
|
|
/** Short weight forms — registry pills and card metadata. */
|
|
export const WEIGHT_SHORT: Record<Weight, string> = {
|
|
light: 'léger',
|
|
binding: 'engageant',
|
|
structural: 'structurant',
|
|
}
|
|
|
|
/** Chain kinds in plain French (fiche chain block). */
|
|
export const CHAIN_LABELS: Record<ChainKind, string> = {
|
|
ratification: 'ratification',
|
|
revision: 'révision',
|
|
revocation: 'révocation',
|
|
element: 'élément',
|
|
}
|
|
|
|
/** Circle kind iconography — lieu / thème / équipe (never a right). */
|
|
export const KIND_ICONS: Record<CircleKind, string> = {
|
|
place: 'i-lucide-map-pin',
|
|
theme: 'i-lucide-tag',
|
|
team: 'i-lucide-users-round',
|
|
}
|
|
export const KIND_LABELS: Record<CircleKind, string> = {
|
|
place: 'Lieux',
|
|
theme: 'Thèmes',
|
|
team: 'Équipes',
|
|
}
|
|
|
|
/** Advice positions in plain French. */
|
|
export const ADVICE_LABELS = {
|
|
favorable: 'favorable',
|
|
reserved: 'réservé',
|
|
unfavorable: 'défavorable',
|
|
} as const
|
|
|
|
/** Display status: 'frozen' overlays 'voting' when the session is frozen. */
|
|
export type DisplayStatus = DecisionStatus | 'frozen'
|
|
|
|
export function displayStatus(decision: Decision, session?: VoteSession): DisplayStatus {
|
|
if (decision.status === 'voting' && session?.status === 'frozen') return 'frozen'
|
|
return decision.status
|
|
}
|
|
|
|
export function displayStatusLabel(status: DisplayStatus): string {
|
|
return status === 'frozen' ? FROZEN_LABEL : STATUS_LABELS[status as DecisionStatus]
|
|
}
|
|
|
|
/** Timeline color mapping — the ONE state→color mapping (moods.css tokens). */
|
|
export const STATUS_TOKEN: Record<DisplayStatus, string> = {
|
|
draft: 'prepa',
|
|
advice: 'fenetre',
|
|
objection: 'fenetre',
|
|
framing: 'prepa',
|
|
voting: 'vote',
|
|
frozen: 'fige',
|
|
adopted: 'vigueur',
|
|
rejected: 'clos',
|
|
revoked: 'revoque',
|
|
transmitted: 'fige',
|
|
closed: 'clos',
|
|
}
|
|
|
|
/** Case/accent-insensitive folding — same logic as useSearch. */
|
|
export function fold(text: string): string {
|
|
return text.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase()
|
|
}
|
|
|
|
/** Short French date (« 12 août 2026 »). */
|
|
export function dateFr(iso?: string): string {
|
|
if (!iso) return ''
|
|
return new Date(iso).toLocaleDateString('fr-FR', {
|
|
day: 'numeric', month: 'short', year: 'numeric',
|
|
})
|
|
}
|
|
|
|
/** French date + time for timeline milestones. */
|
|
export function dateTimeFr(iso?: string): string {
|
|
if (!iso) return ''
|
|
return new Date(iso).toLocaleString('fr-FR', {
|
|
day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit',
|
|
})
|
|
}
|