{% extends 'base.html.twig' %} {% block title %}{{ meal.name }} — Repas{% endblock %} {% block body_class %}bg-stone-100 text-stone-900 dark:bg-stone-950 dark:text-stone-100{% endblock %} {% block body %}
{% include 'ui/page_nav.html.twig' with { variant: 'surface', back_href: path('front.pantry.meal.index'), eyebrow: 'Repas', title: meal.name, subtitle: meal.eatenAt|date('d/m/Y à H:i') ~ ' · par ' ~ meal.createdBy.displayName, } only %} {# ── Compute macros from consumptions ── #} {% set consumptions = meal.consumptions %} {% set totalCal = meal.totalCalories %} {% set totalProteins = 0.0 %} {% set totalCarbs = 0.0 %} {% set totalFat = 0.0 %} {% set hasMacros = false %} {% for c in consumptions %} {% set n = c.item.nutriments %} {% if n %} {% if n.proteins is defined and n.proteins is not null %} {% set totalProteins = totalProteins + (n.proteins * c.quantity / 100) %} {% set hasMacros = true %} {% endif %} {% if n.carbohydrates is defined and n.carbohydrates is not null %} {% set totalCarbs = totalCarbs + (n.carbohydrates * c.quantity / 100) %} {% set hasMacros = true %} {% endif %} {% if n.fat is defined and n.fat is not null %} {% set totalFat = totalFat + (n.fat * c.quantity / 100) %} {% set hasMacros = true %} {% endif %} {% endif %} {% endfor %} {% set macroCalories = (totalProteins * 4) + (totalCarbs * 4) + (totalFat * 9) %} {% if macroCalories > 0 %} {% set protPct = ((totalProteins * 4) / macroCalories * 100)|round %} {% set carbPct = ((totalCarbs * 4) / macroCalories * 100)|round %} {% set fatPct = 100 - protPct - carbPct %} {% else %} {% set protPct = 0 %} {% set carbPct = 0 %} {% set fatPct = 0 %} {% endif %} {# ── Description ── #} {% if meal.description %}

"{{ meal.description }}"

{% endif %} {# ── Nutrition hero card ── #} {% if totalCal is not null or hasMacros %}
{# Calorie banner #} {% if totalCal is not null %}

{{ totalCal|number_format(0, ',', ' ') }} kcal

{{ consumptions|length }} aliment{{ consumptions|length > 1 ? 's' : '' }} · {{ meal.eatenAt|date('d/m/Y') }}

{% endif %} {# Macro donuts — same style as pantry item show #} {% if hasMacros %}
{{ protPct }}%

Protéines

{{ totalProteins|round(1) }}g

{{ carbPct }}%

Glucides

{{ totalCarbs|round(1) }}g

{{ fatPct }}%

Lipides

{{ totalFat|round(1) }}g

{% endif %} {% if totalCal is not null %}

* Estimation basée sur les valeurs nutritionnelles pour 100 g × quantités consommées.

{% endif %}
{% endif %} {# ── Aliments consommés ── #}

Aliments consommés

{% if consumptions is empty %}

Aucun aliment enregistré.

{% else %} {% endif %}
{% endblock %}