diff --git a/src/components/labnotes/LabNoteCard.tsx b/src/components/labnotes/LabNoteCard.tsx
index c01f403..9475b96 100644
--- a/src/components/labnotes/LabNoteCard.tsx
+++ b/src/components/labnotes/LabNoteCard.tsx
@@ -30,6 +30,7 @@
// src/components/labnotes/LabNoteCard.tsx
import React from "react";
import { Link } from "react-router-dom";
+const { i18n } = useTranslation("labNotesPage");
import { useTranslation } from "react-i18next";
import type { LabNote } from "@/lib/labNotes";
@@ -83,6 +84,7 @@ type Props = {
};
export function LabNoteCard({ note, index }: Props) {
+ const locale = i18n.language || "en";
const { t } = useTranslation("labNotesPage");
// Prefer canonical department_id; dept is optional label
const deptKey = (note.dept ?? note.department_id ?? "scms").toLowerCase();
@@ -236,7 +238,7 @@ export function LabNoteCard({ note, index }: Props) {
{t("readMore", { defaultValue: "Open Note" })} →
diff --git a/src/pages/LabNoteDetailPage.tsx b/src/pages/LabNoteDetailPage.tsx
index 514b961..a1093bc 100644
--- a/src/pages/LabNoteDetailPage.tsx
+++ b/src/pages/LabNoteDetailPage.tsx
@@ -32,19 +32,21 @@ import { fetchLabNoteBySlug, getLabNotes } from "@/lib/labNotes";
import type { LabNote } from "@/lib/labNotes";
type RouteParams = {
- id?: string; // slug-style id
+ slug?: string;
+ locale?: string; // if you add :locale routes
};
export function LabNoteDetailPage() {
- const { id } = useParams();
+ const { slug, locale: routeLocale } = useParams();
const { i18n, t } = useTranslation("labNotesPage");
- const locale = i18n.language || "en";
+ const locale = routeLocale || i18n.language || "en";
+ const base = `/${locale}`;
const [note, setNote] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
- if (!id) return;
+ if (!slug) return;
const controller = new AbortController();
let alive = true;
@@ -53,7 +55,7 @@ export function LabNoteDetailPage() {
setLoading(true);
try {
- const data = await fetchLabNoteBySlug(locale, id, controller.signal);
+ const data = await fetchLabNoteBySlug(locale, slug, controller.signal);
if (!alive) return;
setNote(data);
@@ -71,7 +73,7 @@ export function LabNoteDetailPage() {
console.error(e);
// Local fallback (useful when API is down)
- const local = getLabNotes(locale).find((n) => n.id === id) ?? null;
+ const local = getLabNotes(locale).find((n) => n.id === slug) ?? null;
setNote(local);
} finally {
if (alive) setLoading(false);
@@ -83,7 +85,7 @@ export function LabNoteDetailPage() {
alive = false;
controller.abort();
};
- }, [id, locale]);
+ }, [slug, locale]);
if (loading) {
return (
@@ -108,7 +110,7 @@ export function LabNoteDetailPage() {
This entry has been retracted or never existed in this timeline.
← Return to Registry
@@ -127,7 +129,7 @@ export function LabNoteDetailPage() {
{/* Breadcrumb */}