Files
threadcount-community/components/HelpMark.tsx
T
ThreadCount 8c86c988c1 ThreadCount Community edition
Uniform stock management for healthcare linen rooms: the coordinator app, the phone counter and the staff app, for your own server. Built from 2d04e45 on 2026-09-15. Licensed under the Functional Source License (FSL-1.1-ALv2).
2026-09-16 04:04:31 +10:00

33 lines
1.4 KiB
TypeScript

"use client";
import { Suspense } from "react";
import Link from "next/link";
import { usePathname, useSearchParams } from "next/navigation";
import { helpFor } from "@/lib/manual-links";
/* The help mark beside every app screen's title: one square that opens the manual page about the
* screen you are on. Only on the coordinator app (/app); the phone apps have their own furniture
* and Help itself needs no mark. Screens with tabs (Settings, Stock, Reports, a staff record) pick
* the page by ?tab=, which switches through router.replace, so the tab is read with
* useSearchParams. That reader sits in its own Suspense boundary, so no screen that renders a page
* head needs one; until it resolves the mark points at the screen's untabbed page. */
export default function HelpMark() {
const path = usePathname() || "";
if (!path.startsWith("/app") || path.startsWith("/app/help")) return null;
return (
<Suspense fallback={<Mark path={path} tab={null} />}>
<TabbedMark path={path} />
</Suspense>
);
}
function TabbedMark({ path }: { path: string }) {
const sp = useSearchParams();
return <Mark path={path} tab={sp?.get("tab") ?? null} />;
}
function Mark({ path, tab }: { path: string; tab: string | null }) {
return (
<Link href={`/app/help/${helpFor(path, tab)}`} className="tc-helpmark no-print" aria-label="Help for this screen" title="Help for this screen">?</Link>
);
}