{% extends "CHRISTMAS/default.html" %}

{% block title %}
<title>Badge Grant</title>
{% endblock %}

{% block pagetype %}message{% endblock %}

{% block content %}
<div class="col-span-full my-2 px-2.5 md:px-0">

		{% if error %}
		<div class="alert alert-danger alert-dismissible fade show my-3" role="alert">
			<i class="fas fa-exclamation-circle my-auto"></i>
			<span>
				{{error}}
			</span>
			<button type="button" class="close" data-bs-dismiss="alert" aria-label="Close">
				<span aria-hidden="true"><i class="far fa-times"></i></span>
			</button>
		</div>
		{% endif %}
		{% if msg %}
		<div class="alert alert-success alert-dismissible fade show my-3" role="alert">
			<i class="fas fa-check-circle my-auto" aria-hidden="true"></i>
			<span>
				{{msg}}
			</span>
			<button type="button" class="close" data-bs-dismiss="alert" aria-label="Close">
				<span aria-hidden="true"><i class="far fa-times"></i></span>
			</button>
		</div>
		{% endif %}

<pre></pre>
<pre></pre>
<h5>Badge Grant</h5>

<form action="/admin/badge_grant" method="post">
<input type="hidden" name="formkey" value="{{v.formkey}}">


<label for="input-username" class="label">Username</label>
<input id="input-username" class="form-input mb-4" type="text" name="username" required placeholder="Enter a username">

<table class="w-full table table-striped">
<thead class="bg-primary text-white">
		<tr>
			<th scope="col">Select</th>
			<th scope="col">Image</th>
			<th scope="col">Name</th>
			<th scope="col">Default Description</th>
		</tr>
	</thead>
	<tbody>
{% for k, v in badge_types.items() %}
<tr>
	<td><input type="radio" id="badge-{{k}}" name="badge_id" value="{{k}}"></td>
	<td>
		<label for="badge-{{k}}">
			<img loading="lazy" src="/assets/CHRISTMAS/images/badges/{{v['name']}}.webp?a=1" class="object-contain w-16 h-16 p-2" alt="{{v['name']}} badge"/>
		</label>
	</td>
	<td>{{v['name']}}</td>
	<td>{{v['description']}}</td>
</tr>
{% endfor %}
</table>

<label for="input-url" class="label">URL</label>
<input id="input-url" class="form-input mb-2" type="text" name="url" placeholder="Optional">

<label for="input-description" class="label">Custom description</label>
<input id="input-description" class="form-input" type="text" name="description" placeholder="Leave blank for badge default">

<input class="btn btn-green mt-2" type="submit">

</form>

</div>

<style>
	@media (max-width: 767.98px) {
		table {
			display: inline-block;
			overflow: auto;
		}
	}
</style>

{% endblock %}
