c2b10347b1
- Removed rust-service/, c-runtime/, kafka stubs - Generic Store[T] pattern with real tests - Slimmed main.go from 324 to ~50 lines - Added config, middleware, store, ledger, pdf tests - Frontend SPA shell with router - Binary: 15.5MB -> 12MB
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
// CRM module
|
|
export async function render(container) {
|
|
container.innerHTML = `
|
|
<header class="module-header">
|
|
<h1>CRM</h1>
|
|
<p class="subtitle">Kunder och leads</p>
|
|
</header>
|
|
<div class="toolbar">
|
|
<button class="btn-primary" id="btn-new-customer">+ Ny kund</button>
|
|
</div>
|
|
<div class="table-container">
|
|
<table class="data-table" id="customers-table">
|
|
<thead>
|
|
<tr><th>Namn</th><th>Företag</th><th>Status</th><th>Email</th></tr>
|
|
</thead>
|
|
<tbody></tbody>
|
|
</table>
|
|
</div>
|
|
`;
|
|
|
|
try {
|
|
const res = await apiRequest('/crm/customers');
|
|
const data = await res.json();
|
|
const tbody = container.querySelector('#customers-table tbody');
|
|
|
|
if (data.customers?.length) {
|
|
tbody.innerHTML = data.customers.map(c => `
|
|
<tr>
|
|
<td>${c.name}</td>
|
|
<td>${c.company || '-'}</td>
|
|
<td><span class="badge badge-${c.status}">${c.status}</span></td>
|
|
<td>${c.email || '-'}</td>
|
|
</tr>
|
|
`).join('');
|
|
} else {
|
|
tbody.innerHTML = '<tr><td colspan="4">Inga kunder hittades</td></tr>';
|
|
}
|
|
} catch (err) {
|
|
container.innerHTML += `<div class="alert alert-error">Kunde inte ladda kunder: ${err.message}</div>`;
|
|
}
|
|
}
|