ERP/templates/customers/list.html

100 lines
5.1 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>
2026-02-07 07:47:20 +01:00
<div class="mt-4 flex items-center justify-between border-t border-gray-200 bg-white px-4 py-3 sm:px-6">
<div class="hidden sm:flex sm:flex-1 sm:items-center sm:justify-between">
<div>
<p class="text-sm text-gray-700">
Page <span class="font-medium">{{.Page}}</span> of <span class="font-medium">{{.TotalPages}}</span>
</p>
</div>
<div>
<nav class="isolate inline-flex -space-x-px rounded-md shadow-sm" aria-label="Pagination">
{{if .HasPrev}}
<button
hx-get="/customers?page={{.PrevPage}}&search={{.Search}}&partial=true"
hx-target="#customer-table"
class="relative inline-flex items-center rounded-l-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0">
<span class="sr-only">Previous</span>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z" clip-rule="evenodd" />
</svg>
</button>
{{end}}
{{if .HasNext}}
<button
hx-get="/customers?page={{.NextPage}}&search={{.Search}}&partial=true"
hx-target="#customer-table"
class="relative inline-flex items-center rounded-r-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0">
<span class="sr-only">Next</span>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
</svg>
</button>
{{end}}
</nav>
</div>
</div>
</div>
2026-02-06 17:35:29 +01:00
{{end}}