mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 11:58:14 +00:00
321a6298a4
- Pharmacy: the sidebar entry now expands into Pharmacy + a new Inventory page (searchable medication stock with derived in-stock/low/out availability, backed by /api/inventory). Fix the dispensing-queue "Expiring" badge so it only flags courses ending within the next 7 days, not ones already elapsed. - Lab "Add analysis result": the patient picker no longer lists patients until you type and supports arrow-key + Enter selection; the test field offers a catalog of common analyses with an Advanced option (custom analysis + ref range); submitted results now show immediately in a Recent results feed. - Analysis: add a Live panel (real-time line chart) and replace the flat trend sparklines with bklit-ui area + bar charts (installed from the @bklit shadcn registry; chart CSS variables wired into the theme for light and dark). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
"use client";
|
|
|
|
import { createContext, type ReactNode, useContext, useMemo } from "react";
|
|
|
|
interface ChartLegendHoverContextValue {
|
|
hoveredIndex: number | null;
|
|
setHoveredIndex: (index: number | null) => void;
|
|
}
|
|
|
|
const ChartLegendHoverContext =
|
|
createContext<ChartLegendHoverContextValue | null>(null);
|
|
|
|
export function ChartLegendHoverProvider({
|
|
hoveredIndex,
|
|
onHoverChange,
|
|
children,
|
|
}: {
|
|
hoveredIndex: number | null;
|
|
onHoverChange: (index: number | null) => void;
|
|
children: ReactNode;
|
|
}) {
|
|
const value = useMemo(
|
|
() => ({ hoveredIndex, setHoveredIndex: onHoverChange }),
|
|
[hoveredIndex, onHoverChange]
|
|
);
|
|
|
|
return (
|
|
<ChartLegendHoverContext.Provider value={value}>
|
|
{children}
|
|
</ChartLegendHoverContext.Provider>
|
|
);
|
|
}
|
|
|
|
export function useChartLegendHover(): ChartLegendHoverContextValue {
|
|
const context = useContext(ChartLegendHoverContext);
|
|
return (
|
|
context ?? {
|
|
hoveredIndex: null,
|
|
setHoveredIndex: () => {
|
|
/* noop outside ChartLegendHoverProvider */
|
|
},
|
|
}
|
|
);
|
|
}
|