<%- include('partials/header', { title, user }) %>
<% const unread = notifications.filter((item) => !item.read_at).length; %>
<section class="hero notifications-hero">
	<div><p class="kicker">Inbox</p><h1>Notifications</h1><p class="muted"><%= unread ? `${unread} unread` : 'You’re all caught up.' %></p></div>
	<% if (unread) { %><form method="post" action="/notifications/read-all"><button class="button outline small" type="submit">Mark all as read</button></form><% } %>
</section>
<section class="notification-list">
	<% if (!notifications.length) { %>
		<div class="notification-empty"><p>No notifications yet. Reminders and updates that need your attention will appear here.</p></div>
	<% } %>
	<% notifications.forEach((item) => { %>
	<a class="notification-item<%= item.read_at ? '' : ' unread' %> <%= item.type %>" href="/notifications/<%= item.id %>/open">
		<span class="notification-text"><strong><%= item.title %></strong><% if (item.body) { %><span><%= item.body %></span><% } %></span>
		<time datetime="<%= new Date(item.created_at).toISOString() %>"><%= fmtDate(item.created_at) %></time>
		<% if (!item.read_at) { %><span class="notification-dot" aria-label="Unread"></span><% } %>
	</a>
	<% }) %>
</section>
<%- include('partials/footer') %>
