100 lines
2.7 KiB
TypeScript
100 lines
2.7 KiB
TypeScript
import React from "react";
|
|
import { ScrollView, StyleSheet } from "react-native";
|
|
|
|
import type { DetailRendererProps } from "../../types/renderer.types";
|
|
|
|
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
|
import { Hero } from "../shared/Hero";
|
|
import { BulletList } from "../shared/BulletList";
|
|
import { SectionCard } from "../shared/SectionCard";
|
|
import { Paragraphs } from "../shared/Paragraphs";
|
|
import { ImageGallery } from "../shared/ImageGallery";
|
|
import { asString, asStringArray } from "../helpers/value";
|
|
|
|
export function PathogenicFactorsDetailRenderer({
|
|
content,
|
|
data,
|
|
definitions,
|
|
presentationAttributes,
|
|
}: DetailRendererProps) {
|
|
const title =
|
|
asString(data.name) ||
|
|
asString(data.title) ||
|
|
content.title;
|
|
|
|
const overview = asString(data.overview);
|
|
const clinicalManifestationsRaw =
|
|
data.clinical_manifestations ??
|
|
data.clinical_manifestation;
|
|
const clinicalManifestationItems = asStringArray(clinicalManifestationsRaw).filter(
|
|
(item) => item.trim().length > 0,
|
|
);
|
|
const analysis = asString(data.analysis);
|
|
const contentText = asString(data.content);
|
|
const defaultImage = asString(data["default image"]);
|
|
|
|
const imageValue = data.image;
|
|
const media = Array.isArray(imageValue)
|
|
? imageValue.filter(
|
|
(item): item is Record<string, unknown> =>
|
|
item !== null && typeof item === "object" && !Array.isArray(item),
|
|
)
|
|
: [];
|
|
|
|
return (
|
|
<ScrollView
|
|
contentContainerStyle={styles.content}
|
|
showsVerticalScrollIndicator={false}
|
|
>
|
|
<Hero title={title} />
|
|
|
|
{media.length > 0 ? <ImageGallery images={media} /> : null}
|
|
|
|
{defaultImage ? (
|
|
<SectionCard title="Default Image">
|
|
<Paragraphs items={[defaultImage]} />
|
|
</SectionCard>
|
|
) : null}
|
|
|
|
{overview ? (
|
|
<SectionCard title="Overview">
|
|
<Paragraphs items={[overview]} />
|
|
</SectionCard>
|
|
) : null}
|
|
|
|
{clinicalManifestationItems.length > 0 ? (
|
|
<SectionCard title="Clinical Manifestations">
|
|
<BulletList items={clinicalManifestationItems} />
|
|
</SectionCard>
|
|
) : null}
|
|
|
|
{analysis ? (
|
|
<SectionCard title="Analysis">
|
|
<Paragraphs items={[analysis]} />
|
|
</SectionCard>
|
|
) : null}
|
|
|
|
{contentText ? (
|
|
<SectionCard title="Content">
|
|
<Paragraphs items={[contentText]} />
|
|
</SectionCard>
|
|
) : null}
|
|
|
|
<ContentLinkAttributeSections
|
|
data={data}
|
|
definitions={definitions}
|
|
presentationAttributes={presentationAttributes}
|
|
/>
|
|
</ScrollView>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
content: {
|
|
paddingHorizontal: 18,
|
|
paddingTop: 16,
|
|
paddingBottom: 40,
|
|
gap: 14,
|
|
},
|
|
});
|