import React, { FC, ReactNode, useState } from 'react'; import { ScrollView, Text, TouchableOpacity, View } from 'react-native'; import { Image } from 'expo-image'; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import { CommonActions, NavigationProp, useNavigation } from '@react-navigation/native'; import { type Score, type Series, type SocialData, usePostGetProfileInfoPublicQuery, usePostGetProfileInfoQuery } from '@api/user'; import { BigText, Button, PageWrapper, Loading, AvatarWithInitials } from '../../../components'; import { Colors } from '../../../theme'; import { styles } from './styles'; import { ButtonVariants } from '../../../types/components'; import { API_HOST } from '../../../constants'; import { NAVIGATION_PAGES } from '../../../types'; import { navigationOpts } from './navigation-opts'; import { storage, StoreType } from '../../../storage'; import { getFontSize, getYears } from '../../../utils'; import IconFacebook from '../../../../assets/icons/facebook.svg'; import IconInstagram from '../../../../assets/icons/instagram.svg'; import IconTwitter from '../../../../assets/icons/x(twitter).svg'; import IconYouTube from '../../../../assets/icons/youtube.svg'; import IconGlobe from '../../../../assets/icons/bottom-navigation/globe.svg'; import IconLink from '../../../../assets/icons/link.svg'; import GearIcon from '../../../../assets/icons/gear.svg'; const Tab = createMaterialTopTabNavigator(); type Props = { navigation: NavigationProp; route: any; }; const ProfileScreen: FC = ({ navigation, route }) => { const isPublicView = route.name === NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW; const token = storage.get('token', StoreType.STRING) as string; if (!token) return ; const { data, isFetching } = isPublicView ? usePostGetProfileInfoPublicQuery(route.params?.userId, true) : usePostGetProfileInfoQuery(token, true); if (!data || isFetching) return ; return ( {data.avatar ? ( ) : ( )} {data.first_name} {data.last_name} Age: {getYears(data.date_of_birth)} {data.homebase2_flag && data.homebase2_flag !== data.homebase_flag ? ( ) : null} {!isPublicView ? ( navigation.navigate(NAVIGATION_PAGES.SETTINGS)}> ) : null} ( {children} ) }} > {() => ( )} {() => } {() => } ); }; type PersonalInfoProps = { data: { bio: string; date_of_birth: string; scores: Score[]; links: { f?: SocialData; t?: SocialData; i?: SocialData; y?: SocialData; www?: SocialData; other?: SocialData; }; homebase: string; homebase2: string; series: Series[]; }; }; const PersonalInfo: FC = ({ data }) => { const [showMoreSeries, setShowMoreSeries] = useState(false); return ( {data.scores?.map((data, index) => { if (!data.score) return null; return ( {data.score} {data.name} ); })} {data.series?.slice(0, showMoreSeries ? data.series.length : 8).map((data, index) => ( {data.score} ))} {data.series?.length > 8 ? ( ); }; export default ProfileScreen;