import React, { useState, useCallback } from 'react' import { View, Text, ScrollView, StyleSheet, RefreshControl, ActivityIndicator } from 'react-native' import { useFocusEffect } from 'expo-router' import { COLORS } from '../../constants/Config' import client from '../../services/api' function ServiceNode({ name, deps, allNodes }: { name: string; deps: string[]; allNodes: Record }) { return ( {name} {deps.length > 0 && ( {deps.map((d, i) => ( {d} ))} )} ) } const n = StyleSheet.create({ wrap: { marginBottom: 12 }, node: { backgroundColor: COLORS.accent, borderRadius: 8, paddingHorizontal: 14, paddingVertical: 8, alignSelf: 'flex-start' }, name: { color: '#fff', fontSize: 13, fontWeight: '700' }, depsWrap: { marginLeft: 20, marginTop: 4 }, depRow: { flexDirection: 'row', alignItems: 'center', marginTop: 4 }, arrow: { width: 20, height: 2, backgroundColor: COLORS.border, marginRight: 6 }, depBox: { backgroundColor: COLORS.light, borderRadius: 6, paddingHorizontal: 10, paddingVertical: 4 }, depText: { fontSize: 12, color: COLORS.text }, }) export default function DependencyMapScreen() { const [data, setData] = useState(null) const [loading, setLoading] = useState(false) const load = useCallback(async () => { setLoading(true) try { const r = await client.get('/api/knowledge-graph/service-map'); setData(r.data) } catch { setData(null) } finally { setLoading(false) } }, []) useFocusEffect(useCallback(() => { load() }, [load])) if (loading) return if (!data) return 서비스 의존성 맵을 불러올 수 없습니다. const nodes: Record = data.dependencies ?? data.services ?? {} return ( } contentContainerStyle={{ padding: 16 }}> 서비스 의존성 맵 노드: {Object.keys(nodes).length}개 · 관계: {Object.values(nodes).flat().length}개 {Object.entries(nodes).map(([name, deps]) => ( ))} ) } const s = StyleSheet.create({ container: { flex: 1, backgroundColor: COLORS.bg }, empty: { textAlign: 'center', color: COLORS.muted, marginTop: 40 }, title: { fontSize: 20, fontWeight: '800', color: COLORS.text, marginBottom: 4 }, sub: { fontSize: 12, color: COLORS.muted, marginBottom: 16 }, })