Added ear acupuncture ui
This commit is contained in:
parent
686a739541
commit
ab80c0a319
|
|
@ -66,6 +66,35 @@ export default function TabsLayout() {
|
|||
}}
|
||||
/>
|
||||
|
||||
|
||||
<Tabs.Screen
|
||||
name="library"
|
||||
options={{
|
||||
title: "Library",
|
||||
tabBarIcon: ({ color, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? "library" : "library-outline"}
|
||||
size={22}
|
||||
color={color}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
||||
<Tabs.Screen
|
||||
name="profile"
|
||||
options={{
|
||||
title: "Profile",
|
||||
tabBarIcon: ({ color, focused }) => (
|
||||
<Ionicons
|
||||
name={focused ? "person" : "person-outline"}
|
||||
size={22}
|
||||
color={color}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
||||
<Tabs.Screen
|
||||
name="auth-action"
|
||||
options={{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
import React from "react";
|
||||
|
||||
import { asNumber, asString } from "../helpers/value";
|
||||
import { CollectionScaffold } from "../shared/CollectionScaffold";
|
||||
import { StandardIndexCard } from "../shared/StandardIndexCard";
|
||||
import type {
|
||||
CollectionItemRendererProps,
|
||||
CollectionRendererProps,
|
||||
} from "../../types/renderer.types";
|
||||
|
||||
/**
|
||||
* Shared collection shell for the Ear Acupuncture catalogue templates.
|
||||
*
|
||||
* CT0001 is the module catalogue/index. CT0002-CT0007 are point-category
|
||||
* lists. The renderer intentionally derives its visible values from the API
|
||||
* attributes instead of template codes so the same presentation renderer can
|
||||
* be reused by every catalogue template that declares it.
|
||||
*/
|
||||
export function EarAcupunctureCatalogCollectionRenderer(
|
||||
props: CollectionRendererProps,
|
||||
) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
|
||||
export function EarAcupunctureCatalogCardRenderer({
|
||||
item,
|
||||
onPress,
|
||||
}: CollectionItemRendererProps) {
|
||||
const attributes = item.attributes;
|
||||
const name = asString(attributes.name).trim();
|
||||
const point = asString(attributes.point).trim();
|
||||
const title = name || point || item.title;
|
||||
|
||||
const contentCount = asNumber(attributes.content_count);
|
||||
const contentLabel = asString(attributes.content_label).trim();
|
||||
|
||||
return (
|
||||
<StandardIndexCard
|
||||
title={title}
|
||||
subtitle={item.summary || null}
|
||||
count={contentCount}
|
||||
countLabel={contentLabel || null}
|
||||
onPress={onPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Shared collection shell for concrete Ear Acupuncture points (CT0011). */
|
||||
export function EarAcupunctureCollectionRenderer(props: CollectionRendererProps) {
|
||||
return <CollectionScaffold {...props} />;
|
||||
}
|
||||
|
||||
export function EarAcupunctureCardRenderer({
|
||||
item,
|
||||
onPress,
|
||||
}: CollectionItemRendererProps) {
|
||||
const attributes = item.attributes;
|
||||
const point = asString(attributes.point).trim() || item.title;
|
||||
const category = asString(attributes.category).trim();
|
||||
const subCategory = asString(attributes.sub_category).trim();
|
||||
const subtitle = [category, subCategory].filter(Boolean).join(" · ");
|
||||
|
||||
return (
|
||||
<StandardIndexCard
|
||||
title={point}
|
||||
subtitle={subtitle || item.summary || null}
|
||||
onPress={onPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
import React, { useMemo } from "react";
|
||||
import { ScrollView } from "react-native";
|
||||
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import {
|
||||
bareAttributeKey,
|
||||
findAttributePresentationRule,
|
||||
getEmptyDisplayText,
|
||||
presentationDisplayOrder,
|
||||
shouldRenderAttribute,
|
||||
} from "../../utils/attribute-presentation";
|
||||
import { asString, humanizeKey } from "../helpers/value";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { ImageGallery } from "../shared/ImageGallery";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
|
||||
const RESERVED_KEYS = new Set(["name", "point", "code", "sort_order", "link"]);
|
||||
|
||||
/**
|
||||
* Detail renderer for CT0001-CT0007 catalogue/index entries.
|
||||
*
|
||||
* Normally catalogue rows navigate through their hydrated `link` reference and
|
||||
* never open a detail page. This renderer is still fully implemented because
|
||||
* the presentation contract declares it and it is also a safe fallback when a
|
||||
* row has no navigable reference.
|
||||
*/
|
||||
export function EarAcupunctureCatalogDetailRenderer({
|
||||
content,
|
||||
data,
|
||||
definitions,
|
||||
presentationAttributes,
|
||||
}: DetailRendererProps) {
|
||||
const title = asString(data.name).trim() || asString(data.point).trim() || content.title;
|
||||
|
||||
const attributes = useMemo(() => {
|
||||
const roots = definitions.filter((definition) => definition.is_root);
|
||||
const contractIndex = new Map(
|
||||
presentationAttributes.map((rule, index) => [rule.attribute_key, index]),
|
||||
);
|
||||
|
||||
const definitionByKey = new Map(
|
||||
roots.map((definition) => [
|
||||
definition.code || bareAttributeKey(definition.attribute_key),
|
||||
definition,
|
||||
]),
|
||||
);
|
||||
|
||||
const keys = new Set<string>();
|
||||
for (const definition of roots) {
|
||||
keys.add(definition.code || bareAttributeKey(definition.attribute_key));
|
||||
}
|
||||
for (const key of Object.keys(data)) keys.add(key);
|
||||
|
||||
return [...keys]
|
||||
.flatMap((key) => {
|
||||
if (!key || RESERVED_KEYS.has(key)) return [];
|
||||
|
||||
const value = data[key];
|
||||
const definition = definitionByKey.get(key);
|
||||
const rule = findAttributePresentationRule(
|
||||
definition?.attribute_key ?? key,
|
||||
presentationAttributes,
|
||||
);
|
||||
if (!shouldRenderAttribute(value, rule)) return [];
|
||||
|
||||
return [{
|
||||
key,
|
||||
label: definition?.label?.trim() || humanizeKey(key),
|
||||
value,
|
||||
emptyText: getEmptyDisplayText(value, rule),
|
||||
order: presentationDisplayOrder(
|
||||
rule,
|
||||
definition?.sort_order,
|
||||
rule ? contractIndex.get(rule.attribute_key) : undefined,
|
||||
),
|
||||
}];
|
||||
})
|
||||
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
|
||||
}, [data, definitions, presentationAttributes]);
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 18,
|
||||
paddingTop: 16,
|
||||
paddingBottom: 40,
|
||||
gap: 14,
|
||||
}}
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Hero title={title} subtitle={content.summary ?? undefined} />
|
||||
<ImageGallery images={[]} />
|
||||
|
||||
{attributes.map((attribute) => (
|
||||
<SectionCard key={attribute.key} title={attribute.label}>
|
||||
<ContentValue
|
||||
value={attribute.value}
|
||||
emptyText={attribute.emptyText ?? undefined}
|
||||
/>
|
||||
</SectionCard>
|
||||
))}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
import React, { useMemo } from "react";
|
||||
import { ScrollView, Text } from "react-native";
|
||||
|
||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||
import {
|
||||
bareAttributeKey,
|
||||
findAttributePresentationRule,
|
||||
getEmptyDisplayText,
|
||||
presentationDisplayOrder,
|
||||
shouldRenderAttribute,
|
||||
} from "../../utils/attribute-presentation";
|
||||
import { asString, humanizeKey } from "../helpers/value";
|
||||
import { ContentValue } from "../shared/ContentValue";
|
||||
import { Hero } from "../shared/Hero";
|
||||
import { ImageGallery } from "../shared/ImageGallery";
|
||||
import { SectionCard } from "../shared/SectionCard";
|
||||
|
||||
const RESERVED_KEYS = new Set([
|
||||
"point",
|
||||
"category",
|
||||
"sub_category",
|
||||
"code",
|
||||
"sort_order",
|
||||
"link",
|
||||
]);
|
||||
|
||||
/** Semantic detail renderer for M0002_CT0011 Ear Acupuncture points. */
|
||||
export function EarAcupunctureDetailRenderer({
|
||||
content,
|
||||
data,
|
||||
definitions,
|
||||
presentationAttributes,
|
||||
}: DetailRendererProps) {
|
||||
const point = asString(data.point).trim() || content.title;
|
||||
const category = asString(data.category).trim();
|
||||
const subCategory = asString(data.sub_category).trim();
|
||||
const subtitle = [category, subCategory].filter(Boolean).join(" · ");
|
||||
|
||||
const attributes = useMemo(() => {
|
||||
const roots = definitions.filter((definition) => definition.is_root);
|
||||
const contractIndex = new Map(
|
||||
presentationAttributes.map((rule, index) => [rule.attribute_key, index]),
|
||||
);
|
||||
const definitionByKey = new Map(
|
||||
roots.map((definition) => [
|
||||
definition.code || bareAttributeKey(definition.attribute_key),
|
||||
definition,
|
||||
]),
|
||||
);
|
||||
|
||||
const keys = new Set<string>();
|
||||
for (const definition of roots) {
|
||||
keys.add(definition.code || bareAttributeKey(definition.attribute_key));
|
||||
}
|
||||
for (const rule of presentationAttributes) {
|
||||
const key = bareAttributeKey(rule.attribute_key);
|
||||
if (Object.prototype.hasOwnProperty.call(data, key)) keys.add(key);
|
||||
}
|
||||
for (const key of Object.keys(data)) keys.add(key);
|
||||
|
||||
return [...keys]
|
||||
.flatMap((key) => {
|
||||
if (!key || RESERVED_KEYS.has(key)) return [];
|
||||
|
||||
const value = data[key];
|
||||
const definition = definitionByKey.get(key);
|
||||
const rule = findAttributePresentationRule(
|
||||
definition?.attribute_key ?? key,
|
||||
presentationAttributes,
|
||||
);
|
||||
if (!shouldRenderAttribute(value, rule)) return [];
|
||||
|
||||
return [{
|
||||
key,
|
||||
label: definition?.label?.trim() || humanizeKey(key),
|
||||
value,
|
||||
emptyText: getEmptyDisplayText(value, rule),
|
||||
order: presentationDisplayOrder(
|
||||
rule,
|
||||
definition?.sort_order,
|
||||
rule ? contractIndex.get(rule.attribute_key) : undefined,
|
||||
),
|
||||
}];
|
||||
})
|
||||
.sort((a, b) => a.order - b.order || a.label.localeCompare(b.label));
|
||||
}, [data, definitions, presentationAttributes]);
|
||||
|
||||
return (
|
||||
<ScrollView
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: 18,
|
||||
paddingTop: 16,
|
||||
paddingBottom: 40,
|
||||
gap: 14,
|
||||
}}
|
||||
showsVerticalScrollIndicator={false}
|
||||
>
|
||||
<Hero title={point} subtitle={subtitle || content.summary || undefined} />
|
||||
<ImageGallery images={[]} />
|
||||
|
||||
{attributes.map((attribute) => (
|
||||
<SectionCard key={attribute.key} title={attribute.label}>
|
||||
{typeof attribute.value === "string" ? (
|
||||
<Text style={{ fontSize: 16, lineHeight: 25, color: "#334155" }}>
|
||||
{attribute.value}
|
||||
</Text>
|
||||
) : (
|
||||
<ContentValue
|
||||
value={attribute.value}
|
||||
emptyText={attribute.emptyText ?? undefined}
|
||||
/>
|
||||
)}
|
||||
</SectionCard>
|
||||
))}
|
||||
</ScrollView>
|
||||
);
|
||||
}
|
||||
|
|
@ -24,6 +24,9 @@ import { FourSeasDetailRenderer } from "./details/FourSeasDetailRenderer";
|
|||
import { GhostPointsDetailRenderer } from "./details/GhostPointsDetailRenderer";
|
||||
import { EntryExitPointsDetailRenderer } from "./details/EntryExitPointsDetailRenderer";
|
||||
import { ReturningYangDetailRenderer } from "./details/ReturningYangDetailRenderer";
|
||||
import { EarAcupunctureCatalogCollectionRenderer, EarAcupunctureCatalogCardRenderer, EarAcupunctureCollectionRenderer, EarAcupunctureCardRenderer } from "./collections/EarAcupunctureRenderers";
|
||||
import { EarAcupunctureCatalogDetailRenderer } from "./details/EarAcupunctureCatalogDetailRenderer";
|
||||
import { EarAcupunctureDetailRenderer } from "./details/EarAcupunctureDetailRenderer";
|
||||
|
||||
export const collectionRenderers: Readonly<Record<string, CollectionRendererComponent>> = Object.freeze({
|
||||
module_catalog_collection: ModuleCatalogCollectionRenderer,
|
||||
|
|
@ -34,6 +37,8 @@ export const collectionRenderers: Readonly<Record<string, CollectionRendererComp
|
|||
eov_index_collection: EovIndexCollectionRenderer,
|
||||
eov_collection: EovCollectionRenderer,
|
||||
point_category_index_collection: PointCategoryIndexCollectionRenderer,
|
||||
ear_acupuncture_catalog_collection: EarAcupunctureCatalogCollectionRenderer,
|
||||
ear_acupuncture_collection: EarAcupunctureCollectionRenderer,
|
||||
});
|
||||
export const collectionItemRenderers: Readonly<Record<string, CollectionItemRendererComponent>> = Object.freeze({
|
||||
module_catalog_card: ModuleCatalogCardRenderer,
|
||||
|
|
@ -44,6 +49,8 @@ export const collectionItemRenderers: Readonly<Record<string, CollectionItemRend
|
|||
eov_index_card: EovIndexCardRenderer,
|
||||
eov_card: EovCardRenderer,
|
||||
point_category_index_card: PointCategoryIndexCardRenderer,
|
||||
ear_acupuncture_catalog_card: EarAcupunctureCatalogCardRenderer,
|
||||
ear_acupuncture_card: EarAcupunctureCardRenderer,
|
||||
});
|
||||
export const detailRenderers: Readonly<Record<string, DetailRendererComponent>> = Object.freeze({
|
||||
module_catalog_detail: IndexEntryDetailRenderer,
|
||||
|
|
@ -70,6 +77,8 @@ export const detailRenderers: Readonly<Record<string, DetailRendererComponent>>
|
|||
ghost_points_detail: GhostPointsDetailRenderer,
|
||||
entry_exit_points_detail: EntryExitPointsDetailRenderer,
|
||||
returning_yang_detail: ReturningYangDetailRenderer,
|
||||
ear_acupuncture_catalog_detail: EarAcupunctureCatalogDetailRenderer,
|
||||
ear_acupuncture_detail: EarAcupunctureDetailRenderer,
|
||||
});
|
||||
export function resolveCollectionRenderer(code:string):CollectionRendererComponent { const r=collectionRenderers[code]; if(!r) throw new Error(`Unknown collection renderer: ${code}`); return r; }
|
||||
export function resolveCollectionItemRenderer(code:string):CollectionItemRendererComponent { const r=collectionItemRenderers[code]; if(!r) throw new Error(`Unknown collection item renderer: ${code}`); return r; }
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
import type { ModuleResponse } from "@/features/content/types/content.types";
|
||||
import type { TemplateReference } from "@/features/content/types/content-reference.types";
|
||||
|
||||
/**
|
||||
* Client-only fallbacks for presentation and commerce values that are not yet
|
||||
* guaranteed by the modules API. Business/content metadata such as module
|
||||
* name, description and category must come from the API response.
|
||||
*/
|
||||
export interface ModuleVisualConfig {
|
||||
title?: string;
|
||||
description?: string;
|
||||
icon: string;
|
||||
color: string;
|
||||
category: string;
|
||||
isDefaultFree: boolean;
|
||||
planCode: string;
|
||||
entryTemplateCode?: string;
|
||||
|
|
@ -26,147 +28,99 @@ export interface ModuleIndexItem {
|
|||
|
||||
const MODULE_VISUALS: Record<string, ModuleVisualConfig> = {
|
||||
M0001: {
|
||||
title: "Acupuncture",
|
||||
description: "All points, locations, indications & more",
|
||||
icon: "water-outline",
|
||||
color: "#2563EB",
|
||||
category: "point",
|
||||
isDefaultFree: true,
|
||||
planCode: "POINTS_ACU",
|
||||
entryTemplateCode: "M0001_CT0001",
|
||||
},
|
||||
M0002: {
|
||||
title: "Ear-acupuncture",
|
||||
description: "Ear Points & Point Category",
|
||||
icon: "ear-outline",
|
||||
color: "#F59E0B",
|
||||
category: "point",
|
||||
isDefaultFree: false,
|
||||
planCode: "POINTS_EAR",
|
||||
},
|
||||
M0003: {
|
||||
title: "Scalp acupuncture",
|
||||
description: "Scalp zones, points & protocols",
|
||||
icon: "accessibility-outline",
|
||||
color: "#EF4444",
|
||||
category: "point",
|
||||
isDefaultFree: false,
|
||||
planCode: "POINTS_SCALP",
|
||||
},
|
||||
M0011: {
|
||||
title: "Eight principle",
|
||||
description: "Exterior/Interior, Cold/Heat, Deficiency/Excess, Yin/Yang patterns",
|
||||
icon: "git-network-outline",
|
||||
color: "#7C3AED",
|
||||
category: "Patterns",
|
||||
isDefaultFree: true,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0012: {
|
||||
title: "TCM Patterns",
|
||||
description: "Zangfu organ and channel identification",
|
||||
icon: "pulse-outline",
|
||||
color: "#06B6D4",
|
||||
category: "Patterns",
|
||||
isDefaultFree: false,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0013: {
|
||||
title: "Qi-Blood-body fluid",
|
||||
description: "Qi, Blood, and Body Fluid identification of patterns",
|
||||
icon: "water-outline",
|
||||
color: "#3B82F6",
|
||||
category: "Patterns",
|
||||
isDefaultFree: false,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0014: {
|
||||
title: "Pathogenic factors",
|
||||
description: "Wind, Cold, Summer-Heat, Dampness, Dryness, Fire patterns",
|
||||
icon: "flame-outline",
|
||||
color: "#F59E0B",
|
||||
category: "Patterns",
|
||||
isDefaultFree: false,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0015: {
|
||||
title: "Six stages",
|
||||
description: "Tai Yang, Yang Ming, Shao Yang, Tai Yin, Shao Yin, Jue Yin",
|
||||
icon: "layers-outline",
|
||||
color: "#10B981",
|
||||
category: "Patterns",
|
||||
isDefaultFree: false,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0016: {
|
||||
title: "Four level",
|
||||
description: "Wei, Qi, Ying, Xue level pattern identification",
|
||||
icon: "trending-up-outline",
|
||||
color: "#EF4444",
|
||||
category: "Patterns",
|
||||
isDefaultFree: false,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0017: {
|
||||
title: "Three burners",
|
||||
description: "Upper, Middle, and Lower Burner pattern identification",
|
||||
icon: "thermometer-outline",
|
||||
color: "#EC4899",
|
||||
category: "Patterns",
|
||||
isDefaultFree: false,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0018: {
|
||||
title: "Twelve channel",
|
||||
description: "Twelve-channel theory and clinical reference",
|
||||
icon: "pulse-outline",
|
||||
color: "#06B6D4",
|
||||
category: "Patterns",
|
||||
isDefaultFree: false,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0019: {
|
||||
title: "Five elements",
|
||||
description: "Wood, Fire, Earth, Metal, Water relationships and patterns",
|
||||
icon: "flower-outline",
|
||||
color: "#6366F1",
|
||||
category: "Patterns",
|
||||
isDefaultFree: false,
|
||||
planCode: "PATTERN_CORE",
|
||||
},
|
||||
M0020: {
|
||||
title: "Extra Ordinary Vessel",
|
||||
description: "Extraordinary vessel theory, pathways and relationships",
|
||||
icon: "git-branch-outline",
|
||||
color: "#8B5CF6",
|
||||
category: "point",
|
||||
isDefaultFree: false,
|
||||
planCode: "POINTS_ACU",
|
||||
},
|
||||
M0031: {
|
||||
title: "Nutrition",
|
||||
description: "Nutritional food classifications, properties and indications",
|
||||
icon: "nutrition-outline",
|
||||
color: "#10B981",
|
||||
category: "Nutrition",
|
||||
isDefaultFree: true,
|
||||
planCode: "NUTRITION_CORE",
|
||||
},
|
||||
M0041: {
|
||||
title: "Auriculotherapy",
|
||||
description: "Auriculotherapy reflexology systems",
|
||||
icon: "body-outline",
|
||||
color: "#8B5CF6",
|
||||
category: "point",
|
||||
isDefaultFree: false,
|
||||
planCode: "LIFETIME_ALL",
|
||||
},
|
||||
M0042: {
|
||||
title: "Gynecology",
|
||||
description: "Menstrual irregularities and pregnancy patterns",
|
||||
icon: "woman-outline",
|
||||
color: "#EC4899",
|
||||
category: "Therapeutics",
|
||||
isDefaultFree: false,
|
||||
planCode: "THERAPEUTICS_GYNAE",
|
||||
},
|
||||
|
|
@ -182,6 +136,46 @@ function readMetadataString(module: ModuleResponse, key: string): string | null
|
|||
return asNonBlankString(module.metadata?.[key]);
|
||||
}
|
||||
|
||||
function readMetadataBoolean(module: ModuleResponse, key: string): boolean | null {
|
||||
const value = module.metadata?.[key];
|
||||
if (typeof value === "boolean") return value;
|
||||
if (typeof value === "string") {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (normalized === "true") return true;
|
||||
if (normalized === "false") return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function resolveModuleCategory(module: ModuleResponse): string {
|
||||
const explicitCategory = readMetadataString(module, "category");
|
||||
if (explicitCategory) return explicitCategory;
|
||||
|
||||
const kind = readMetadataString(module, "kind")?.toLowerCase();
|
||||
|
||||
switch (kind) {
|
||||
case "point":
|
||||
case "points":
|
||||
return "Points";
|
||||
|
||||
case "pattern":
|
||||
case "patterns":
|
||||
case "five-elements":
|
||||
case "five_elements":
|
||||
return "Patterns";
|
||||
|
||||
case "nutrition":
|
||||
return "Nutrition";
|
||||
|
||||
case "therapeutic":
|
||||
case "therapeutics":
|
||||
return "Therapeutics";
|
||||
|
||||
default:
|
||||
return "Other";
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveModuleEntryTemplateCode(module: ModuleResponse): string {
|
||||
const configured = MODULE_VISUALS[module.code]?.entryTemplateCode;
|
||||
const metadataConfigured =
|
||||
|
|
@ -210,27 +204,25 @@ export function buildModuleTemplateReference(module: ModuleResponse): TemplateRe
|
|||
|
||||
export function toModuleIndexItem(module: ModuleResponse): ModuleIndexItem {
|
||||
const visual = MODULE_VISUALS[module.code];
|
||||
const metadataCategory = readMetadataString(module, "category");
|
||||
const metadataIcon = readMetadataString(module, "icon");
|
||||
const metadataColor = readMetadataString(module, "color");
|
||||
const metadataPlanCode = readMetadataString(module, "plan_code");
|
||||
const metadataIsDefaultFree = readMetadataBoolean(module, "is_default_free");
|
||||
|
||||
return {
|
||||
module,
|
||||
reference: buildModuleTemplateReference(module),
|
||||
title: visual?.title ?? module.name,
|
||||
description:
|
||||
visual?.description ??
|
||||
module.description ??
|
||||
"Structured clinical reference content",
|
||||
|
||||
// API is authoritative for module content/business metadata.
|
||||
title: module.name,
|
||||
description: module.description?.trim() || "Structured clinical reference content",
|
||||
category: resolveModuleCategory(module),
|
||||
|
||||
// Presentation/commerce values use API metadata when supplied and retain
|
||||
// current client fallbacks until those fields are guaranteed by the API.
|
||||
icon: metadataIcon ?? visual?.icon ?? "folder-outline",
|
||||
color: metadataColor ?? visual?.color ?? "#4F46E5",
|
||||
category:
|
||||
metadataCategory ??
|
||||
visual?.category ??
|
||||
readMetadataString(module, "kind") ??
|
||||
"Other",
|
||||
isDefaultFree: visual?.isDefaultFree ?? false,
|
||||
isDefaultFree: metadataIsDefaultFree ?? visual?.isDefaultFree ?? false,
|
||||
planCode: metadataPlanCode ?? visual?.planCode ?? "",
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue