From 98d0e49597d8dca0c82949292fe6df6f0b073995 Mon Sep 17 00:00:00 2001 From: ShivaniKhaire Date: Wed, 21 Oct 2026 14:12:35 +0530 Subject: [PATCH] three burners clinical menifestation fix --- .../details/ThreeBurnersDetailRenderer.tsx | 72 +++++++++++++++---- 1 file changed, 57 insertions(+), 15 deletions(-) diff --git a/src/features/content/renderers/details/ThreeBurnersDetailRenderer.tsx b/src/features/content/renderers/details/ThreeBurnersDetailRenderer.tsx index ccb3248..76aa34c 100644 --- a/src/features/content/renderers/details/ThreeBurnersDetailRenderer.tsx +++ b/src/features/content/renderers/details/ThreeBurnersDetailRenderer.tsx @@ -9,17 +9,49 @@ import { BackActionContext } from "../../context/BackActionContext"; import { Hero } from "../shared/Hero"; import { SectionCard } from "../shared/SectionCard"; import { Paragraphs } from "../shared/Paragraphs"; -import { asString } from "../helpers/value"; +import { BulletList } from "../shared/BulletList"; +import { asString, asStringArray } from "../helpers/value"; import { useContentSearchInfiniteQuery } from "../../hooks/use-content-search-infinite-query"; interface PatternData { name: string; code?: string; - clinicalManifestation?: string; + clinicalManifestation?: string[]; pathology?: string; treatment?: string; } +function parseBullets(raw: unknown): string[] { + if (Array.isArray(raw)) { + return asStringArray(raw); + } + const text = asString(raw).trim(); + if (!text) return []; + + if (text.includes("\n")) { + return text + .split("\n") + .map((s) => s.replace(/^[•\-\*\d+\.]\s*/, "").trim()) + .filter((s) => s.length > 0); + } + + if (text.includes(";")) { + return text + .split(";") + .map((s) => s.trim().replace(/^and\s+/i, "")) + .filter((s) => s.length > 0); + } + + const parts = text.split(/,\s*(?![^()]*\))/); + if (parts.length > 1) { + return parts + .map((s) => s.trim().replace(/\.$/, "").replace(/^and\s+/i, "")) + .filter((s) => s.length > 0); + } + + return [text]; +} + interface BurnerCategory { key: string; title: string; @@ -183,7 +215,10 @@ export function ThreeBurnersDetailRenderer({ // 1. Seed fallback patterns for (const p of Object.values(FALLBACK_PATTERNS)) { - map.set(normalizeKey(p.name), p); + map.set(normalizeKey(p.name), { + ...p, + clinicalManifestation: parseBullets(p.clinicalManifestation), + }); } // 2. Hydrate from live search query @@ -193,19 +228,20 @@ export function ThreeBurnersDetailRenderer({ const name = asString(a.name) || it.title; if (!name) continue; - const clinical = - asString(a["clinical menifestation"]) || - asString(a["clinical manifestation"]) || - asString(a.clinical_manifestations) || - asString(a.clinical_manifestation); + const clinicalRaw = + a["clinical menifestation"] ?? + a["clinical manifestation"] ?? + a.clinical_manifestations ?? + a.clinical_manifestation; + const clinical = parseBullets(clinicalRaw); const pathology = asString(a.pathology); const treatment = asString(a.treatment); map.set(normalizeKey(name), { name, code: asString(a.code) || undefined, - clinicalManifestation: clinical || undefined, + clinicalManifestation: clinical.length > 0 ? clinical : undefined, pathology: pathology || undefined, treatment: treatment || undefined, }); @@ -241,13 +277,18 @@ export function ThreeBurnersDetailRenderer({ const activePatternData: PatternData | null = useMemo(() => { if (isDirectLeafPattern) { const name = asString(data.name) || content.title || "Three Burners Pattern"; + const clinicalRaw = + data["clinical menifestation"] ?? + data["clinical manifestation"] ?? + data.clinical_manifestations ?? + data.clinical_manifestation; + + const clinical = parseBullets(clinicalRaw); + return { name, code: asString(data.code) || undefined, - clinicalManifestation: - asString(data["clinical menifestation"]) || - asString(data["clinical manifestation"]) || - asString(data.clinical_manifestations), + clinicalManifestation: clinical.length > 0 ? clinical : undefined, pathology: asString(data.pathology) || undefined, treatment: asString(data.treatment) || undefined, }; @@ -294,9 +335,10 @@ export function ThreeBurnersDetailRenderer({ {/* 1. Clinical Manifestations Card */} - {activePatternData.clinicalManifestation ? ( + {activePatternData.clinicalManifestation && + activePatternData.clinicalManifestation.length > 0 ? ( - + ) : null}