61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import React from "react";
|
|
import { StyleSheet, Text, View } from "react-native";
|
|
import { humanizeKey } from "../helpers/value";
|
|
import { ContentValue } from "./ContentValue";
|
|
|
|
export function RecordCards({
|
|
rows,
|
|
titleKey = "name",
|
|
}: {
|
|
rows: Record<string, unknown>[];
|
|
titleKey?: string;
|
|
}) {
|
|
if (!rows.length) return null;
|
|
|
|
return (
|
|
<View style={styles.list}>
|
|
{rows.map((row, index) => (
|
|
<View key={index} style={styles.card}>
|
|
{typeof row[titleKey] === "string" && String(row[titleKey]).trim() ? (
|
|
<Text style={styles.title}>{String(row[titleKey])}</Text>
|
|
) : null}
|
|
{Object.entries(row).filter(([key]) => key !== titleKey && key !== "code").map(([key, value]) => (
|
|
<View key={key} style={styles.field}>
|
|
<Text style={styles.label}>{humanizeKey(key)}</Text>
|
|
<ContentValue value={value} textStyle={styles.value} />
|
|
</View>
|
|
))}
|
|
</View>
|
|
))}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
list: { gap: 10 },
|
|
card: {
|
|
borderWidth: 1,
|
|
borderColor: "#E1E8E4",
|
|
borderRadius: 14,
|
|
padding: 13,
|
|
gap: 10,
|
|
backgroundColor: "#FAFCFB",
|
|
},
|
|
title: {
|
|
fontSize: 16,
|
|
lineHeight: 22,
|
|
fontWeight: "700",
|
|
color: "#294C3B",
|
|
},
|
|
field: { gap: 4 },
|
|
label: {
|
|
fontSize: 12,
|
|
lineHeight: 17,
|
|
fontWeight: "700",
|
|
color: "#617468",
|
|
textTransform: "uppercase",
|
|
letterSpacing: 0.35,
|
|
},
|
|
value: { fontSize: 15, lineHeight: 23, color: "#334155" },
|
|
});
|