feat: update ingest, registry, and UI flows
This commit is contained in:
@@ -7,13 +7,24 @@
|
||||
{{template "breadcrumbs" .}}
|
||||
|
||||
<main class="container">
|
||||
<section class="card">
|
||||
<h2>Create Customer</h2>
|
||||
<form class="form" id="create-customer-form">
|
||||
<div class="field">
|
||||
<label for="customer-name">Name</label>
|
||||
<input id="customer-name" class="input" type="text" required />
|
||||
</div>
|
||||
<button class="button" type="submit">Create</button>
|
||||
<div class="meta" id="create-customer-message"></div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h2>All Customers</h2>
|
||||
{{if .Customers}}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Name</th>
|
||||
<th>Created</th>
|
||||
<th>Updated</th>
|
||||
@@ -22,7 +33,6 @@
|
||||
<tbody>
|
||||
{{range .Customers}}
|
||||
<tr>
|
||||
<td>{{.ID}}</td>
|
||||
<td>{{.Name}}</td>
|
||||
<td title="{{formatTimeFull .CreatedAt}}">{{formatTime .CreatedAt}}</td>
|
||||
<td title="{{formatTimeFull .UpdatedAt}}">{{formatTime .UpdatedAt}}</td>
|
||||
@@ -35,6 +45,35 @@
|
||||
{{end}}
|
||||
</section>
|
||||
</main>
|
||||
<script>
|
||||
const customerForm = document.getElementById('create-customer-form');
|
||||
const customerMessage = document.getElementById('create-customer-message');
|
||||
|
||||
customerForm.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
customerMessage.textContent = '';
|
||||
|
||||
const name = document.getElementById('customer-name').value.trim();
|
||||
if (!name) {
|
||||
customerMessage.textContent = 'Customer name is required.';
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch('/customers', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: JSON.stringify({name})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const payload = await response.json().catch(() => ({error: 'Create failed'}));
|
||||
customerMessage.textContent = payload.error || 'Create failed';
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user