{% extends "layouts/base.html" %}
{% load crispy_forms_tags %}
{% load i18n %}
{% load month_name %}
{% load static %}

{% block title %}{% translate 'Monthly Overview' %} :: {{ month|month_name }}/{{ year }}{% endblock %}

{% block body_hyperscript %}
  on keyup[code is 'ArrowLeft' and target.nodeName is 'BODY'] from body trigger 'previous_month' end
  on keyup[code is 'ArrowRight' and target.nodeName is 'BODY'] from body trigger 'next_month' end
{% endblock %}

{% block content %}
  <div class="container">
    <div class="flex flex-wrap mb-4 gap-x-xl-4 gap-y-3">
      {#    Date picker#}
      <div class="w-full xl:w-4/12 flex-row items-center flex">
        <a role="button"
           hx-boost="true"
           class="btn btn-ghost"
           hx-trigger="click, previous_month from:window"
           href="{% url 'calendar' month=previous_month year=previous_year %}">
          <i class="fa-solid fa-chevron-left"></i>
        </a>
        <div class="text-2xl font-bold btn btn-ghost flex-1 text-center whitespace-normal flex-wrap h-auto min-w-0 1flex flex-"
             hx-get="{% url 'month_year_picker' %}"
             hx-target="#generic-offcanvas-left"
             hx-trigger="click, date_picker from:window"
             hx-vals='{"month": {{ month }}, "year": {{ year }}, "for": "calendar", "field": "date"}' role="button">
          {{ month|month_name }} {{ year }}
        </div>
        <a role="button"
           hx-boost="true"
           class="btn btn-ghost"
           hx-trigger="click, next_month from:window"
           href="{% url 'calendar' month=next_month year=next_year %}">
          <i class="fa-solid fa-chevron-right"></i>
        </a>
      </div>
    </div>
    <div class="flex flex-wrap">
      <div class="show-loading w-full" hx-get="{% url 'calendar_list' month=month year=year %}"
           hx-trigger="load, updated from:window, selective_update from:window, every 10m"></div>
    </div>
  </div>
  <c-ui.transactions_fab></c-ui.transactions_fab>
{% endblock %}
