Repository navigation
Recent pages across Work and Clinical, and a start list on Clinical mode homes #3498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3f85d17
Recent pages across Work and Clinical, and a start list on Clinical m…
claude b006b21
Recent pages: record documents by their own title, never save a stale…
claude 4bd2b4d
Merge branch 'main' into claude/site-clinical-recent-xk2j9i
BigSimmo 2b91d60
fix(recent-pages): honour Save recent searches everywhere, never keep…
claude d947fcb
Mode home start list: move the shared row and group into their own fi…
claude 78f272a
Recent pages: load the recorder after the page and keep the patient-d…
claude dcc4c09
Recent pages: a recorder that loads after the reader moved on waits f…
claude b61c672
Recent pages: the small eager wrapper notes any navigation before the…
claude 7752fb6
Recent pages: test the eager wrapper hands a late-loading recorder th…
claude e565426
Merge remote-tracking branch 'origin/main' into claude/site-clinical-…
claude d3f824d
Merge remote-tracking branch 'origin/main' into claude/site-clinical-…
claude 8f33add
Merge branch 'main' into claude/site-clinical-recent-xk2j9i
BigSimmo 7f011d0
Merge main into claude/site-clinical-recent-xk2j9i
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect, useState } from "react"; | ||
|
|
||
| import { useAccountData } from "@/components/account-data-provider"; | ||
| import { ModeHomeStartGroup, ModeHomeStartRow } from "@/components/mode-home-start-parts"; | ||
| import { appModeIcons } from "@/lib/app-mode-icons"; | ||
| import type { AppModeId } from "@/lib/app-modes"; | ||
|
|
||
| /** How many favourites a mode home lists; the Favourites page holds the rest. */ | ||
| const FAVOURITES_SHOWN = 3; | ||
|
|
||
| type FavouriteRow = { readonly slug: string; readonly title: string; readonly href: string }; | ||
|
|
||
| /** | ||
| * This mode's Favourites on its home. Reads only this mode's saved slugs from | ||
| * the account data already loaded for the app (nothing here writes, and no | ||
| * service or form registry is fetched). Hidden when there are none, while they | ||
| * load, and for a signed-out reader. | ||
| */ | ||
| export function ModeHomeFavouritesGroup({ | ||
| modeId, | ||
| favouriteType, | ||
| }: { | ||
| modeId: AppModeId; | ||
| favouriteType: "differentials" | "therapies"; | ||
| }) { | ||
| // While an account's favourites are loading (including straight after a switch | ||
| // of account), the previous account's list is still in memory: show nothing. | ||
| const { ready } = useAccountData(); | ||
| if (!ready) return null; | ||
|
qodo-code-review[bot] marked this conversation as resolved.
Resolved
|
||
| return favouriteType === "therapies" ? ( | ||
| <TherapyFavourites modeId={modeId} /> | ||
| ) : ( | ||
| <DifferentialFavourites modeId={modeId} /> | ||
| ); | ||
| } | ||
|
|
||
| /** Differential favourites are named from their slug, exactly as the Favourites page names them. */ | ||
| function DifferentialFavourites({ modeId }: { modeId: AppModeId }) { | ||
| const slugs = useAccountData().favourites.differential.slice(0, FAVOURITES_SHOWN); | ||
| const rows = slugs.map((slug) => ({ | ||
| slug, | ||
| title: slug | ||
| .split("-") | ||
| .filter(Boolean) | ||
| .map((word) => word[0]?.toUpperCase() + word.slice(1)) | ||
| .join(" "), | ||
| href: `/differentials/diagnoses/${encodeURIComponent(slug)}`, | ||
| })); | ||
| return <FavouritesRows modeId={modeId} rows={rows} />; | ||
| } | ||
|
|
||
| /** Therapy favourites take their names from the therapy catalogue, loaded only on the Therapy home and only when some are saved. */ | ||
| function TherapyFavourites({ modeId }: { modeId: AppModeId }) { | ||
| const saved = useAccountData().favourites.therapy; | ||
| const key = saved.slice(0, FAVOURITES_SHOWN).join("\u0000"); | ||
| const [loaded, setLoaded] = useState<{ key: string; rows: FavouriteRow[] }>({ key: "", rows: [] }); | ||
|
|
||
| useEffect(() => { | ||
| if (!key) return undefined; | ||
| let active = true; | ||
| void import("@/lib/therapies") | ||
| .then(({ findTherapyRecord }) => { | ||
| if (!active) return; | ||
| const rows = key.split("\u0000").flatMap((slug) => { | ||
| const therapy = findTherapyRecord(slug); | ||
| return therapy ? [{ slug, title: therapy.name, href: `/therapy-compass/${therapy.slug}` }] : []; | ||
| }); | ||
| setLoaded({ key, rows }); | ||
| }) | ||
| .catch(() => { | ||
| // The group stays hidden; the Favourites page still lists them. | ||
| }); | ||
| return () => { | ||
| active = false; | ||
| }; | ||
| }, [key]); | ||
|
|
||
| return <FavouritesRows modeId={modeId} rows={loaded.key === key ? loaded.rows : []} />; | ||
| } | ||
|
|
||
| function FavouritesRows({ modeId, rows }: { modeId: AppModeId; rows: readonly FavouriteRow[] }) { | ||
| if (rows.length === 0) return null; | ||
| return ( | ||
| <ModeHomeStartGroup id={`${modeId}-home-favourites`} title="Favourites" testId="mode-home-favourites"> | ||
| {rows.map((row) => ( | ||
| <ModeHomeStartRow key={row.slug} href={row.href} icon={appModeIcons[modeId]} title={row.title} /> | ||
| ))} | ||
| </ModeHomeStartGroup> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.