← back to NationalPaperHangers

views/admin/papers-moderation.ejs

46 lines

<%- include('../partials/head', { title, admin: true }) %>
<%- include('partials/admin-header') %>
<section class="admin-main">
  <header class="admin-page-head">
    <h1>Paper-comment moderation</h1>
    <p class="muted">Comments post immediately and are public-readable. Flag to hide from public view (reversible, not deletion).</p>
  </header>
  <% if (flash && flash.ok) { %><div class="callout callout-success"><%= flash.ok %></div><% } %>
  <% if (flash && flash.error) { %><div class="callout callout-warn"><%= flash.error %></div><% } %>

  <nav style="display:flex;gap:8px;margin:8px 0 24px">
    <% ['all','visible','flagged'].forEach(function(s){ %>
      <a href="/admin/papers-moderation?show=<%= s %>"
         style="padding:6px 14px;border:1px solid <%= show === s ? '#0e0e0e' : 'var(--border,#ddd)' %>;border-radius:18px;font-size:13px;color:<%= show === s ? '#fff' : 'inherit' %>;background:<%= show === s ? '#0e0e0e' : 'transparent' %>;text-decoration:none;text-transform:capitalize">
        <%= s %>
      </a>
    <% }); %>
  </nav>

  <% if (!comments || !comments.length) { %>
    <div class="callout"><p style="margin:0">No comments in this view.</p></div>
  <% } else { %>
    <% comments.forEach(function(c){ %>
      <article style="border:1px solid <%= c.flagged ? '#fca5a5' : 'var(--border,#ddd)' %>;border-radius:8px;padding:16px 18px;margin:0 0 14px;background:<%= c.flagged ? '#fef2f2' : 'transparent' %>">
        <header style="display:flex;justify-content:space-between;align-items:start;gap:12px;flex-wrap:wrap;margin-bottom:10px">
          <div style="font-size:13px">
            <a href="/papers/<%= c.thread_slug %>" style="color:inherit"><strong><%= c.thread_brand %> · <%= c.thread_paper %></strong></a>
            <span class="muted"> · by <a href="/installer/<%= c.installer_slug %>" style="color:inherit"><%= c.installer_business_name %></a></span>
          </div>
          <span class="muted" style="font-size:12px"><%= new Date(c.created_at).toLocaleString('en-US') %></span>
        </header>
        <p style="margin:0 0 12px;font-size:14px;line-height:1.55;white-space:pre-wrap"><%= c.body %></p>
        <form method="post" action="/admin/papers-moderation/<%= c.id %>/<%= c.flagged ? 'unflag' : 'flag' %>" style="display:flex;gap:8px;align-items:center">
          <input type="hidden" name="_csrf" value="<%= csrfToken %>">
          <input type="hidden" name="return_to_show" value="<%= show %>">
          <button type="submit" class="btn <%= c.flagged ? 'btn-ghost' : 'btn-warn' %> btn-sm">
            <%= c.flagged ? 'Unflag (restore)' : 'Flag (hide)' %>
          </button>
          <% if (c.flagged) { %><span class="muted" style="font-size:12px">Hidden from public</span><% } %>
        </form>
      </article>
    <% }); %>
  <% } %>
</section>
<%- include('../partials/footer') %>