{# # ============================================================================ # ORGANISM: DASHBOARD ACTIVITY # ============================================================================ # # Liste simple d'activités récentes pour le dashboard. # Affiche les dernières activités avec date, tokens et énergie. # # ============================================================================ # COMPOSITION (Atomes utilisés) # ============================================================================ # # - _atoms/icon/icon.html.twig # - _molecules/empty-state/empty-state.html.twig # # ============================================================================ # PARAMÈTRES # ============================================================================ # # | Paramètre | Type | Défaut | Description | # |---------------|---------|------------|------------------------------------| # | activities | array | [] | Liste des activités | # | limit | int | 5 | Nombre d'activités affichées | # | viewMoreHref | string | null | Lien vers historique complet | # | class | string | '' | Classes additionnelles | # # ============================================================================ #} {# @tailwind-safelist (Tailwind JIT: dynamic color classes) bg-primary/8 bg-cohorts/8 bg-warning/8 bg-error/8 bg-success/8 bg-info/8 bg-pink/8 border-primary/12 border-cohorts/12 border-warning/12 border-error/12 border-success/12 border-info/12 border-pink/12 text-primary text-cohorts text-warning text-error text-success text-info text-pink #} {# ============================================================================ CONFIGURATION DES VALEURS PAR DÉFAUT ============================================================================ #} {% set activities = activities ?? [] %} {% set limit = limit ?? 5 %} {% set viewMoreHref = viewMoreHref ?? null %} {% set class = class ?? '' %} {# ============================================================================ RENDU HTML ============================================================================ #}
{% if activities|length > 0 %}
{% for activity in activities|slice(0, limit) %} {% set toolCode = activity.tool is defined and activity.tool ? activity.tool.code : (activity.type ?? activity.activityType ?? 'moodia') %} {% set actTitle = activity.title ?? activity.description ?? 'Activité' %} {% set actTokens = activity.tokens ?? activity.tokensUsed ?? 0 %} {% set actEnergy = activity.energy ?? activity.energyConsumedWh ?? 0 %} {% set actDate = activity.date ?? activity.createdAt %} {# Couleur par outil (via global tool_colors + tool_color_details depuis la DB) #} {% set atc = tool_colors[toolCode|lower] ?? 'primary' %} {% set atHex = (tool_color_details[toolCode|lower] ?? {}).primary ?? null %} {% set atHexSecondary = (tool_color_details[toolCode|lower] ?? {}).secondary ?? null %}
{# Icône outil #}
{% include '_atoms/icon/icon.html.twig' with { name: 'bubul-' ~ toolCode|lower, size: 'md', color: atc, colorPrimary: atHex, colorSecondary: atHexSecondary } only %}
{# Titre #}
{{ actTitle }}
{# Date + heure #}
{{ actDate|format_datetime('short', 'none', locale='fr') }}
{{ actDate|date('H:i') }}
{# Tokens #}
{% include '_atoms/icon/icon.html.twig' with { name: 'token', size: 'xs', color: 'primary' } only %} {{ actTokens|format_number(locale='fr') }}
{# Énergie (Wh) en jaune/warning #}
{% include '_atoms/icon/icon.html.twig' with { name: 'bolt', size: 'xs', color: 'warning' } only %} {{ actEnergy|number_format(2, ',', ' ') }} Wh
{% endfor %}
{% else %}
{% include '_molecules/empty-state/empty-state.html.twig' with { title: 'Aucune activité récente', description: 'Vos activités apparaîtront ici.', icon: 'clock', size: 'sm' } only %}
{% endif %}