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