chore(context): lint + build adjustments

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
SJCoetz 2026-08-07 03:04:28 +02:00
parent f5185d3a2c
commit 2de8cf1a56
4 changed files with 10 additions and 21 deletions

View file

@ -104,6 +104,7 @@ export function OrderItemContextPanel({ itemId, defaultOpen = true, onApply }: P
}, [itemId, data, loading]);
useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect -- data fetch on dep change
if (open) void fetchOnce();
}, [open, fetchOnce]);

View file

@ -7,35 +7,24 @@ import {
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
import { OrderItemContextPanel, type ApplyPayload } from "@/components/order-item-context-panel";
import type { OrderItemContextResponse } from "@/lib/server/order-item-context-service";
import { OrderItemContextPanel } from "@/components/order-item-context-panel";
import { cn } from "@/lib/utils";
interface Props {
itemId: string;
/** Optional pre-loaded context. Saves a fetch on first open if supplied. */
initialData?: OrderItemContextResponse | null;
className?: string;
}
/**
* ⓘ popover trigger that renders the deterministic order-item
* context inside the orders detail page items table. Fetches lazily
* on first open. Hidden entirely if the fetch 404s (e.g. the
* endpoint is feature-flagged off).
* on first open.
*/
export function OrderItemContextPopoverTrigger({ itemId, initialData, className }: Props) {
export function OrderItemContextPopoverTrigger({ itemId, className }: Props) {
const [open, setOpen] = useState(false);
const [hidden, setHidden] = useState(false);
const handleOpen = async (next: boolean) => {
setOpen(next);
};
if (hidden) return null;
return (
<Popover open={open} onOpenChange={handleOpen}>
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger
className={cn(
"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full",
@ -56,7 +45,7 @@ export function OrderItemContextPopoverTrigger({ itemId, initialData, className
<OrderItemContextPanel
itemId={itemId}
defaultOpen
onApply={(_p: ApplyPayload) => {
onApply={() => {
// Orders page is read-only at the row level — apply
// requires the user to open the process modal. Close
// the popover and let the row click target the modal.

View file

@ -1,6 +1,6 @@
"use client";
import { useCallback, useEffect, useState } from "react";
import { useEffect, useState } from "react";
import {
Building2,
ChevronDown,

View file

@ -8,14 +8,13 @@
* supplier/cheapest aggregate give the operator the historical
* record before they pick a supplier and cost.
*
* Pure helpers (`normaliseSkuForHistory`, `findBestDescriptionMatch`,
* `aggregateSuppliers`, `computeCheapest`, `daysAgo`, `isValidPrice`)
* are imported from `item-history-service.ts` — DO NOT duplicate them.
* Pure helpers (`findBestDescriptionMatch`, `aggregateSuppliers`,
* `computeCheapest`, `daysAgo`, `isValidPrice`) are imported from
* `item-history-service.ts` — DO NOT duplicate them.
*/
import { getAdminPocketBase } from "@/lib/server/pocketbase-admin";
import {
normaliseSkuForHistory,
findBestDescriptionMatch,
aggregateSuppliers,
computeCheapest,