import React from "react"; import { StyleSheet, Text } from "react-native"; import { asRecord, asRecordArray, asString, asStringArray } from "../helpers/value"; import { BulletList } from "../shared/BulletList"; import { ChipList } from "../shared/ChipList"; import { ImageGallery } from "../shared/ImageGallery"; import { ObjectSections } from "../shared/ObjectSections"; import { RecordCards } from "../shared/RecordCards"; import { RecordTable } from "../shared/RecordTable"; import { SectionCard } from "../shared/SectionCard"; import { useRelationalContentMedia } from "../../media/ContentMediaContext"; export const PointCodes = ({ data }: { data: Record }) => ( ); export const DescriptionList = ({ data }: { data: Record }) => { const arr = asStringArray(data.description); const text = asString(data.description); return ( {arr.length ? : {text}} ); }; const extractCategoryImages = (data: Record): Record[] => { const images = asRecordArray(data.images); if (images.length > 0) return images; const single = asRecord(data.default_image || data.image); if (Object.keys(single).length > 0) { return [single]; } return []; }; export const Images = ({ data }: { data: Record }) => { const directImages = extractCategoryImages(data); const relationalMedia = useRelationalContentMedia(); // If direct images are explicitly defined in category data, display them if (directImages.length > 0) { return ; } // If direct media was assigned directly to this category (e.g. primary image in CMS) const hasDirectMedia = relationalMedia.some((m) => m.media_role === "primary"); if (hasDirectMedia) { return ; } // Do not show inherited media from referenced points/meridians for categories without images return null; }; export const ObjectCard = ({ title, value }: { title: string; value: unknown }) => { const obj = asRecord(value); return Object.keys(obj).length ? ( ) : null; }; export const ObjectArrayCards = ({ title, value }: { title: string; value: unknown }) => { const rows = asRecordArray(value); return rows.length ? ( ) : null; }; export const ObjectArrayTable = ({ title, value, columns, }: { title: string; value: unknown; columns?: string[]; }) => { const rows = asRecordArray(value); return rows.length ? ( ) : null; }; export const Strings = ({ title, value }: { title: string; value: unknown }) => { const arr = asStringArray(value); const txt = asString(value); if (!arr.length && !txt) return null; return ( {arr.length ? : {txt}} ); }; const styles = StyleSheet.create({ readingText: { fontSize: 16, lineHeight: 26, color: "#334155" }, });