From d6ae0cf92c75f18d1ac4dd9216b971af981c35ed Mon Sep 17 00:00:00 2001 From: Vlad0sEnIgma345 Date: Thu, 27 Nov 2025 08:41:23 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/frontend/app/(tabs)/two.tsx | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 apps/frontend/app/(tabs)/two.tsx diff --git a/apps/frontend/app/(tabs)/two.tsx b/apps/frontend/app/(tabs)/two.tsx new file mode 100644 index 0000000..3752f9e --- /dev/null +++ b/apps/frontend/app/(tabs)/two.tsx @@ -0,0 +1,85 @@ +import React, { useState } from 'react'; +import { + TextInput, + View as RNView, + TouchableOpacity, + Alert, + ActivityIndicator, +} from 'react-native'; +import { useRouter } from 'expo-router'; +import { Text, View } from '@/components/Themed'; +import { useColorScheme } from '@/components/useColorScheme'; +import Colors from '@/constants/Colors'; +import { usersApi } from '@/lib/api'; +import { Search, User } from 'lucide-react-native'; + +export default function SearchScreen() { + const [searchQuery, setSearchQuery] = useState(''); + const [loading, setLoading] = useState(false); + const colorScheme = useColorScheme(); + const colors = Colors[colorScheme ?? 'light']; + const router = useRouter(); + + const handleSearch = async () => { + const query = searchQuery.trim(); + + if (!query) { + Alert.alert('Ошибка', 'Введите имя пользователя'); + return; + } + + setLoading(true); + try { + const user = await usersApi.getUserByName(query); + // Переходим к профилю пользователя по его ID + router.push(`/user/${user.id}` as any); + setSearchQuery(''); + } catch (error: any) { + Alert.alert('Пользователь не найден', error.message || 'Пользователь с таким именем не существует'); + } finally { + setLoading(false); + } + }; + + return ( + + + + + + {loading ? ( + + ) : ( + + )} + + + + + + Поиск пользователей + + Введите имя пользователя в поле выше и нажмите поиск, чтобы просмотреть его профиль + + + + ); +}