{% extends "admin/shell.html" %}

{% block title %}Invite Codes{% endblock %}

{% block head %}
{% endblock %}

{% block page %}
<h1>invite code page</h1>
<form action="/admin/invitecode" method="post">
    <h3>invite code generator!</h3>
    <h4>you will be inserting codes as {{ username }}</h4>
    <label for="code">invite code value</label>
    <input type="text" name="code" id="code" autofocus>
    <label for="comment">comment (usu. put who you're giving it to here)</label>
    <input type="text" name="comment" id="comment">
    <button type="submit">gemerate!</button>
</form>
<h1>active invite codes</h1>
<table id="active-codes">
    <tr><th>code</th><th>issuer</th><th>root issuer</th><th>issued on</th><th>comment</th></tr>
    {% for code in active_codes %}
    <tr><td>{{ code.code }}</td><td>{{ code.creator }}</td><td>{{ code.root_creator }}</td><td>{{ code.created_at }}</td><td>{{ code.comment }}</td></tr>
    {% endfor %}
</table>
<h1>used invite codes (fixme: separate into pages to prevent long load times in the future)</h1>
<table id="used-codes">
    <tr><th>code</th><th>issuer</th><th>root issuer</th><th>issued on</th><th>used on</th><th>used by</th><th>comment</th></tr>
    {% for code in used_codes %}
    <tr><td>{{ code.code }}</td><td>{{ code.creator }}</td><td>{{ code.root_creator }}</td><td>{{ code.created_at }}</td><td>{{ code.used_at.as_ref().unwrap() }}</td><td>{{ code.used_by.as_ref().unwrap() }}</td><td>{{ code.comment }}</td></tr>
    {% endfor %}
</table>
{% endblock %}
