{% extends 'base.html' %}

{% block title %}Reserva de Números{% endblock %}
{% block content %}
<p>Números a escolher: {{ purchase.numbers_left }} de {{ purchase.total_numbers }}</p>
{% if purchase.numbers_left > 0 %}
    <form method="POST">
        <div class="form-group">
            <label>Rifa</label>
            <select name="raffle_id" class="form-control">
                <option value="">[ Escolha uma Rifa ]</option>
                {% for raffle in raffles %}
                <option value="{{ raffle.id }}">{{ raffle.description }}</option>
                {% endfor %}
            </select>
        </div>
        <div class="form-group">
            <label>Seu nome</label>
            <input type="text" name="name" class="form-control" value="{{ buyer_data.name }}">
        </div>
        <div class="form-group">
            <label>Contato</label>
            <input type="text" name="contact" class="form-control" value="{{ buyer_data.contact }}">
        </div>
        <div class="form-group">
            <label>Número para Sorteio</label>
            <input type="number" name="number" class="form-control">
        </div>
        <button type="submit" class="btn btn-primary">Reservar</button>
    </form>
{% endif %}
{% if grouped_tickets %}
    <br>
    <h4>Escolhidos:</h4>
    {% for raffle, tickets in grouped_tickets.items() %}
    <h5>{{ raffle }}</h5>
    <ul>
        {% for ticket in tickets %}
        <li>{{ ticket.chosen_number }}</li>
        {% endfor %}
    </ul>
    {% endfor %}
{% endif %}
{% endblock %}
