|
|
|
|
@ -12,7 +12,7 @@ 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 { asString, asStringArray, formatPatternTitle } from "../helpers/value";
|
|
|
|
|
import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query";
|
|
|
|
|
|
|
|
|
|
interface PatternData {
|
|
|
|
|
@ -73,7 +73,7 @@ const BURNER_CONFIGS: Array<{ key: string; title: string }> = [
|
|
|
|
|
// Embedded fallback patterns for guaranteed zero-latency / offline rendering
|
|
|
|
|
const FALLBACK_PATTERNS: Record<string, PatternData> = {
|
|
|
|
|
"wind_heat_in_the_lungs_defensive_qi_portion": {
|
|
|
|
|
name: "Wind-Heat in the Lungs’ Defensive Qi portion",
|
|
|
|
|
name: "Wind-Heat in the Lung's Defensive Qi portion",
|
|
|
|
|
clinicalManifestation:
|
|
|
|
|
"Fever, aversion to cold, headache, sore throat, slight sweating, runny nose with yellow discharge, swollen tonsils, body aches, slight thirst",
|
|
|
|
|
pathology:
|
|
|
|
|
@ -155,7 +155,9 @@ function extractBurnerList(data: Record<string, unknown>, burnerKey: string): st
|
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
|
|
|
const normK = normalizeKey(k);
|
|
|
|
|
if (normK === normTarget && Array.isArray(v)) {
|
|
|
|
|
return v.map((item) => asString(item).trim()).filter((item) => item.length > 0);
|
|
|
|
|
return v
|
|
|
|
|
.map((item) => formatPatternTitle(asString(item).trim()))
|
|
|
|
|
.filter((item) => item.length > 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return [];
|
|
|
|
|
@ -228,8 +230,9 @@ export function ThreeBurnersDetailRenderer({
|
|
|
|
|
const items = patternsQuery.data?.pages?.flatMap((p) => p.items) ?? [];
|
|
|
|
|
for (const it of items) {
|
|
|
|
|
const a = it.attributes as Record<string, unknown>;
|
|
|
|
|
const name = asString(a.name) || it.title;
|
|
|
|
|
if (!name) continue;
|
|
|
|
|
const rawName = asString(a.name) || it.title;
|
|
|
|
|
if (!rawName) continue;
|
|
|
|
|
const name = formatPatternTitle(rawName);
|
|
|
|
|
|
|
|
|
|
const clinicalRaw =
|
|
|
|
|
a["clinical menifestation"] ??
|
|
|
|
|
@ -285,7 +288,8 @@ export function ThreeBurnersDetailRenderer({
|
|
|
|
|
|
|
|
|
|
const activePatternData: PatternData | null = useMemo(() => {
|
|
|
|
|
if (isDirectLeafPattern) {
|
|
|
|
|
const name = asString(data.name) || content.title || "Three Burners Pattern";
|
|
|
|
|
const rawName = asString(data.name) || content.title || "Three Burners Pattern";
|
|
|
|
|
const name = formatPatternTitle(rawName);
|
|
|
|
|
const clinicalRaw =
|
|
|
|
|
data["clinical menifestation"] ??
|
|
|
|
|
data["clinical manifestation"] ??
|
|
|
|
|
@ -310,11 +314,16 @@ export function ThreeBurnersDetailRenderer({
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!selectedPatternName) return null;
|
|
|
|
|
return (
|
|
|
|
|
patternMap.get(normalizeKey(selectedPatternName)) || {
|
|
|
|
|
name: selectedPatternName,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
const found = patternMap.get(normalizeKey(selectedPatternName));
|
|
|
|
|
if (found) {
|
|
|
|
|
return {
|
|
|
|
|
...found,
|
|
|
|
|
name: formatPatternTitle(found.name),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
name: formatPatternTitle(selectedPatternName),
|
|
|
|
|
};
|
|
|
|
|
}, [isDirectLeafPattern, data, content.title, selectedPatternName, patternMap]);
|
|
|
|
|
|
|
|
|
|
// Connect drilldown navigation to the top-header back button
|
|
|
|
|
@ -415,25 +424,28 @@ export function ThreeBurnersDetailRenderer({
|
|
|
|
|
|
|
|
|
|
<View style={styles.patternsContainer}>
|
|
|
|
|
<Text style={styles.sectionHeading}>Patterns</Text>
|
|
|
|
|
{selectedBurner.patterns.map((patternName, idx) => (
|
|
|
|
|
<Pressable
|
|
|
|
|
key={patternName}
|
|
|
|
|
accessibilityRole="button"
|
|
|
|
|
accessibilityLabel={`Open ${patternName}`}
|
|
|
|
|
onPress={() => setSelectedPatternName(patternName)}
|
|
|
|
|
style={({ pressed }) => [styles.patternRow, pressed && styles.pressed]}
|
|
|
|
|
>
|
|
|
|
|
<View style={styles.numberBadge}>
|
|
|
|
|
<Text style={styles.numberText}>{idx + 1}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
{selectedBurner.patterns.map((patternName, idx) => {
|
|
|
|
|
const formattedTitle = formatPatternTitle(patternName);
|
|
|
|
|
return (
|
|
|
|
|
<Pressable
|
|
|
|
|
key={patternName}
|
|
|
|
|
accessibilityRole="button"
|
|
|
|
|
accessibilityLabel={`Open ${formattedTitle}`}
|
|
|
|
|
onPress={() => setSelectedPatternName(patternName)}
|
|
|
|
|
style={({ pressed }) => [styles.patternRow, pressed && styles.pressed]}
|
|
|
|
|
>
|
|
|
|
|
<View style={styles.numberBadge}>
|
|
|
|
|
<Text style={styles.numberText}>{idx + 1}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<View style={styles.patternTitleContainer}>
|
|
|
|
|
<Text style={styles.patternTitle}>{patternName}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
<View style={styles.patternTitleContainer}>
|
|
|
|
|
<Text style={styles.patternTitle}>{formattedTitle}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<Ionicons name="chevron-forward" size={20} color="#9CA3AF" />
|
|
|
|
|
</Pressable>
|
|
|
|
|
))}
|
|
|
|
|
<Ionicons name="chevron-forward" size={20} color="#9CA3AF" />
|
|
|
|
|
</Pressable>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
</ScrollView>
|
|
|
|
|
|