| 1 |
{%- import "partials/_ui.html" as ui -%} |
| 2 |
<div class="section-group-label">Contacts</div> |
| 3 |
|
| 4 |
<details class="form-section buyer-contacts" open> |
| 5 |
<summary><h2 class="subsection-title">Shared Contacts ({{ contacts.len() }})</h2></summary> |
| 6 |
<p class="text-sm muted mb-4"> |
| 7 |
Buyers who opted to share their email at checkout. They can revoke sharing from their library. |
| 8 |
</p> |
| 9 |
{% if !contacts.is_empty() %} |
| 10 |
<div class="mb-4"> |
| 11 |
<button class="btn-secondary text-sm" |
| 12 |
hx-post="/api/export/contacts" |
| 13 |
hx-swap="none" |
| 14 |
onclick="this.textContent='Exporting...'; this.disabled=true; var btn=this; fetch('/api/export/contacts', {method:'POST', headers: csrfHeaders()}).then(function(r){return r.blob()}).then(function(b){var a=document.createElement('a'); a.href=URL.createObjectURL(b); a.download='contacts.csv'; a.click(); btn.textContent='Export CSV'; btn.disabled=false;}).catch(function(){btn.textContent='Export CSV'; btn.disabled=false; showToast('Export failed')});">Export CSV</button> |
| 15 |
</div> |
| 16 |
<div class="scroll-x"> |
| 17 |
<table class="data-table contacts-table"> |
| 18 |
<thead> |
| 19 |
<tr> |
| 20 |
<th>Username</th> |
| 21 |
<th>Email</th> |
| 22 |
<th>Purchases</th> |
| 23 |
<th>Total Spent</th> |
| 24 |
<th>Last Purchase</th> |
| 25 |
</tr> |
| 26 |
</thead> |
| 27 |
<tbody> |
| 28 |
{% for contact in contacts %} |
| 29 |
<tr> |
| 30 |
<td><a href="/u/{{ contact.username }}">{{ contact.username }}</a></td> |
| 31 |
<td>{{ contact.email }}</td> |
| 32 |
<td>{{ contact.total_purchases }}</td> |
| 33 |
<td>{{ contact.total_spent }}</td> |
| 34 |
<td>{{ contact.last_purchase }}</td> |
| 35 |
</tr> |
| 36 |
{% endfor %} |
| 37 |
</tbody> |
| 38 |
</table> |
| 39 |
</div> |
| 40 |
{% else %} |
| 41 |
{% call ui::empty_state("", "No shared contacts yet. When buyers opt to share their email at checkout, they will appear here.") %} |
| 42 |
{% endif %} |
| 43 |
</details> |
| 44 |
|