Merge pull request 'fix(renderers): correct apostrophe placement in Lung's for Three Burners patterns (issue #126)' (#128) from issue-126 into main
Reviewed-on: https://git.zedobject.local/AcuPedia/acupedia-mobile-ui/pulls/128
This commit is contained in:
commit
550de8025c
|
|
@ -4,7 +4,7 @@ import { Ionicons } from "@expo/vector-icons";
|
|||
import { moderateScale } from "react-native-size-matters";
|
||||
|
||||
import { Colors } from "@/theme";
|
||||
import { asNumber, asString } from "../helpers/value";
|
||||
import { asNumber, asString, formatPatternTitle } from "../helpers/value";
|
||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||
import type {
|
||||
CollectionItemRendererProps,
|
||||
|
|
@ -20,7 +20,8 @@ export function ThreeBurnersCardRenderer({
|
|||
onPress,
|
||||
}: CollectionItemRendererProps) {
|
||||
const a = item.attributes;
|
||||
const title = asString(a.name) || asString(a.title) || item.title;
|
||||
const rawTitle = asString(a.name) || asString(a.title) || item.title;
|
||||
const title = formatPatternTitle(rawTitle);
|
||||
const sortOrder = asNumber(a.sort_order);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -44,3 +44,13 @@ export function humanizeKey(value: string): string {
|
|||
.replace(/\b\w/g, (letter) => letter.toUpperCase())
|
||||
.replace(/(['’‘ʼ])s\b/gi, (match) => match[0] + "s");
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes pattern titles, correcting misplaced apostrophes in singular possessive organ names
|
||||
* (e.g. "Lungs’" / "Lungs'" / "Lunges'" -> "Lung's").
|
||||
*/
|
||||
export function formatPatternTitle(value: string): string {
|
||||
if (!value) return "";
|
||||
return value.replace(/\bLung(?:es|s)['’]/gi, "Lung's");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue