import { useState } from 'react'; import { View, Text, ScrollView, Pressable, Image } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { useLocalSearchParams, useRouter } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { useColors } from '../../lib/theme'; import { resolveAvatar } from '../../lib/resolveAvatar'; import type { Plan } from '../../hooks/useUserPlan'; const planLabel: Record = { free: 'Free', pro: 'Pro', legend: 'Legend', }; const planColors: Record = { free: { bg: '#f5f5f5', text: '#525252', border: '#e5e5e5' }, pro: { bg: '#fff7ed', text: '#c2410c', border: '#fed7aa' }, legend: { bg: '#fef9c3', text: '#854d0e', border: '#fde68a' }, }; // TODO: GET /api/social/profile/[userId] — extend response um approvedDomainsCount. // Strikt anonym: nur nickname, avatar, plan, memberSince, postsCount, followersCount, // approvedDomainsCount, isFollowing. NIEMALS email, demographics, cooldowns, sos-insights. type ForeignProfile = { id: string; nickname: string; avatar: string | null; plan: Plan; memberSince: string; postsCount: number; followersCount: number; approvedDomainsCount: number; isFollowing: boolean; }; const DUMMY_FOREIGN: ForeignProfile = { id: 'foreign-user-id', nickname: 'Jonas_42', avatar: 'wolf', plan: 'pro', memberSince: 'April 2026', postsCount: 12, followersCount: 47, approvedDomainsCount: 8, isFollowing: false, }; type StatProps = { value: string; label: string; }; function ForeignStat({ value, label }: StatProps) { const colors = useColors(); return ( {value} {label} ); } export default function ForeignProfileScreen() { const insets = useSafeAreaInsets(); const router = useRouter(); const colors = useColors(); const { userId } = useLocalSearchParams<{ userId: string }>(); const [imageFailed, setImageFailed] = useState(false); const [isFollowing, setIsFollowing] = useState(DUMMY_FOREIGN.isFollowing); // TODO: useQuery → apiFetch(`/api/social/profile/${userId}`) const profile = DUMMY_FOREIGN; void userId; const avatarUrl = resolveAvatar(profile.avatar, profile.nickname); const initials = profile.nickname.slice(0, 2).toUpperCase(); const showImage = !!profile.avatar && !imageFailed; const planStyle = planColors[profile.plan]; return ( router.back()} hitSlop={8} style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1, padding: 8 })} > Profil {showImage ? ( setImageFailed(true)} style={{ width: 92, height: 92, borderRadius: 46 }} /> ) : ( {initials} )} {profile.nickname} {planLabel[profile.plan].toUpperCase()} Mitglied seit {profile.memberSince} { // TODO: POST /api/social/follow/[userId] resp. DELETE bei unfollow setIsFollowing((v) => !v); }} style={({ pressed }) => ({ flex: 1, opacity: pressed ? 0.7 : 1, })} > {isFollowing ? 'Folge ich' : 'Folgen'} { // TODO: navigate to DM with this userId router.push(`/dm`); }} style={({ pressed }) => ({ flex: 1, opacity: pressed ? 0.7 : 1, })} > Nachricht {/* TODO: GET /api/community/posts?userId=... — letzte 5 Posts */} LETZTE POSTS Posts-Liste folgt in Phase C ); }