{% extends '__layout__.html' %}
{% block title %}Admin - Generate Invite Keys{% endblock %}
{% block head %}
<link href="/static/css/admin.css" rel="stylesheet"/>
{% endblock %}
{% block content %}
<div id="main">
    <div class="container" style="max-width: 800px;">
        <a href="/admin" class="btn border-primary btn-sm mb-2">Back to Admin Panel</a>
        <h1>Generate Invite Keys</h1>
        {% with messages = get_flashed_messages(with_categories=true) %}
        {% if messages %}
        <div>
        {% for category, message in messages %}
            {% if category == 'error': %}
            <div class="alert border p-2 text-center alert-danger border-danger">
                {{ message }}
            </div>
            {% endif %}
            {% if category == 'success': %}
            <div class="alert border p-2 text-center alert-success border-success">
                {{ message }}
            </div>
            {% endif %}
        {% endfor %}
        </div>
        {% endif %}
        {% endwith %}
        <form method="post">
            <div class="form-floating">
                <input type="number" class="form-control" id="floatingAmount" placeholder="Amount" name="amount" min="1" max="50" required>
                <label for="floatingAmount">Number of Keys (1&ndash;50)</label>
            </div>
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <button class="btn btn-primary mt-2 w-100 btn-sm" type="submit">Generate Keys</button>
        </form>
        {% if keys %}
            <div class="linebreak"></div>
            <h2>Generated Keys</h2>
            <div class="border rounded p-2">
                {% for key in keys %}
                    <span class="m-0">{{ key }}</span>
                    <br>
                {% endfor %}
            </div>
        {% endif %}
    </div>
</div>
{% endblock %}
