import { View, Text, FlatList, StyleSheet } from 'react-native' import { COLORS } from '../constants/Config' export interface TimelineEvent { timestamp: string actor: string action: string detail?: string } interface Props { events: TimelineEvent[] } const ACTION_COLOR: Record = { created: COLORS.accent, assigned: COLORS.blue, status: '#4f6ef7', escalated: COLORS.danger, comment: COLORS.muted, resolved: COLORS.success, closed: COLORS.success, } /** * 기능 #6 — 인시던트 타임라인 * 수직 타임라인 UI (점 + 연결선 + 이벤트 카드) */ export default function IncidentTimeline({ events }: Props) { if (!events || events.length === 0) { return 타임라인 이벤트가 없습니다. } return ( String(i)} renderItem={({ item, index }) => { const color = ACTION_COLOR[item.action?.toLowerCase()] ?? COLORS.accent const isLast = index === events.length - 1 return ( {!isLast && } {item.action} {formatTime(item.timestamp)} {item.actor} {!!item.detail && {item.detail}} ) }} /> ) } function formatTime(ts: string): string { try { const d = new Date(ts) return `${d.getMonth() + 1}/${d.getDate()} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}` } catch { return ts } } const s = StyleSheet.create({ empty: { textAlign: 'center', color: COLORS.muted, paddingVertical: 24, fontSize: 13 }, row: { flexDirection: 'row' }, gutter: { width: 24, alignItems: 'center' }, dot: { width: 12, height: 12, borderRadius: 6, marginTop: 4 }, line: { flex: 1, width: 2, backgroundColor: COLORS.border, marginTop: 2 }, content: { flex: 1, paddingBottom: 18, paddingLeft: 8 }, head: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }, action: { fontSize: 13, fontWeight: '700', color: COLORS.text, textTransform: 'capitalize' }, time: { fontSize: 11, color: COLORS.muted }, actor: { fontSize: 12, color: COLORS.blue, marginTop: 2 }, detail: { fontSize: 12, color: COLORS.muted, marginTop: 4, lineHeight: 17 }, })