- <form method='post' action='{% url 'social_like_book' book.slug %}'>
- {% csrf_token %}
- <button class="l-button l-button--fav">
- <img src="{% static '2022/images/fav.svg' %}" alt="Dodaj do ulubionych">
- </button>
- </form>
+ {% likes_book book as likes %}
+ {% if likes %}
+ <form method='post' action='{% url 'social_unlike_book' book.slug %}'>
+ {% csrf_token %}
+ <button class="l-button l-button--fav">
+ <img src="{% static '2022/images/faved.svg' %}" alt="Usuń z ulubionych">
+ </button>
+ </form>
+ {% else %}
+ <form method='post' action='{% url 'social_like_book' book.slug %}'>
+ {% csrf_token %}
+ <button class="l-button l-button--fav">
+ <img src="{% static '2022/images/fav.svg' %}" alt="Dodaj do ulubionych">
+ </button>
+ </form>
+ {% endif %}