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

{% block fixedMobileBarJS %}{% endblock %}

{% block pagetype %}{% 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">
					Inbox
				</h1>
				<ul class="text-xs flex items-center space-x-3 leading-normal mb-0">
					<li>
						<a class="{{ 'font-bold text-primary' if not '=true' in request.full_path else 'text-gray-500' }}" href="/notifications">
							All
						</a>
					</li>
					<li>
						<a class="{{ 'font-bold text-primary' if '/notifications?posts=true' in request.full_path else 'text-gray-500' }}" href="/notifications?posts=true">
							Posts
							{% if v.post_notifications_count %}
							<span class="text-gray-600">({{v.post_notifications_count}})</span>
							{% endif %}
						</a>
					</li>
					<li>
						<a class="{{ 'font-bold text-primary' if '/notifications?messages=true' in request.full_path else 'text-gray-500' }}" href="/notifications?messages=true">
							Messages
						</a>
					</li>
					{% if v.admin_level > 1 %}
					<li>
						<a class="{{ 'font-bold text-primary' if '/notifications?modmail=true' in request.full_path else 'text-gray-500' }}" href="/notifications?modmail=true">
							Mod Mail
						</a>
					</li>
					{% endif %}
				</ul>
			</div>
			<div class="ml-auto">
				<button class="btn btn-green" onclick="post_toast('/clear')">
					<i class="fas fa-check-double fa-sm fa-fw mr-1"></i>
					Mark all as read
				</button>
			</div>
		</div>
	</div>
{% endblock %}

{% block content %}

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

	<div class="col-span-full px-2.5 md:px-0">
	  	{% with comments=notifications %}
			{% include "CHRISTMAS/comments.html" %}
		{% endwith %}
	</div>

	{% if not notifications %}
	<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 unread messages</h2>
		<p class="text-gray-500 text-sm">
			When someone comments or replies, it will show up here.
		</p>
		<a href="/notifications" class="mt-3 btn btn-gray">
			View entire inbox
		</a>
	</div>
	{% endif %}

</div>

{% if notifications %}
<div class="col-span-full">
	<ul class="flex flex-wrap items-center mb-4">
		{% if page>1 %}
		<li>
			{% if "?page=" in request.full_path %}
				{% set path = request.full_path.split("?page=")[0] %}
			{% elif "&page=" in request.full_path %}
				{% set path = request.full_path.split("&page=")[0] %}
			{% else %}
				{% set path = request.full_path %}
			{% endif %}
			{% if request.full_path == "/notifications" %}
				<small><a class="block px-2 py-1 text-sm font-bold text-primary bg-gray-900" href="{{path}}?page={{page-1}}">Back</a></small>
			{% else %}
				<small><a class="block px-2 py-1 text-sm font-bold text-primary bg-gray-900" href="{{path}}&page={{page-1}}">Back</a></small>
			{% endif %}
		</li>
		{% else %}
		<li><button disabled class="block px-2 py-1 text-sm font-bold text-gray-700 bg-gray-800 cursor-not-allowed">Back</button></li>
		{% endif %}

		{% if next_exists %}
		<li>
			{% if "?page=" in request.full_path %}
				{% set path = request.full_path.split("?page=")[0] %}
			{% elif "&page=" in request.full_path %}
				{% set path = request.full_path.split("&page=")[0] %}
			{% else %}
				{% set path = request.full_path %}
			{% endif %}
			{% if request.full_path == "/notifications" %}
				<small><a class="block px-2 py-1 text-sm font-bold text-primary bg-gray-900" href="{{path}}?page={{page+1}}">Next</a></small>
			{% else %}
				<small><a class="block px-2 py-1 text-sm font-bold text-primary bg-gray-900" href="{{path}}&page={{page+1}}">Next</a></small>
			{% endif %}
		</li>
		{% else %}
		<li><button disabled class="block px-2 py-1 text-sm font-bold text-gray-700 bg-gray-800 cursor-not-allowed">Next</button></li>
		{% endif %}
	</ul>
</div>
{% endif %}

{% endblock %}

{% block GIFpicker %}
{% endblock %}