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