Refine dashboard recent orders
This commit is contained in:
24
server.js
24
server.js
@@ -340,7 +340,6 @@ function topbar(activePath, subtitle, accountName = "", accountMeta = "") {
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<a class="btn btn-primary" href="/orders/new">${icon("plus")} New order</a>
|
||||
<button class="icon-btn" type="button" data-action="alert" title="Notifications">${icon("bell")}</button>
|
||||
<a class="btn btn-secondary account-chip" href="/settings">
|
||||
<span class="account-avatar" aria-hidden="true">DL</span>
|
||||
<span class="account-copy">
|
||||
@@ -450,20 +449,15 @@ function accountLayoutOptions(session = {}) {
|
||||
}
|
||||
|
||||
async function dashboardPage(session) {
|
||||
const [homeOrders, results] = await Promise.all([
|
||||
loadHomeOrders(session),
|
||||
loadResults(session, ""),
|
||||
]);
|
||||
const orders = homeOrders.items;
|
||||
const orders = await loadDesktopOrders(session, { currentPage: 1, month: new Date().getMonth() + 1, year: new Date().getFullYear() });
|
||||
const stats = [
|
||||
{ label: "Orders this month", value: String(homeOrders.totals.total), trend: `${homeOrders.month}/${homeOrders.year}`, hint: "" },
|
||||
{ label: "Confirmed", value: String(homeOrders.totals.confirmed), trend: "Home", hint: "" },
|
||||
{ label: "Results pending", value: String(results.filter((item) => item.status !== "Released").length), trend: "Live", hint: "" },
|
||||
{ label: "Unconfirmed", value: String(homeOrders.totals.unconfirmed), trend: "Home", hint: "" },
|
||||
{ label: "Orders this month", value: String(orders.items.length), trend: `${orders.month}/${orders.year}`, hint: "" },
|
||||
{ label: "Confirmed", value: String(orders.items.filter((item) => item.status === "Confirmed").length), trend: "Home", hint: "" },
|
||||
{ label: "Unconfirmed", value: String(orders.items.filter((item) => item.status === "Unconfirmed").length), trend: "Home", hint: "" },
|
||||
];
|
||||
return `
|
||||
<div class="stack">
|
||||
<section class="grid grid-4">
|
||||
<section class="grid grid-3">
|
||||
${stats
|
||||
.map(
|
||||
(item) => `
|
||||
@@ -481,15 +475,15 @@ async function dashboardPage(session) {
|
||||
</section>
|
||||
<section class="detail-grid">
|
||||
<div class="panel">
|
||||
${panelHeader("Recent orders", `Monthly snapshot from /order/home for ${homeOrders.month}/${homeOrders.year}.`, '<a class="btn btn-secondary" href="/orders">View all</a>')}
|
||||
${panelHeader("Recent orders", "", '<a class="btn btn-secondary" href="/orders">View all</a>')}
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Patient</th><th>Order</th><th>Status</th><th>Updated</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${orders.length
|
||||
? orders
|
||||
${(orders.items || []).length
|
||||
? orders.items
|
||||
.slice(0, 5)
|
||||
.map(
|
||||
(order) => `
|
||||
@@ -502,7 +496,7 @@ async function dashboardPage(session) {
|
||||
`,
|
||||
)
|
||||
.join("")
|
||||
: `<tr><td colspan="4">${emptyState("No orders returned", "The home endpoint did not return any rows for this month.")}</td></tr>`}
|
||||
: `<tr><td colspan="4">${emptyState("No orders returned", "The desktop order endpoint did not return any rows for this page.")}</td></tr>`}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user