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>
|
||||||
<div class="topbar-actions">
|
<div class="topbar-actions">
|
||||||
<a class="btn btn-primary" href="/orders/new">${icon("plus")} New order</a>
|
<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">
|
<a class="btn btn-secondary account-chip" href="/settings">
|
||||||
<span class="account-avatar" aria-hidden="true">DL</span>
|
<span class="account-avatar" aria-hidden="true">DL</span>
|
||||||
<span class="account-copy">
|
<span class="account-copy">
|
||||||
@@ -450,20 +449,15 @@ function accountLayoutOptions(session = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function dashboardPage(session) {
|
async function dashboardPage(session) {
|
||||||
const [homeOrders, results] = await Promise.all([
|
const orders = await loadDesktopOrders(session, { currentPage: 1, month: new Date().getMonth() + 1, year: new Date().getFullYear() });
|
||||||
loadHomeOrders(session),
|
|
||||||
loadResults(session, ""),
|
|
||||||
]);
|
|
||||||
const orders = homeOrders.items;
|
|
||||||
const stats = [
|
const stats = [
|
||||||
{ label: "Orders this month", value: String(homeOrders.totals.total), trend: `${homeOrders.month}/${homeOrders.year}`, hint: "" },
|
{ label: "Orders this month", value: String(orders.items.length), trend: `${orders.month}/${orders.year}`, hint: "" },
|
||||||
{ label: "Confirmed", value: String(homeOrders.totals.confirmed), trend: "Home", hint: "" },
|
{ label: "Confirmed", value: String(orders.items.filter((item) => item.status === "Confirmed").length), trend: "Home", hint: "" },
|
||||||
{ label: "Results pending", value: String(results.filter((item) => item.status !== "Released").length), trend: "Live", hint: "" },
|
{ label: "Unconfirmed", value: String(orders.items.filter((item) => item.status === "Unconfirmed").length), trend: "Home", hint: "" },
|
||||||
{ label: "Unconfirmed", value: String(homeOrders.totals.unconfirmed), trend: "Home", hint: "" },
|
|
||||||
];
|
];
|
||||||
return `
|
return `
|
||||||
<div class="stack">
|
<div class="stack">
|
||||||
<section class="grid grid-4">
|
<section class="grid grid-3">
|
||||||
${stats
|
${stats
|
||||||
.map(
|
.map(
|
||||||
(item) => `
|
(item) => `
|
||||||
@@ -481,15 +475,15 @@ async function dashboardPage(session) {
|
|||||||
</section>
|
</section>
|
||||||
<section class="detail-grid">
|
<section class="detail-grid">
|
||||||
<div class="panel">
|
<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">
|
<div class="table-wrap">
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>Patient</th><th>Order</th><th>Status</th><th>Updated</th></tr>
|
<tr><th>Patient</th><th>Order</th><th>Status</th><th>Updated</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
${orders.length
|
${(orders.items || []).length
|
||||||
? orders
|
? orders.items
|
||||||
.slice(0, 5)
|
.slice(0, 5)
|
||||||
.map(
|
.map(
|
||||||
(order) => `
|
(order) => `
|
||||||
@@ -502,7 +496,7 @@ async function dashboardPage(session) {
|
|||||||
`,
|
`,
|
||||||
)
|
)
|
||||||
.join("")
|
.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>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user