ERP/templates/customers/list.html

64 lines
3.0 KiB
HTML
Raw Normal View History

2026-02-06 17:35:29 +01:00
{{define "content"}}
<div class="space-y-6">
<div class="sm:flex sm:items-center sm:justify-between">
<h1 class="text-2xl font-bold text-gray-900">Customers</h1>
<a href="/customers/new" class="inline-flex items-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500">
+ New Customer
</a>
</div>
<!-- Search -->
<div class="max-w-md">
<input type="search" name="search" placeholder="Search customers..."
value="{{.Search}}"
class="block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm"
hx-get="/customers?partial=true"
hx-trigger="input changed delay:300ms, search"
hx-target="#customer-table"
hx-include="this">
</div>
<div id="customer-table">
{{template "customer-table" .}}
</div>
</div>
{{end}}
{{define "customer-table"}}
<div class="overflow-hidden bg-white shadow ring-1 ring-black ring-opacity-5 sm:rounded-lg">
<table class="min-w-full divide-y divide-gray-300">
<thead class="bg-gray-50">
<tr>
<th class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900">Name</th>
<th class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Email</th>
<th class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Phone</th>
<th class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Actions</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
{{if .Customers}}
{{range .Customers}}
<tr class="hover:bg-gray-50">
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-indigo-600">
<a href="/customers/{{.ID}}">{{.Name}}</a>
</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{.Email}}</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{.Phone}}</td>
<td class="whitespace-nowrap px-3 py-4 text-sm space-x-2">
<a href="/customers/{{.ID}}/edit" class="text-indigo-600 hover:text-indigo-900">Edit</a>
<button class="text-red-600 hover:text-red-900"
hx-delete="/customers/{{.ID}}"
hx-confirm="Are you sure you want to delete this customer?">Delete</button>
</td>
</tr>
{{end}}
{{else}}
<tr>
<td colspan="4" class="px-3 py-8 text-center text-sm text-gray-500">No customers found. <a href="/customers/new" class="text-indigo-600 hover:text-indigo-500">Create one</a>.</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{end}}