{%
	set colors = {
	'fa-user-slash': 'text-red-600',
	'fa-feather-alt': 'text-gray-500',
	'fa-eye-evil': 'text-red-600'
}
%}

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

{% block pagetitle %}Moderation Log{% endblock %}

{% block subHeader %}
<div class="relative max-w-screen-2xl mx-auto px-4 py-4 grid grid-cols-12 rounded-t">
	<div class="absolute top-0 left-0 w-full h-full bg-gradient-to-t from-gray-300 to-gray-200 dark:bg-none dark:bg-gray-800 rounded-t sub-header-shadow dark:border-b dark:border-gray-700 sub-header"></div>
	<div class="relative col-span-full flex items-center">
		<div>
			<h1 class="font-bold text-xl font-heading leading-normal mb-0">
				Moderation Log
			</h1>
			<ul class="flex space-x-2 text-xs text-gray-500 dark:text-gray-400 leading-normal mb-0">
				{% if v and v.admin_level > 2 %}
				<li>
					<a href="/admin" class="text-gray-500 hover:underline">Admin Dashboard</a>
				</li>
				<li>
					<i class="fas fa-arrow-alt-right text-shadow fa-fw fa-sm"></i>
				</li>
				{% endif %}
				<li>
					<a href="#" class="text-gray-700 dark:text-gray-500 hover:underline">Moderation Log</a>
				</li>
			</ul>
		</div>
		<div class="ml-auto flex space-x-2">
			<!-- Filter by mod -->
			<div class="dropdown">
				<button class="inline-flex items-center px-4 py-2 bg-gradient-to-t from-gray-200 to-gray-100 focus:from-gray-100 focus:to-gray-200 border border-gray-300 rounded-md text-shadow shadow-inset-t-white-10 text-sm font-bold text-gray-700 focus:text-gray-900 focus:shadow-inner focus:outline-none dropdown-toggle" type="button" id="dropdownLogSortsButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					{% if admin %}
					<img src="/@{{admin}}/pic" alt="{{ admin }}avatar" class="flex-shrink-0 w-4 h-4 object-cover mr-2">{{ admin }}
					{% else %}
					<img src="/assets/images/emojis/marseyjanny.webp" alt="default mod avatar" class="flex-shrink-0 w-4 h-4 object-cover mr-4">All
					{% endif %}
				</button>
				<ul class="dropdown-menu w-56 bg-gray-900 rounded-md shadow-lg" aria-labelledby="dropdownLogSortsButton" x-placement="bottom-start">
					<li>
						<a class="dropdown-item dropdown-item-primary" href="/log{% if type %}?kind={{type}}{% endif %}">
							<img src="/assets/images/emojis/marseyjanny.webp" alt="default mod avatar" class="flex-shrink-0 w-4 h-4 object-cover mr-4">All
						</a>
					</li>
					{% for a in admins %}
					<li>
						<a class="dropdown-item dropdown-item-primary" href="?admin={{a}}{% if type %}&kind={{type}}{% endif %}">
							<img src="/@{{a}}/pic" alt="{{ a }} avatar" class="flex-shrink-0 w-4 h-4 object-cover mr-4">{{ a }}
						</a>
					</li>
					{% endfor %}
				</ul>
			</div>
			<!-- Filter by action -->
			<div class="dropdown">
				<button class="inline-flex items-center px-4 py-2 bg-gradient-to-t from-gray-200 to-gray-100 focus:from-gray-100 focus:to-gray-200 border border-gray-300 rounded-md text-shadow shadow-inset-t-white-10 text-sm font-bold text-gray-700 focus:text-gray-900 focus:shadow-inner focus:outline-none dropdown-toggle" type="button" id="dropdownLogActionSortsButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
					{% if type %}
					<i class="fas {{types[type]['icon']}} fa-fw mr-2"></i>{{type}}
					{% else %}
					<i class="fas fa-broom fa-fw mr-2"></i>All
					{% endif %}
				</button>
				<ul class="dropdown-menu w-56 bg-gray-900 rounded-md shadow-lg" aria-labelledby="dropdownLogActionSortsButton" x-placement="bottom-start">
					<li>
						<a class="dropdown-item dropdown-item-primary" href="/log{% if admin %}?admin={{admin}}{% endif %}">
							<i class="fas fa-broom fa-fw mr-2"></i>All
						</a>
					</li>
					{% for t, v in types.items() %}
					<li>
						<a class="dropdown-item dropdown-item-primary" href="?{% if admin %}admin={{admin}}&{% endif %}kind={{t}}">
							<i class="fas {{v['icon']}} fa-fw mr-2"></i>{{t}}
						</a>
					</li>
					{% endfor %}
				</ul>
			</div>
		</div>
	</div>
</div>
{% endblock %}


{% block content %}

<div class="col-span-full my-4">

	{% if actions %}
	<ul class="flex flex-col divide-y divide-gray-300 dark:divide-gray-700 space-y-2.5 mb-0 list-none">
		{% for ma in actions %}
		<li id="action-{{ma.id}}" class="relative flex pt-2.5 first:pt-0">
			<div class="w-6 h-6 flex justify-center items-center flex-shrink-0">
				<i class="far {{ ma.icon }} {{ colors[ma.icon] }} fa-fw"></i>
			</div>
			<div class="pl-2 text-gray-500 dark:text-gray-400 text-sm">
				<div>
					<a href="{{ma.user.url}}" class="font-font text-black dark:text-gray-200 hover:text-primary dark:hover:text-primary" target="_self">@{{ma.user.username}}
					</a>
					<span>{{ma.string | safe}}</span>
				</div>
				<div class="text-gray-400 dark:text-gray-500 text-xs">
					<span>{{ma.age_string}}</span>
				</div>
			</div>
		</li>
		{% endfor %}
	</ul>
	{% else %}
	<div class="flex flex-col items-center justify-center py-24 md:py-48">
		<img loading="lazy" src="https://c.tenor.com/NhDy-AkelhQAAAAM/marsey-drama.gif" class="w-20 h-20 mb-4 rounded-md object-cover">
		<h2 class="text-xl font-bold leading-normal font-heading">No logs</h2>
		<p class="text-gray-500 text-sm">
			When mods perform actions, it will show up here.
		</p>
		{% if v and v.admin_level > 2 %}
		<a href="/admin" class="mt-3 btn btn-gray">
			Go to admin dashboard
		</a>
		{% else %}
		<a href="/" class="mt-3 btn btn-gray">
			Go to homepage
		</a>
		{% endif %}
	</div>
	{% endif %}

	<nav aria-label="Page navigation" class="mb-5">
		<ul class="pagination pagination-sm mb-0">
			{% if page>1 %}
			<li class="page-item">
				<small><a class="page-link" href="/log?page={{page+1}}{% if admin %}&admin={{admin}}{% endif %}{% if type %}&kind={{type}}{% endif %}" tabindex="-1">Prev</a></small>
			</li>
			{% else %}
			<li class="page-item disabled"><span class="page-link">Prev</span></li>
			{% endif %}
			{% if next_exists %}
			<li class="page-item">
				<small><a class="page-link" href="/log?page={{page+1}}{% if admin %}&admin={{admin}}{% endif %}{% if type %}&kind={{type}}{% endif %}">Next</a></small>
			</li>
			{% else %}
			<li class="page-item disabled"><span class="page-link">Next</span></li>
			{% endif %}
		</ul>
	</nav>

</div>

{% endblock %}