mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 22:50:51 +00:00
Revert "feat(topics): add the Topics preview area, its navigation entry and its switch"
This reverts commit c68e833dcc.
This commit is contained in:
1 parent
ce0c2a3f3f
commit
c1911e71e3
62 files changed
+212
-4313
No files matched your search
@@ -6,7 +6,6 @@ import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||
import { TileHeader } from "@/components/insights/tile-header";
|
||||
import { useFormatters, useTranslations } from "@/lib/i18n/context";
|
||||
|
||||
import { labTrendLines } from "./lab-trend-lines";
|
||||
import type { BiomarkerTrendDto } from "./types";
|
||||
|
||||
/**
|
||||
@@ -28,12 +27,44 @@ export function LabTrendCard({
|
||||
const fmt = useFormatters();
|
||||
if (!trend || trend.status !== "ok") return null;
|
||||
|
||||
const { slope: slopeLine, projection: projectionLine } = labTrendLines(
|
||||
trend,
|
||||
const digits = Math.abs(trend.slopePerYear) >= 10 ? 0 : 2;
|
||||
const per = (v: number) => fmt.number(Math.abs(v), digits);
|
||||
const direction =
|
||||
trend.slopePerYear > 0
|
||||
? "rising"
|
||||
: trend.slopePerYear < 0
|
||||
? "falling"
|
||||
: "flat";
|
||||
const slopeLine = t(`labs.trend.slope.${direction}`, {
|
||||
amount: per(trend.slopePerYear),
|
||||
unit,
|
||||
t,
|
||||
fmt,
|
||||
);
|
||||
n: trend.n,
|
||||
since: fmt.dateShortSmartCalendar(trend.firstAt),
|
||||
});
|
||||
const projectionLine =
|
||||
trend.projection === "exits" && trend.exitDate
|
||||
? t(`labs.trend.projection.exits.${trend.exitBound ?? "high"}`, {
|
||||
date: fmt.dateShortSmartCalendar(trend.exitDate),
|
||||
})
|
||||
: trend.projection === "no_band"
|
||||
? null
|
||||
: trend.projection === "stale"
|
||||
? t("labs.trend.projection.stale", {
|
||||
date: fmt.dateShortSmartCalendar(trend.lastAt),
|
||||
})
|
||||
: trend.projection === "beyond_horizon"
|
||||
? t(
|
||||
trend.horizonCapped
|
||||
? "labs.trend.projection.beyond_horizon_capped"
|
||||
: "labs.trend.projection.beyond_horizon",
|
||||
{
|
||||
years: fmt.number(
|
||||
trend.horizonYears,
|
||||
trend.horizonCapped ? 0 : 1,
|
||||
),
|
||||
},
|
||||
)
|
||||
: t(`labs.trend.projection.${trend.projection}`);
|
||||
|
||||
return (
|
||||
<Card data-slot="lab-trend">
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
import type { Formatters } from "@/lib/format-locale";
|
||||
|
||||
import type { BiomarkerTrendDto } from "./types";
|
||||
|
||||
type Translate = (
|
||||
key: string,
|
||||
params?: Record<string, string | number>,
|
||||
) => string;
|
||||
|
||||
/**
|
||||
* The two sentences a lab trend reads as: the slope across the readings, and
|
||||
* where the straight line would meet the reference band (or why it is not
|
||||
* drawn). Shared by the marker page's trend card and the metabolism topic, so
|
||||
* one trend is never worded two ways.
|
||||
*/
|
||||
export function labTrendLines(
|
||||
trend: Extract<BiomarkerTrendDto, { status: "ok" }>,
|
||||
unit: string,
|
||||
t: Translate,
|
||||
fmt: Formatters,
|
||||
): { slope: string; projection: string | null } {
|
||||
const digits = Math.abs(trend.slopePerYear) >= 10 ? 0 : 2;
|
||||
const direction =
|
||||
trend.slopePerYear > 0
|
||||
? "rising"
|
||||
: trend.slopePerYear < 0
|
||||
? "falling"
|
||||
: "flat";
|
||||
const slope = t(`labs.trend.slope.${direction}`, {
|
||||
amount: fmt.number(Math.abs(trend.slopePerYear), digits),
|
||||
unit,
|
||||
n: trend.n,
|
||||
since: fmt.dateShortSmartCalendar(trend.firstAt),
|
||||
});
|
||||
const projection =
|
||||
trend.projection === "exits" && trend.exitDate
|
||||
? t(`labs.trend.projection.exits.${trend.exitBound ?? "high"}`, {
|
||||
date: fmt.dateShortSmartCalendar(trend.exitDate),
|
||||
})
|
||||
: trend.projection === "no_band"
|
||||
? null
|
||||
: trend.projection === "stale"
|
||||
? t("labs.trend.projection.stale", {
|
||||
date: fmt.dateShortSmartCalendar(trend.lastAt),
|
||||
})
|
||||
: trend.projection === "beyond_horizon"
|
||||
? t(
|
||||
trend.horizonCapped
|
||||
? "labs.trend.projection.beyond_horizon_capped"
|
||||
: "labs.trend.projection.beyond_horizon",
|
||||
{
|
||||
years: fmt.number(
|
||||
trend.horizonYears,
|
||||
trend.horizonCapped ? 0 : 1,
|
||||
),
|
||||
},
|
||||
)
|
||||
: t(`labs.trend.projection.${trend.projection}`);
|
||||
return { slope, projection };
|
||||
}
|
||||
Reference in new issue
Block a user