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