Close the UI-review follow-ups: names typeahead, fleet form, overflow flip.
Some checks are pending
offline / test (push) Waiting to run
Some checks are pending
offline / test (push) Waiting to run
Staff pages typeahead customers by name (Ada, not cust_1). Add-machine is two rows with a wide identity path and filename picker. Overflow menus flip up near the viewport edge. Customer list no longer leaks password hashes. UI-REVIEW.pdf remaining list is the three leftover items.
This commit is contained in:
parent
9cc0018708
commit
b68fefdea8
41 changed files with 569 additions and 454 deletions
|
|
@ -53,8 +53,9 @@
|
|||
<div class="card">
|
||||
<div class="row">
|
||||
<div>
|
||||
<label for="id">Customer id or name</label>
|
||||
<input id="id" value="cust_1" autocomplete="off" />
|
||||
<label for="id">Customer</label>
|
||||
<input id="id" list="cust-list" placeholder="Type a name or id" autocomplete="off" />
|
||||
<datalist id="cust-list"></datalist>
|
||||
</div>
|
||||
<button type="button" onclick="review()">Review account</button>
|
||||
<a class="btn ghost" href="/export/quickbooks.iif">QuickBooks IIF</a>
|
||||
|
|
@ -77,6 +78,18 @@
|
|||
}).join('') + '</tr>').join('');
|
||||
return `<table><thead><tr>${head}</tr></thead><tbody>${body}</tbody></table>`;
|
||||
}
|
||||
async function loadCustomers() {
|
||||
try {
|
||||
const { customers } = await (await fetch('/customers')).json();
|
||||
document.getElementById('cust-list').innerHTML = (customers || [])
|
||||
.map((c) => `<option value="${c.name}">${c.id}</option>`)
|
||||
.join('');
|
||||
if (customers && customers[0] && !document.getElementById('id').value) {
|
||||
document.getElementById('id').value = customers[0].name;
|
||||
}
|
||||
} catch { /* edge optional */ }
|
||||
}
|
||||
loadCustomers();
|
||||
async function review() {
|
||||
const id = document.getElementById('id').value.trim();
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,16 @@
|
|||
/** Join ledger ids to zappier-edge customer display names. */
|
||||
export async function listCustomers(edge, key) {
|
||||
try {
|
||||
const r = await fetch(`${edge.replace(/\/$/, '')}/admin/api/customers`, {
|
||||
headers: { 'x-admin-key': key },
|
||||
});
|
||||
const body = await r.json();
|
||||
return (body.customers || []).map(({ passwordHash, apiKey, totpSecret, ...rest }) => rest);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function withCustomerName(st, idOrName, edge, key) {
|
||||
const out = { ...(st || {}) };
|
||||
if (out.name && out.customerId) return out;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import http from 'node:http';
|
|||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { SUBJECTS, billingRequest } from './nats-billing.js';
|
||||
import { withCustomerName } from './names.js';
|
||||
import { listCustomers, withCustomerName } from './names.js';
|
||||
|
||||
const PORT = Number(process.env.PORT || 3013);
|
||||
const EDGE = (process.env.ZAPPIER_ADMIN_URL || 'http://127.0.0.1:3000').replace(/\/$/, '');
|
||||
|
|
@ -41,6 +41,9 @@ const server = http.createServer(async (req, res) => {
|
|||
if (req.method === 'GET' && url.pathname === '/health') {
|
||||
return json(200, { ok: true, role: 'zappier-accounting-export' });
|
||||
}
|
||||
if (req.method === 'GET' && url.pathname === '/customers') {
|
||||
return json(200, { customers: await listCustomers(EDGE, KEY) });
|
||||
}
|
||||
const review = url.pathname.match(/^\/review\/([^/]+)$/);
|
||||
if (req.method === 'GET' && review) {
|
||||
const id = decodeURIComponent(review[1]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue