feat(renderers): render structured treatment point references as chips in pattern details
This commit is contained in:
parent
91ae140c9f
commit
27e62f99db
|
|
@ -13,6 +13,7 @@ import {
|
|||
import { asRecord, asString, asStringArray } from "../helpers/value";
|
||||
import { BulletList } from "../shared/BulletList";
|
||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { Paragraphs } from "../shared/Paragraphs";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
|
|
@ -236,9 +237,11 @@ export function FourLevelsDetailRenderer({
|
|||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
{treatment ? (
|
||||
{data.treatment ? (
|
||||
<SectionCard title="Treatment">
|
||||
{treatmentBullets.length > 0 ? (
|
||||
{typeof data.treatment === "object" ? (
|
||||
<ContentValue value={data.treatment} />
|
||||
) : treatmentBullets.length > 0 ? (
|
||||
<BulletList items={treatmentBullets} />
|
||||
) : (
|
||||
<Paragraphs items={[treatment]} />
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { Hero } from "../shared/Hero";
|
|||
import { SectionCard } from "../shared/SectionCard";
|
||||
import { Paragraphs } from "../shared/Paragraphs";
|
||||
import { BulletList } from "../shared/BulletList";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { asString, asStringArray } from "../helpers/value";
|
||||
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
||||
|
||||
|
|
@ -19,7 +20,7 @@ interface PatternData {
|
|||
clinicalManifestation?: string | string[];
|
||||
pathology?: string;
|
||||
treatmentPrinciple?: string | string[];
|
||||
treatment?: string;
|
||||
treatment?: unknown;
|
||||
}
|
||||
|
||||
function parseBullets(raw: unknown): string[] {
|
||||
|
|
@ -242,7 +243,7 @@ export function ThreeBurnersDetailRenderer({
|
|||
a["treatment principle"] ??
|
||||
a.treatmentPrinciple;
|
||||
const treatmentPrinciple = parseBullets(treatmentPrincipleRaw);
|
||||
const treatment = asString(a.treatment);
|
||||
const treatment = a.treatment ?? a["treatment"];
|
||||
|
||||
map.set(normalizeKey(name), {
|
||||
name,
|
||||
|
|
@ -250,7 +251,7 @@ export function ThreeBurnersDetailRenderer({
|
|||
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
|
||||
pathology: pathology || undefined,
|
||||
treatmentPrinciple: treatmentPrinciple.length > 0 ? treatmentPrinciple : undefined,
|
||||
treatment: treatment || undefined,
|
||||
treatment: treatment ?? undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -303,7 +304,7 @@ export function ThreeBurnersDetailRenderer({
|
|||
clinicalManifestation: clinical.length > 0 ? clinical : undefined,
|
||||
pathology: asString(data.pathology) || undefined,
|
||||
treatmentPrinciple: treatmentPrinciple.length > 0 ? treatmentPrinciple : undefined,
|
||||
treatment: asString(data.treatment) || undefined,
|
||||
treatment: data.treatment ?? undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -336,9 +337,11 @@ export function ThreeBurnersDetailRenderer({
|
|||
// SCREEN 3: Pattern Leaf Detail Screen
|
||||
// ----------------------------------------------------
|
||||
if (activePatternData && (selectedPatternName || isDirectLeafPattern)) {
|
||||
const { principles, acupuncture } = parseTreatment(
|
||||
activePatternData.treatment || "",
|
||||
);
|
||||
const treatmentRaw = activePatternData.treatment;
|
||||
const { principles, acupuncture } =
|
||||
typeof treatmentRaw === "string"
|
||||
? parseTreatment(treatmentRaw)
|
||||
: { principles: [], acupuncture: [] };
|
||||
|
||||
const rawPrinciples =
|
||||
activePatternData.treatmentPrinciple &&
|
||||
|
|
@ -349,11 +352,6 @@ export function ThreeBurnersDetailRenderer({
|
|||
const allPrinciples =
|
||||
rawPrinciples && rawPrinciples.length > 0 ? rawPrinciples : principles;
|
||||
|
||||
const treatmentText =
|
||||
acupuncture.length > 0
|
||||
? acupuncture.join("\n")
|
||||
: activePatternData.treatment;
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
contentContainerStyle={styles.container}
|
||||
|
|
@ -389,9 +387,13 @@ export function ThreeBurnersDetailRenderer({
|
|||
) : null}
|
||||
|
||||
{/* 4. Treatment Card */}
|
||||
{treatmentText ? (
|
||||
{treatmentRaw ? (
|
||||
<SectionCard title="Treatment">
|
||||
<Paragraphs items={[treatmentText]} />
|
||||
{typeof treatmentRaw === "object" ? (
|
||||
<ContentValue value={treatmentRaw} />
|
||||
) : (
|
||||
<Paragraphs items={[acupuncture.length > 0 ? acupuncture.join("\n") : String(treatmentRaw)]} />
|
||||
)}
|
||||
</SectionCard>
|
||||
) : null}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import { ContentLink } from "../../components/navigation/ContentLink";
|
|||
import { parseNavigableContentReference } from "../../utils/content-reference";
|
||||
import { humanizeKey } from "../helpers/value";
|
||||
import { BulletList } from "./BulletList";
|
||||
import { ReferenceChipList } from "./ReferenceChipList";
|
||||
|
||||
export interface ContentValueProps {
|
||||
value: unknown;
|
||||
|
|
@ -81,6 +82,10 @@ export function ContentValue({
|
|||
return <BulletList items={visible as string[]} />;
|
||||
}
|
||||
|
||||
if (visible.some((item) => parseNavigableContentReference(item) !== null)) {
|
||||
return <ReferenceChipList value={visible} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<View style={styles.stack}>
|
||||
{visible.map((item, index) => (
|
||||
|
|
|
|||
Loading…
Reference in New Issue