{% extends "base.html" %}
{% comment %}
Copyright (C) by BDE ENS Paris-Saclay
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n crispy_forms_tags %}

{% block content %}
<div class="card bg-white mb-3">
  <h3 class="card-header text-center">
    {{ title }} {{ food.name }}
  </h3>
  <div class="card-body">
    <ul>
      {% if QR_code %}
      <li> {{QR_code}} </li>
      {% endif %}
      {% for field, value in fields %}
      <li> {{ field }} : {{ value }}</li>
      {% endfor %}
      {% if meals %}
      <li> {% trans "Contained in" %} :
      {% for meal in meals %}
      <a href="{% url "food:transformedfood_view" pk=meal.pk %}">{{ meal.name }}</a>{% if not forloop.last %},{% endif %}
      {% endfor %}
      </li>
      {% endif %}
      {% if foods %}
      <li> {% trans "Contain" %} :
      {% for food in foods %}
        <a href="{% url "food:food_view" pk=food.pk %}">{{ food.name }}</a>{% if not forloop.last %},{% endif %}
      {% endfor %}
      </li>
      {% endif %}
    </ul>
      {% if update %}
        <a class="btn btn-sm btn-secondary" href="{% url "food:food_update" pk=food.pk %}">
          {% trans "Update" %}
        </a>
      {% endif %}
      {% if add_ingredient %}
        <a class="btn btn-sm btn-primary" href="{% url "food:add_ingredient" pk=food.pk %}">
          {% trans "Add to a meal" %}
        </a>
      {% endif %}
      {% if manage_ingredients %}
        <a class="btn btn-sm btn-secondary" href="{% url "food:manage_ingredients" pk=food.pk %}">
          {% trans "Manage ingredients" %}
        </a>
        {% if false %}
        <a class="btn btn-sm btn-secondary" href="{% url "food:recipe_use" pk=food.pk %}">
          {% trans "Use a recipe" %}
        </a>
        {% endif %}
      {% endif %}
        <a class="btn btn-sm btn-primary" href="{% url "food:food_list" %}">
          {% trans "Return to the food list" %}
        </a>
  </div>
</div>
{% endblock %}