{% extends "base.html" %}
{% block title %}Sites - Form Relay{% endblock %}
{% block content %}
<h1 style="margin-bottom:20px;">Manage Sites</h1>
<div class="card" style="margin-bottom:24px;">
<h3 style="margin-bottom:12px;">Add New Site</h3>
<form method="POST" action="/sites/add">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"/>
<input type="text" name="name" placeholder="Site name (e.g., Quality Small Engine Repair)" required>
<input type="email" name="owner_email" placeholder="Owner email (e.g., owner@gmail.com)" required>
<input type="email" name="smtp_from" placeholder="From email (optional, uses default if blank)">
<button type="submit" class="btn">Add Site</button>
</form>
</div>
<div class="card">
<table>
<thead>
<tr>
<th>Site</th>
<th>Token</th>
<th>Owner Email</th>
<th>From Email</th>
<th>Created</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for site in sites %}
<tr>
<td>{{ site.name }}</td>
<td><span class="token">{{ site.token }}</span></td>
<td>{{ site.owner_email }}</td>
<td>{{ site.smtp_from or '(default)' }}</td>
<td>{{ site.created_at[:10] }}</td>
<td>
<form method="POST" action="/sites/delete/{{ site.id }}" style="display:inline;" data-onclick="return confirm('Delete this site? This cannot be undone.');">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"/>
data-onsubmit="return confirm('Delete this site?')">
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}