// ----------------------------------------------------------------------------- // Forma-Ka — Agrégateur de formations (province de Québec) // Auteur : Simon-Pierre Boucher — contact@spboucher.ai // components/FormationCard.tsx : carte de formation (grille de résultats) // Pas d'image imposée (rare dans le domaine) : monogramme de la source + // type de formation en badge, détails clés (mode, durée, ville, date). // ----------------------------------------------------------------------------- import { Link } from "react-router-dom"; import { Formation, MODE_ICONS, fmtDate, fmtHours, fmtPrice, sourceName } from "../api"; /** Couleur stable dérivée du domaine (pour le bandeau du monogramme). */ const HUES = [14, 36, 88, 152, 196, 226, 262, 318]; function hue(s: string): number { let h = 0; for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) | 0; return HUES[Math.abs(h) % HUES.length]; } export default function FormationCard({ f }: { f: Formation }) { const img = f.images && f.images.length > 0 ? f.images[0] : null; const start = fmtDate(f.start_date); const dur = f.duration || fmtHours(f.duration_hours); const h = hue(f.category || f.source); return (
{img ? ( {f.title} ) : (
{f.category || sourceName(f.source)}
)} {f.training_type && {f.training_type}} {f.is_free && Gratuit}
{f.price != null && f.price > 0 ? ( <>{fmtPrice(f.price, f.price_label)} ) : f.is_free ? ( <>Gratuit ) : ( {f.credits || f.price_label || "Prix non affiché"} )} {f.code && {f.code}}
{f.title}
{f.mode && {MODE_ICONS[f.mode] ?? ""} {f.mode}} {f.mode && dur && } {dur && {dur}} {(f.mode || dur) && f.city && } {f.city && {f.city}}
{sourceName(f.source)} {start && Débute le {start}}
); }