import { Text, View, StyleSheet } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; import { Card } from "@/components/ui/Cards"; import { Badge } from "@/components/ui/Badge"; import { HistoryCard } from "@/lib/history/types"; import { Trigger } from "@/lib/api"; import { Spacing } from "@/constants/theme"; // TODO: Move these to a constant as well const TRIGGER_META: Record< string, { label: string; variant: string; icon: keyof typeof MaterialIcons.glyphMap } > = { SOCIAL: { label: "Social", variant: "blue", icon: "diversity-1" }, FAMILY: { label: "Familiar", variant: "green", icon: "family-restroom" }, HEALTH: { label: "Emocional", variant: "purple", icon: "healing" }, PHYSICAL: { label: "FĂ­sico", variant: "orange", icon: "fitness-center" }, WORK: { label: "Trabalho", variant: "blue", icon: "work" }, OTHER: { label: "Outro", variant: "gray", icon: "help-outline" }, }; type Props = { card: HistoryCard & { raw: Trigger } }; export function TriggerHistoryCard({ card }: Props) { const meta = TRIGGER_META[card.raw.category] ?? TRIGGER_META.OTHER; const time = new Date(card.timestamp).toLocaleTimeString("pt-BR", { hour: "2-digit", minute: "2-digit", }); return ( Gatilho Identificado {time} {card.raw.comment ? ( {card.raw.comment} ) : null} ); } const styles = StyleSheet.create({ card: { padding: Spacing.cardGap, }, row: { flexDirection: "row", alignItems: "flex-start", gap: 12 }, iconWrap: { width: 40, height: 40, borderRadius: 20, alignItems: "center", justifyContent: "center", marginTop: 1, }, body: { flex: 1 }, titleRow: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", marginBottom: 2, }, title: { fontSize: 15, fontWeight: "600" }, time: { fontSize: 13, opacity: 0.45 }, summary: { fontSize: 13, opacity: 0.6, lineHeight: 18, marginBottom: 6 }, badge: { alignSelf: "flex-start", marginTop: 4 }, });