{% extends 'base.html.twig' %} {% block title %}{{ isViewingOtherUser ? 'Activités de ' ~ viewedUser.fullName : 'Historique d\'activité' }} - Bubul{% endblock %} {% block meta_description %}Consultez l'historique complet de vos activités sur Bubul.{% endblock %} {# Macro pour construire les URLs de filtre en conservant les params existants #} {% macro filter_url(tool, sort, dir, page, uuid) %} {% set params = {} %} {% if uuid is not null %}{% set params = params|merge({uuid: uuid}) %}{% endif %} {% if tool is not null %}{% set params = params|merge({tool: tool}) %}{% endif %} {% if sort is not null and sort != 'date' %}{% set params = params|merge({sort: sort}) %}{% endif %} {% if dir is not null and dir != 'desc' %}{% set params = params|merge({dir: dir}) %}{% endif %} {% if page is not null and page > 1 %}{% set params = params|merge({page: page}) %}{% endif %} {{ path('app_activity_history', params) }} {% endmacro %} {% set targetUuid = isViewingOtherUser ? viewedUser.uuid : null %} {# @tailwind-safelist (classes dynamiques construites à partir de tool_colors) bg-primary/10 bg-cohorts/10 bg-warning/10 bg-pink/10 bg-success/10 bg-info/10 text-primary text-cohorts text-warning text-pink text-success text-info #} {# Couleurs dérivées du global tool_colors (source : Tool entity en base) #} {% set toolBgColors = {} %} {% for code, token in tool_colors %} {% set toolBgColors = toolBgColors|merge({(code): 'bg-' ~ token ~ '/10 text-' ~ token}) %} {% endfor %} {% block body %}
{# ==================================================================== EN-TÊTE DE PAGE ==================================================================== #}
{# Lien retour #} {% if isViewingOtherUser %} {% include '_atoms/icon/icon.html.twig' with { name: 'chevron-left', size: 'sm', color: 'current' } only %} Retour à la fiche utilisateur {% else %} {% include '_atoms/icon/icon.html.twig' with { name: 'chevron-left', size: 'sm', color: 'current' } only %} Retour au dashboard {% endif %}
{% include '_atoms/icon/icon.html.twig' with { name: 'clock', size: 'xl', color: 'primary' } only %}

{{ isViewingOtherUser ? 'Activités de ' ~ viewedUser.fullName : 'Historique d\'activité' }}

{{ isViewingOtherUser ? 'Utilisations de ' ~ viewedUser.fullName ~ ' sur les 30 derniers jours' : '30 derniers jours d\'utilisation des outils Bubul' }}

{# Badge nombre total #}
{{ totalActivities }} activité{{ totalActivities > 1 ? 's' : '' }}
{# ==================================================================== FILTRES : Outils + Tri ==================================================================== #}
{# Filtres outils (dynamique depuis la base de données) #} {% set toolFiltersList = [ { id: 'all', label: 'Tous', href: (_self.filter_url(null, currentSort, currentDir, null, targetUuid))|trim } ] %} {% for tool in tools %} {% set toolFiltersList = toolFiltersList|merge([{ id: tool.code, label: tool.name, href: (_self.filter_url(tool.code, currentSort, currentDir, null, targetUuid))|trim }]) %} {% endfor %} {% include '_molecules/filter-tabs/filter-tabs.html.twig' with { filters: toolFiltersList, active: currentTool ?? 'all', size: 'md', name: 'tool' } only %} {# Tri (molecule filter-tabs Moodia) #} {% set nextDirDate = (currentSort == 'date') ? (currentDir == 'desc' ? 'asc' : 'desc') : 'desc' %} {% set nextDirTokens = (currentSort == 'tokens') ? (currentDir == 'desc' ? 'asc' : 'desc') : 'desc' %} {% set nextDirEnergy = (currentSort == 'energy') ? (currentDir == 'desc' ? 'asc' : 'desc') : 'desc' %} {% set sortFiltersList = [ { id: 'date', label: 'Date ' ~ (currentSort == 'date' and currentDir == 'asc' ? '↑' : '↓'), href: (_self.filter_url(currentTool, 'date', nextDirDate, null, targetUuid))|trim }, { id: 'tokens', label: 'Tokens ' ~ (currentSort == 'tokens' and currentDir == 'asc' ? '↑' : '↓'), href: (_self.filter_url(currentTool, 'tokens', nextDirTokens, null, targetUuid))|trim }, { id: 'energy', label: 'Énergie ' ~ (currentSort == 'energy' and currentDir == 'asc' ? '↑' : '↓'), href: (_self.filter_url(currentTool, 'energy', nextDirEnergy, null, targetUuid))|trim } ] %} {% include '_molecules/filter-tabs/filter-tabs.html.twig' with { filters: sortFiltersList, active: currentSort, size: 'md', name: 'sort' } only %}
{# ==================================================================== GRAPHIQUE DE CONSOMMATION ==================================================================== #}

Consommation

J-30
{{ currentSort == 'energy' ? 'Énergie (Wh)' : 'Tokens' }}
{# ==================================================================== LISTE DES ACTIVITÉS ==================================================================== #} {% include '_molecules/section-divider/section-divider.html.twig' with { title: 'Détail des activités', icon: 'clock', iconColor: 'primary' } only %}
{% if activities|length > 0 %}
{% for activity in activities %} {# Résoudre le type d'outil #} {% if activity.tool is defined and activity.tool %} {% set toolCode = activity.tool.code %} {% set toolName = activity.tool.name %} {% elseif activity.type is defined %} {% set toolCode = activity.type|lower %} {% set toolName = toolCode|capitalize %} {% else %} {% set toolCode = 'moodia' %} {% set toolName = 'Moodia' %} {% endif %} {% set tokensValue = activity.tokens is defined ? activity.tokens : (activity.tokensUsed is defined ? activity.tokensUsed : 0) %} {% set energyValue = activity.energy is defined ? activity.energy : (activity.energyConsumedWh is defined ? activity.energyConsumedWh : 0) %} {% set activityDate = activity.date is defined ? activity.date : activity.createdAt %} {% set activityTitle = activity.title is defined ? activity.title : (activity.description is defined ? activity.description : 'Activité') %} {% set aHex = (tool_color_details[toolCode] ?? {}).primary ?? null %} {% set aHexSecondary = (tool_color_details[toolCode] ?? {}).secondary ?? null %}
{# Icône outil #}
{% include '_atoms/icon/icon.html.twig' with { name: 'bubul-' ~ toolCode, size: 'md', color: tool_colors[toolCode]|default('gray'), colorPrimary: aHex, colorSecondary: aHexSecondary } only %}
{# Contenu #}

{{ activityTitle }}

{# Tokens (primary = bleu) #} {% include '_atoms/icon/icon.html.twig' with { name: 'token', size: 'xs', color: 'primary' } only %} {{ tokensValue|number_format(0, ',', ' ') }} {# Énergie (warning = orange) #} {% include '_atoms/icon/icon.html.twig' with { name: 'bolt', size: 'xs', color: 'warning' } only %} {{ energyValue|number_format(4, ',', ' ') }} Wh
{# Date #}
{% endfor %}
{% else %} {# État vide #}
{% include '_atoms/icon/icon.html.twig' with { name: 'clock', size: 'xl', color: 'gray' } only %}

Aucune activité trouvée

{% if currentTool is not null %} Aucune activité pour cet outil. Voir toutes les activités {% elseif isViewingOtherUser %} Cet utilisateur n'a pas encore d'activités. {% else %} Vos activités apparaîtront ici une fois que vous aurez utilisé les outils. {% endif %}

{% endif %}
{# ==================================================================== PAGINATION (molecule Moodia) ==================================================================== #}
{% include '_molecules/pagination/pagination.html.twig' with { currentPage: currentPage, totalPages: totalPages, baseUrl: (_self.filter_url(currentTool, currentSort, currentDir, null, targetUuid))|trim, variant: 'moodia' } only %}
{% endblock %}