chore: make everything current

This commit is contained in:
2026-04-22 01:49:35 +00:00
parent 6eee7bf0da
commit c3d55b898f
13 changed files with 1419 additions and 119 deletions
+5 -43
View File
@@ -6,6 +6,7 @@
import NoResultsMonkey from "../../../components/NoResultsMonkey.svelte";
import AccessDenied from "../../../components/AccessDenied.svelte";
import Pagination from "../../../components/Pagination.svelte";
import InventoryPopover from "../../../components/InventoryPopover.svelte";
import { formatDate } from "$lib/utils";
import "../../../styles/procurement/catalog.css";
import { clientFetch } from "$lib/client-fetch";
@@ -598,16 +599,7 @@
<td class="col-price">{formatCurrency(item.price)}</td>
<td class="col-cost">{formatCurrency(item.cost)}</td>
<td class="col-onhand">
<span
class="onhand-badge"
class:onhand-zero={item.onHand === 0}
class:onhand-low={item.onHand != null &&
item.onHand > 0 &&
item.onHand <= 3}
class:onhand-ok={item.onHand != null && item.onHand > 3}
>
{item.onHand ?? "—"}
</span>
<InventoryPopover identifier={item.id} onHand={item.onHand} />
</td>
<td class="col-status">
<span
@@ -721,17 +713,7 @@
<div class="detail-field">
<span class="detail-label">On Hand</span>
<span class="detail-value">
<span
class="onhand-badge"
class:onhand-zero={selectedItem.onHand === 0}
class:onhand-low={selectedItem.onHand != null &&
selectedItem.onHand > 0 &&
selectedItem.onHand <= 3}
class:onhand-ok={selectedItem.onHand != null &&
selectedItem.onHand > 3}
>
{selectedItem.onHand ?? "—"}
</span>
<InventoryPopover identifier={selectedItem.id} onHand={selectedItem.onHand} />
</span>
</div>
</div>
@@ -966,17 +948,7 @@
<div class="linked-detail-field">
<span class="detail-label">On Hand</span>
<span class="detail-value">
<span
class="onhand-badge"
class:onhand-zero={li.onHand === 0}
class:onhand-low={li.onHand != null &&
li.onHand > 0 &&
li.onHand <= 3}
class:onhand-ok={li.onHand != null &&
li.onHand > 3}
>
{li.onHand ?? "—"}
</span>
<InventoryPopover identifier={li.id} onHand={li.onHand} />
</span>
</div>
<div class="linked-detail-field">
@@ -1332,17 +1304,7 @@
<div class="link-preview-field">
<span class="detail-label">On Hand</span>
<span class="detail-value">
<span
class="onhand-badge"
class:onhand-zero={linkPreviewItem.onHand === 0}
class:onhand-low={linkPreviewItem.onHand != null &&
linkPreviewItem.onHand > 0 &&
linkPreviewItem.onHand <= 3}
class:onhand-ok={linkPreviewItem.onHand != null &&
linkPreviewItem.onHand > 3}
>
{linkPreviewItem.onHand ?? "—"}
</span>
<InventoryPopover identifier={linkPreviewItem.id} onHand={linkPreviewItem.onHand} />
</span>
</div>
{#if linkPreviewItem.manufacturer}
@@ -4,21 +4,21 @@ import type { RequestHandler } from "./$types";
/** GET /procurement/catalog/inventory?id=<identifier> */
export const GET: RequestHandler = async ({ url, locals }) => {
const accessToken = locals.session?.accessToken;
if (!accessToken) throw error(401, "Unauthorized");
const accessToken = locals.session?.accessToken;
if (!accessToken) throw error(401, "Unauthorized");
const identifier = url.searchParams.get("id");
if (!identifier) throw error(400, "Missing id parameter");
const identifier = url.searchParams.get("id");
if (!identifier) throw error(400, "Missing id parameter");
try {
const result = await optima.procurement.fetchInventory(accessToken, identifier);
return json(result);
} catch (err: unknown) {
console.error("Failed to fetch product inventory:", err);
const status =
err && typeof err === "object" && "status" in err
? (err as { status: number }).status
: 500;
throw error(status, "Failed to fetch product inventory");
}
try {
const result = await optima.procurement.fetchInventory(accessToken, identifier);
return json(result);
} catch (err: unknown) {
console.error("Failed to fetch product inventory:", err);
const status =
err && typeof err === "object" && "status" in err
? (err as { status: number }).status
: 500;
throw error(status, "Failed to fetch product inventory");
}
};
@@ -8,6 +8,7 @@
import { optima } from "$lib";
import NoResultsMonkey from "../../../../../components/NoResultsMonkey.svelte";
import AddProductModal from "../../../../../components/AddProductModal.svelte";
import InventoryPopover from "../../../../../components/InventoryPopover.svelte";
import type { CatalogItem } from "$lib/optima-api/modules/procurement";
import type {
AddProductBody,
@@ -2556,7 +2557,12 @@
<div class="detail-field">
<span class="detail-field-label">On Hand</span>
<span class="detail-field-value">
{#if selectedProduct.onHand != null}
{#if selectedProduct.catalogItem}
<InventoryPopover
identifier={String(selectedProduct.catalogItem.id)}
onHand={selectedProduct.onHand ?? undefined}
/>
{:else if selectedProduct.onHand != null}
<span
class="stock-badge"
class:stock-none={selectedProduct.onHand === 0}