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' export default function AIBriefingScreen() { const [data, setData] = useState(null) const [loading, setLoading] = useState(false) const load = useCallback(async () => { setLoading(true) try { const r = await client.get('/api/ai-insights/briefing'); setData(r.data) } catch { setData(null) } finally { setLoading(false) } }, []) useFocusEffect(useCallback(() => { load() }, [load])) if (loading) return if (!data) return 브리핑을 불러올 수 없습니다. return ( } contentContainerStyle={{ padding: 16 }}> AI 주간 운영 브리핑 {data.period ?? ''} 핵심 요약 {data.summary ?? data.content ?? '데이터 없음'} {data.highlights?.map((h: string, i: number) => ( {h} ))} {data.risks?.length > 0 && ( 리스크 {data.risks.map((r: string, i: number) => ( • {r} ))} )} {data.recommendations?.length > 0 && ( AI 권고 사항 {data.recommendations.map((r: string, i: number) => ( • {r} ))} )} ) } const s = StyleSheet.create({ container: { flex: 1, backgroundColor: COLORS.bg }, empty: { textAlign: 'center', color: COLORS.muted, marginTop: 40 }, header: { marginBottom: 16 }, title: { fontSize: 22, fontWeight: '800', color: COLORS.text }, period: { fontSize: 13, color: COLORS.muted, marginTop: 4 }, card: { backgroundColor: '#fff', borderRadius: 12, padding: 16, marginBottom: 12, elevation: 1 }, sectionTitle: { fontSize: 14, fontWeight: '700', color: COLORS.text, marginBottom: 10 }, body: { fontSize: 14, color: COLORS.text, lineHeight: 22 }, bulletRow: { flexDirection: 'row', gap: 8, marginBottom: 6 }, bullet: { fontSize: 16, color: COLORS.accent, lineHeight: 22 }, bulletText: { flex: 1, fontSize: 13, color: COLORS.text, lineHeight: 20 }, })