import { Feather } from "@expo/vector-icons"; import { useQuery } from "@tanstack/react-query"; import { Link, useRouter } from "expo-router"; import React, { useState } from "react"; import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native"; import { useApp } from "../src/app-context"; import { AccordionSection } from "../src/components/AccordionSection"; import { AppHeader } from "../src/components/AppHeader"; import { ScreenShell } from "../src/components/ScreenShell"; import { isProduction } from "../src/config"; import { profileApi } from "../src/services"; import { Button, ErrorNotice, Loading, styles } from "../src/ui"; import { colors, radii, spacing } from "../src/theme"; export default function ProfileScreen() { const app = useApp(); const router = useRouter(); const enabled = app.authStatus === "authenticated"; const profile = useQuery({ queryKey: ["profile"], queryFn: profileApi.me, enabled }); const documents = useQuery({ queryKey: ["documents"], queryFn: profileApi.documents, enabled }); const [downloadError, setDownloadError] = useState(); const download = async (id: string) => { try { const result = await profileApi.documentUrl(id); if (typeof window !== "undefined") window.location.assign(result.download_url); } catch (error) { setDownloadError(error); } }; if (!enabled) { return ( Профиль Профиль доступен после авторизации. Перейти на главную для входа ); } const personal = profile.data?.profile.personal_data; const fullName = personal?.full_name ?? "Пользователь"; return ( router.back()} style={({ pressed }) => [stylesLocal.backButton, pressed && stylesLocal.pressed]}> Профиль {fullName} {personal?.citizenship ? `Гражданство: ${personal.citizenship}` : "Мигрант"} {(profile.isLoading || documents.isLoading) && } {(profile.error || documents.error) && ( { void profile.refetch(); void documents.refetch(); }} /> )} ({ title: doc.name, value: new Date(doc.sent_at).toLocaleDateString("ru-RU"), icon: "file-text" as const, action: "download", })) : [{ title: "Документов пока нет", value: "Оператор отправит их в этот раздел", icon: "file-text" }]} onItemPress={(index) => { const doc = documents.data?.items[index]; if (doc) void download(doc.document_id); }} /> Редактирование профиля недоступно. Для изменения данных напишите оператору. Написать оператору {!isProduction && ( router.push("/diagnostics")} style={({ pressed }) => [stylesLocal.menuItem, pressed && stylesLocal.pressed]}> Диагностика (dev) )}