← back to NationalPaperHangers
views/admin/ops-credentials.ejs
83 lines
<%- include('../partials/head', { title, admin: true }) %>
<%- include('partials/admin-header') %>
<%
var typeLabel = {
brand_trained: 'Brand-trained',
brand_certified: 'Brand-certified',
brand_approved: 'Brand-approved',
manufacturer_partner: 'Manufacturer partner',
trade_member: 'Trade member'
};
%>
<section class="admin-main">
<header class="admin-page-head">
<p class="kicker">Ops</p>
<h1>Credential review queue</h1>
<p class="muted"><%= pending.length %> pending · <%= verifiedCount %> verified to date</p>
</header>
<% if (flash && flash.ok) { %><div class="callout callout-ok"><%= flash.ok %></div><% } %>
<% if (flash && flash.error) { %><div class="callout callout-warn"><%= flash.error %></div><% } %>
<% if (pending.length === 0) { %>
<div class="empty-state">
<h3>Nothing to review.</h3>
<p>All submitted Brand-Trained credentials have been processed. Studios can submit new ones from <code>/admin/profile</code>.</p>
</div>
<% } else { %>
<table class="data-table">
<thead>
<tr>
<th>Studio</th>
<th>Brand</th>
<th>Type</th>
<th>Year</th>
<th>Cert</th>
<th>Notes</th>
<th>Submitted</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<% pending.forEach(function(c){ %>
<tr>
<td>
<a href="/installer/<%= c.slug %>" target="_blank" rel="noopener" style="color:inherit"><strong><%= c.business_name %></strong></a><br>
<span class="muted" style="font-size:12px"><%= [c.city, c.state].filter(Boolean).join(', ') %><% if (c.website) { %> · <a href="<%= c.website %>" target="_blank" rel="noopener" style="color:inherit">site ↗</a><% } %></span>
</td>
<td><strong><%= c.brand %></strong></td>
<td><%= typeLabel[c.credential_type] || c.credential_type %></td>
<td><%= c.year_issued || '—' %><% if (c.year_expires) { %> – <%= c.year_expires %><% } %></td>
<td>
<% if (c.certificate_url) { %>
<a href="<%= c.certificate_url %>" target="_blank" rel="noopener">View ↗</a>
<% } else { %>—<% } %>
</td>
<td><span class="muted" style="font-size:12px"><%= c.notes || '—' %></span></td>
<td><span class="muted" style="font-size:12px"><%= new Date(c.created_at).toLocaleDateString() %></span></td>
<td class="actions" style="white-space:nowrap">
<form method="post" action="/admin/ops/credentials/<%= c.id %>/verify" class="inline-form" style="display:inline">
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
<button class="btn btn-primary btn-sm">Verify</button>
</form>
<form method="post" action="/admin/ops/credentials/<%= c.id %>/reject" class="inline-form" style="display:inline" onsubmit="return confirm('Reject this credential? It will be removed.')">
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
<button class="btn btn-ghost btn-sm">Reject</button>
</form>
</td>
</tr>
<% }); %>
</tbody>
</table>
<p class="muted" style="margin-top:24px;font-size:13px">
Verifying flips <code>ops_verified=true</code> on the row → the badge appears immediately on the studio's public profile.
Rejecting deletes the row — the studio can resubmit with corrected info.
</p>
<% } %>
</section>
<%- include('../partials/footer') %>