Deep-audit + build-out across all products to fully-usable state; all typecheck clean. - gitgram-web (99): wire Store feature to real endpoints, close 9 gaps - gitgram-backend (100): close 8 flow gaps, document infra-provisioning items - gitgram-mobile (90): fix API base-URL/path mismatch (404s) + copy proximity components into components/proximity wired to real screens; 15 gaps, +react-native-svg - aitm-core (95): wire natural-language CLI flow end-to-end; 11 gaps - aitm-api (97): fix teams metadata runtime bug; copy a2a-js server/client/grpc into src/a2a and wire A2A route; crates.io package search; 8 gaps - aitm-mcp (100): fix A2A client/server card mismatch; 9 gaps - aitm-website (95): build missing docs routes; 9 gaps Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
189 lines
4.6 KiB
TypeScript
189 lines
4.6 KiB
TypeScript
import React, { useState, useEffect } from 'react';
|
|
import {
|
|
View,
|
|
Text,
|
|
StyleSheet,
|
|
FlatList,
|
|
TouchableOpacity,
|
|
} from 'react-native';
|
|
import { useRouter } from 'expo-router';
|
|
import { Colors } from '../../constants/Colors';
|
|
import Header from '../../components/navigation/Header';
|
|
import LoadingSpinner from '../../components/common/LoadingSpinner';
|
|
import EmptyState from '../../components/common/EmptyState';
|
|
import { userService } from '../../services/userService';
|
|
import { logger } from '../../utils/logger';
|
|
import { Image } from 'expo-image';
|
|
import FollowSuggestions from '../../components/proximity/FollowSuggestions';
|
|
|
|
export default function SuggestedUsersScreen() {
|
|
const router = useRouter();
|
|
const [users, setUsers] = useState<any[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
loadSuggestedUsers();
|
|
}, []);
|
|
|
|
const loadSuggestedUsers = async () => {
|
|
try {
|
|
const response = await userService.getSuggestedUsers();
|
|
setUsers(response.users || []);
|
|
} catch (error) {
|
|
logger.error('Load suggested users error:', error);
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
const handleFollow = async (userId: string) => {
|
|
try {
|
|
await userService.followUser(userId);
|
|
setUsers((prev) =>
|
|
prev.map((u) => (u.id === userId ? { ...u, isFollowing: true } : u))
|
|
);
|
|
} catch (error) {
|
|
logger.error('Follow user error:', error);
|
|
}
|
|
};
|
|
|
|
const renderUser = ({ item }: { item: any }) => (
|
|
<TouchableOpacity
|
|
style={styles.userItem}
|
|
onPress={() => router.push(`/profile/${item.id}`)}
|
|
>
|
|
{item.avatar ? (
|
|
<Image source={{ uri: item.avatar }} style={styles.avatar} />
|
|
) : (
|
|
<View style={styles.avatarPlaceholder}>
|
|
<Text style={styles.avatarText}>
|
|
{item.username[0].toUpperCase()}
|
|
</Text>
|
|
</View>
|
|
)}
|
|
<View style={styles.userInfo}>
|
|
<Text style={styles.username}>@{item.username}</Text>
|
|
{item.name && <Text style={styles.name}>{item.name}</Text>}
|
|
{item.bio && (
|
|
<Text style={styles.bio} numberOfLines={1}>
|
|
{item.bio}
|
|
</Text>
|
|
)}
|
|
{item.mutualFollowers && item.mutualFollowers > 0 && (
|
|
<Text style={styles.mutualText}>
|
|
{item.mutualFollowers} mutual follower{item.mutualFollowers !== 1 ? 's' : ''}
|
|
</Text>
|
|
)}
|
|
</View>
|
|
{!item.isFollowing && (
|
|
<TouchableOpacity
|
|
style={styles.followButton}
|
|
onPress={() => handleFollow(item.id)}
|
|
>
|
|
<Text style={styles.followButtonText}>Follow</Text>
|
|
</TouchableOpacity>
|
|
)}
|
|
</TouchableOpacity>
|
|
);
|
|
|
|
if (loading) {
|
|
return (
|
|
<View style={styles.container}>
|
|
<Header title="Suggested Users" />
|
|
<LoadingSpinner fullScreen />
|
|
</View>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<View style={styles.container}>
|
|
<Header title="Suggested Users" />
|
|
{users.length > 0 ? (
|
|
<FlatList
|
|
data={users}
|
|
renderItem={renderUser}
|
|
keyExtractor={(item) => item.id}
|
|
contentContainerStyle={styles.listContent}
|
|
ListHeaderComponent={<FollowSuggestions title="People to follow" />}
|
|
/>
|
|
) : (
|
|
<EmptyState
|
|
title="No suggestions"
|
|
message="We'll suggest users for you to follow based on your interests"
|
|
/>
|
|
)}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
flex: 1,
|
|
backgroundColor: Colors.background,
|
|
},
|
|
listContent: {
|
|
padding: 16,
|
|
},
|
|
userItem: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
padding: 16,
|
|
borderBottomWidth: 1,
|
|
borderBottomColor: Colors.border,
|
|
gap: 12,
|
|
},
|
|
avatar: {
|
|
width: 50,
|
|
height: 50,
|
|
borderRadius: 25,
|
|
},
|
|
avatarPlaceholder: {
|
|
width: 50,
|
|
height: 50,
|
|
borderRadius: 25,
|
|
backgroundColor: Colors.accent,
|
|
justifyContent: 'center',
|
|
alignItems: 'center',
|
|
},
|
|
avatarText: {
|
|
color: Colors.text,
|
|
fontSize: 20,
|
|
fontWeight: 'bold',
|
|
},
|
|
userInfo: {
|
|
flex: 1,
|
|
},
|
|
username: {
|
|
fontSize: 16,
|
|
fontWeight: '600',
|
|
color: Colors.text,
|
|
marginBottom: 4,
|
|
},
|
|
name: {
|
|
fontSize: 14,
|
|
color: Colors.textSecondary,
|
|
marginBottom: 2,
|
|
},
|
|
bio: {
|
|
fontSize: 12,
|
|
color: Colors.textSecondary,
|
|
marginBottom: 4,
|
|
},
|
|
mutualText: {
|
|
fontSize: 12,
|
|
color: Colors.accent,
|
|
},
|
|
followButton: {
|
|
backgroundColor: Colors.accent,
|
|
borderRadius: 8,
|
|
paddingHorizontal: 16,
|
|
paddingVertical: 8,
|
|
},
|
|
followButtonText: {
|
|
color: Colors.text,
|
|
fontSize: 14,
|
|
fontWeight: '600',
|
|
},
|
|
});
|
|
|