import React, { useState, useCallback } from 'react' import { View, Text, FlatList, StyleSheet, RefreshControl } from 'react-native' import { useFocusEffect } from 'expo-router' import { COLORS } from '../../constants/Config' import client from '../../services/api' const MEDAL = ['๐Ÿฅ‡', '๐Ÿฅˆ', '๐Ÿฅ‰'] export default function TeamLeaderboardScreen() { const [items, setItems] = useState([]) const [loading, setLoading] = useState(false) const load = useCallback(async () => { setLoading(true) try { const r = await client.get('/api/mobile2/team-leaderboard'); setItems(r.data?.leaderboard ?? r.data?.items ?? []) } catch { setItems([]) } finally { setLoading(false) } }, []) useFocusEffect(useCallback(() => { load() }, [load])) const maxScore = items[0]?.score ?? 1 return ( String(i)} refreshControl={} ListEmptyComponent={๋ฆฌ๋”๋ณด๋“œ ๋ฐ์ดํ„ฐ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.} style={{ backgroundColor: COLORS.bg }} contentContainerStyle={{ padding: 12 }} ListHeaderComponent={์ด๋ฒˆ ๋‹ฌ ์ฒ˜๋ฆฌ ์„ฑ๊ณผ} renderItem={({ item, index }) => { const score = item.score ?? item.closed_count ?? 0 const barWidth = `${Math.round((score / maxScore) * 100)}%` return ( {MEDAL[index] ?? `${index + 1}`} {item.name ?? item.engineer_name} {score}๊ฑด SLA: {item.sla_rate ?? '-'}% ยท ํ‰์ : {item.rating ?? '-'} ) }} /> ) } const s = StyleSheet.create({ header: { fontSize: 16, fontWeight: '800', color: COLORS.text, marginBottom: 12 }, row: { flexDirection: 'row', alignItems: 'center', gap: 12, backgroundColor: '#fff', borderRadius: 10, padding: 14, marginBottom: 6, elevation: 1 }, rank: { fontSize: 22, width: 32, textAlign: 'center' }, nameRow: { flexDirection: 'row', justifyContent: 'space-between', marginBottom: 6 }, name: { fontSize: 14, fontWeight: '700', color: COLORS.text }, score: { fontSize: 14, fontWeight: '700', color: COLORS.accent }, bar: { height: 6, backgroundColor: COLORS.border, borderRadius: 3, overflow: 'hidden', marginBottom: 4 }, fill: { height: '100%', backgroundColor: COLORS.accent, borderRadius: 3 }, meta: { fontSize: 11, color: COLORS.muted }, empty: { textAlign: 'center', color: COLORS.muted, marginTop: 40 }, })