Compare commits
No commits in common. "042c1cff3606e09359fd87d587fa2bef0198cf7a" and "4145375926ca926156a6a2d503fa3c40c161634f" have entirely different histories.
042c1cff36
...
4145375926
|
|
@ -8,15 +8,7 @@ import { Hero } from "./shared/Hero";
|
|||
import { ImageGallery } from "./shared/ImageGallery";
|
||||
import { SectionCard } from "./shared/SectionCard";
|
||||
|
||||
const RESERVED_KEYS = new Set([
|
||||
"code",
|
||||
"id",
|
||||
"slug",
|
||||
"sort_order",
|
||||
"link",
|
||||
"food_name",
|
||||
"foodname",
|
||||
]);
|
||||
const RESERVED_KEYS = new Set(["code", "id", "slug", "sort_order", "link"]);
|
||||
|
||||
/**
|
||||
* Generic detail renderer for modules and catalog items.
|
||||
|
|
@ -44,10 +36,6 @@ export function GenericDetailRenderer({
|
|||
[definitions],
|
||||
);
|
||||
|
||||
const heroTitle = humanizeKey(
|
||||
content.title || (typeof data.food_name === "string" ? data.food_name : "") || "Untitled content",
|
||||
);
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
contentContainerStyle={{
|
||||
|
|
@ -59,14 +47,14 @@ export function GenericDetailRenderer({
|
|||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Hero
|
||||
title={heroTitle}
|
||||
title={content.title || "Untitled content"}
|
||||
subtitle={content.summary ?? undefined}
|
||||
/>
|
||||
<ImageGallery images={[]} />
|
||||
{Object.entries(data)
|
||||
.filter(
|
||||
([key]) =>
|
||||
!RESERVED_KEYS.has(key.toLowerCase()) &&
|
||||
!RESERVED_KEYS.has(key) &&
|
||||
!(isTherapeutic && key.toLowerCase() === "name"),
|
||||
)
|
||||
.map(([key, value]) => {
|
||||
|
|
|
|||
|
|
@ -54,10 +54,7 @@ export function PatternAccordionCardRenderer({
|
|||
const router = useRouter();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const attributes = item.attributes;
|
||||
const rawTitle =
|
||||
asString(attributes.food_name) ||
|
||||
asString(attributes.name) ||
|
||||
item.title;
|
||||
const rawTitle = asString(attributes.name) || item.title;
|
||||
const title = humanizeKey(rawTitle);
|
||||
|
||||
const link = attributes?.link as Record<string, unknown> | undefined;
|
||||
|
|
@ -346,13 +343,10 @@ export function ModuleCatalogCardRenderer({
|
|||
|
||||
// If this item points to a pattern content item, render inline accordion
|
||||
if (isContentRef) {
|
||||
return <PatternAccordionCardRenderer item={item} onPress={onPress} />;
|
||||
return <PatternAccordionCardRenderer item={item} />;
|
||||
}
|
||||
|
||||
const rawTitle =
|
||||
asString(attributes.food_name) ||
|
||||
asString(attributes.name) ||
|
||||
item.title;
|
||||
const rawTitle = asString(attributes.name) || item.title;
|
||||
const parenMatch = rawTitle.match(/^(.*?)\s*\(([^()]+)\)\s*(.*?)$/);
|
||||
const title = parenMatch
|
||||
? [parenMatch[1], parenMatch[3]].filter(Boolean).join(" ").trim()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export function asString(value: unknown): string {
|
|||
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
||||
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
||||
const record = value as Record<string, unknown>;
|
||||
for (const key of ["label", "point_name", "food_name", "name", "title", "code"]) {
|
||||
for (const key of ["label", "point_name", "name", "title", "code"]) {
|
||||
if (typeof record[key] === "string" && (record[key] as string).trim().length > 0) {
|
||||
return (record[key] as string).trim();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import { DetailPageShell } from "../renderers/shared/DetailPageShell";
|
|||
import { applyPresentationContractToData } from "../utils/attribute-presentation";
|
||||
import { BackActionContext } from "../context/BackActionContext";
|
||||
import { PageToneProvider, type PageTone } from "../context/PageToneContext";
|
||||
import { humanizeKey } from "../renderers/helpers/value";
|
||||
|
||||
export interface ContentDetailScreenProps {
|
||||
moduleCode: string;
|
||||
|
|
@ -99,11 +98,9 @@ function ContentDetailScreenResolved({
|
|||
const presentationAttributes = screen.contractQuery.data?.presentation.attributes ?? [];
|
||||
const presentedData = applyPresentationContractToData(response.data, presentationAttributes);
|
||||
|
||||
const foodName = typeof response.data.food_name === "string" ? response.data.food_name.trim() : "";
|
||||
const pointName = typeof response.data.point_name === "string" ? response.data.point_name.trim() : "";
|
||||
const name = typeof response.data.name === "string" ? response.data.name.trim() : "";
|
||||
const rawTitle = foodName || pointName || name || response.content.title;
|
||||
const displayTitle = humanizeKey(rawTitle);
|
||||
const displayTitle = pointName || name || response.content.title;
|
||||
const alternateNames = [response.data.alt_name_1, response.data.alt_name_2]
|
||||
.filter((value): value is string => typeof value === "string" && value.trim().length > 0)
|
||||
.map((value) => value.trim())
|
||||
|
|
@ -136,7 +133,7 @@ function ContentDetailScreenResolved({
|
|||
contentId={response.content.id}
|
||||
content={{
|
||||
id: response.content.id,
|
||||
title: displayTitle,
|
||||
title: response.content.title,
|
||||
slug: response.content.slug,
|
||||
summary: response.content.summary,
|
||||
}}
|
||||
|
|
@ -150,12 +147,12 @@ function ContentDetailScreenResolved({
|
|||
moduleCode={moduleCode}
|
||||
templateCode={templateCode}
|
||||
contentId={response.content.id}
|
||||
content={{
|
||||
id: response.content.id,
|
||||
title: displayTitle,
|
||||
slug: response.content.slug,
|
||||
summary: response.content.summary,
|
||||
}}
|
||||
content={{
|
||||
id: response.content.id,
|
||||
title: response.content.title,
|
||||
slug: response.content.slug,
|
||||
summary: response.content.summary,
|
||||
}}
|
||||
data={presentedData}
|
||||
definitions={screen.definitionsQuery.data?.attributes ?? []}
|
||||
presentationAttributes={presentationAttributes}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,6 @@ const MODULE_VISUALS: Record<string, ModuleVisualConfig> = {
|
|||
color: "#10B981",
|
||||
isDefaultFree: true,
|
||||
planCode: "NUTRITION_CORE",
|
||||
entryTemplateCode: "m0031_ct0002",
|
||||
},
|
||||
m0041: {
|
||||
icon: "body-outline",
|
||||
|
|
|
|||
Loading…
Reference in New Issue