eletrotupi / tcc/ frontend/components/history/ActivityHistoryCard.tsxd7eb725e76fd8e9ebaab8530632e3dad82c3bf9a
1.9 KB | 63 lines Raw
1
import { Text, View, StyleSheet } from "react-native";
2
import { MaterialIcons } from "@expo/vector-icons";
3
import { Card } from "@/components/ui/Cards";
4
import type { HistoryCard } from "@/lib/history/types";
5
import type { CareAction } from "@/lib/api";
6
import { Spacing } from "@/constants/theme";
7
import { getActivityCategory } from "@/constants/care-action-categories";
8
import { router } from "expo-router";
9

10
type Props = { card: HistoryCard & { raw: CareAction } };
11

12
export function ActivityHistoryCard({ card }: Props) {
13
  const meta = getActivityCategory(card.raw.activity?.type);
14
  const time = new Date(card.timestamp).toLocaleTimeString("pt-BR", {
15
    hour: "2-digit",
16
    minute: "2-digit",
17
  });
18

19
  return (
20
    <Card
21
      style={styles.card}
22
      onPress={() => (router.push as any)(`/care-actions/${card.raw.id}`)}
23
    >
24
      <View style={styles.row}>
25
        <View style={[styles.iconWrap, { backgroundColor: meta.iconBackground }]}>
26
          <MaterialIcons name={meta.icon as any} size={22} color={meta.color} />
27
        </View>
28
        <View style={styles.body}>
29
          <View style={styles.titleRow}>
30
            <Text style={styles.title}>{card.title}</Text>
31
            <Text style={styles.time}>{time}</Text>
32
          </View>
33
          <Text style={styles.summary} numberOfLines={2}>
34
            {card.summary}
35
          </Text>
36
        </View>
37
      </View>
38
    </Card>
39
  );
40
}
41

42
const styles = StyleSheet.create({
43
  card: { padding: Spacing.cardGap },
44
  row: { flexDirection: "row", alignItems: "flex-start", gap: 12 },
45
  iconWrap: {
46
    width: 40,
47
    height: 40,
48
    borderRadius: 20,
49
    alignItems: "center",
50
    justifyContent: "center",
51
    marginTop: 1,
52
  },
53
  body: { flex: 1 },
54
  titleRow: {
55
    flexDirection: "row",
56
    justifyContent: "space-between",
57
    alignItems: "center",
58
    marginBottom: 2,
59
  },
60
  title: { fontSize: 15, fontWeight: "600" },
61
  time: { fontSize: 13, opacity: 0.45 },
62
  summary: { fontSize: 13, opacity: 0.6, lineHeight: 18 },
63
});