|
@@ -1,4 +1,4 @@
|
|
|
-import React, { FC, ReactNode, useState } from 'react';
|
|
|
+import React, { FC, ReactNode, useEffect, useState } from 'react';
|
|
|
import { Linking, ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
|
|
import { Image } from 'expo-image';
|
|
|
import { CommonActions, NavigationProp, useNavigation } from '@react-navigation/native';
|
|
@@ -36,6 +36,7 @@ import IconGlobe from '../../../../assets/icons/bottom-navigation/globe.svg';
|
|
|
import IconLink from '../../../../assets/icons/link.svg';
|
|
|
import GearIcon from '../../../../assets/icons/gear.svg';
|
|
|
import ArrowIcon from '../../../../assets/icons/next.svg';
|
|
|
+import axios from 'axios';
|
|
|
|
|
|
type Props = {
|
|
|
navigation: NavigationProp<any>;
|
|
@@ -46,6 +47,8 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
const isPublicView = route.name === NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW;
|
|
|
|
|
|
const token = storage.get('token', StoreType.STRING) as string;
|
|
|
+ const [isUserMapAvailable, setIsUserMapAvailable] = useState<boolean>(false);
|
|
|
+ const [loading, setLoading] = useState(true);
|
|
|
|
|
|
if (!token) return <UnauthenticatedProfileScreen />;
|
|
|
|
|
@@ -53,23 +56,57 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
? usePostGetProfileInfoPublicQuery(route.params?.userId, true)
|
|
|
: usePostGetProfileInfoQuery(token, true);
|
|
|
|
|
|
- if (!data || isFetching) return <Loading />;
|
|
|
+ useEffect(() => {
|
|
|
+ const getUserMapUrl = async () => {
|
|
|
+ const response = await axios.get(`${API_HOST}/img/single_maps/${route.params?.userId}.png`);
|
|
|
+ return Boolean(response.data);
|
|
|
+ };
|
|
|
+ getUserMapUrl().then((res) => {
|
|
|
+ setIsUserMapAvailable(res);
|
|
|
+ setLoading(false);
|
|
|
+ });
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ if (!data || isFetching || loading) return <Loading />;
|
|
|
+
|
|
|
+ const handleGoToMap = () => {
|
|
|
+ isPublicView
|
|
|
+ ? navigation.navigate(NAVIGATION_PAGES.USERS_MAP, { userId: route.params?.userId, data })
|
|
|
+ : navigation.dispatch(
|
|
|
+ CommonActions.reset({
|
|
|
+ index: 1,
|
|
|
+ routes: [{ name: NAVIGATION_PAGES.MAP_TAB }]
|
|
|
+ })
|
|
|
+ );
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
|
<PageWrapper>
|
|
|
{isPublicView && <Header label="Profile" />}
|
|
|
- <View style={[styles.pageWrapper, isPublicView && { marginTop: 0 }]}>
|
|
|
- <View>
|
|
|
+ <TouchableOpacity
|
|
|
+ style={[styles.usersMap, { backgroundColor: '#EBF2F5' }]}
|
|
|
+ onPress={handleGoToMap}
|
|
|
+ >
|
|
|
+ <Image
|
|
|
+ source={
|
|
|
+ isUserMapAvailable
|
|
|
+ ? { uri: `${API_HOST}/img/single_maps/${route.params?.userId}.png` }
|
|
|
+ : require('../../../../assets/nm-map.png')
|
|
|
+ }
|
|
|
+ style={styles.usersMap}
|
|
|
+ />
|
|
|
+ </TouchableOpacity>
|
|
|
+
|
|
|
+ <View style={styles.pageWrapper}>
|
|
|
+ <View style={{ top: -34 }}>
|
|
|
{data.avatar ? (
|
|
|
- <Image
|
|
|
- style={{ borderRadius: 64 / 2, width: 64, height: 64 }}
|
|
|
- source={{ uri: API_HOST + data.avatar }}
|
|
|
- />
|
|
|
+ <Image style={styles.avatar} source={{ uri: API_HOST + data.avatar }} />
|
|
|
) : (
|
|
|
<AvatarWithInitials
|
|
|
text={`${data.first_name[0] ?? ''}${data.last_name[0] ?? ''}`}
|
|
|
flag={API_HOST + data.homebase_flag}
|
|
|
size={64}
|
|
|
+ borderColor={Colors.WHITE}
|
|
|
/>
|
|
|
)}
|
|
|
</View>
|
|
@@ -77,22 +114,8 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
<Text style={[styles.headerText, { fontSize: getFontSize(18), flex: 0 }]}>
|
|
|
{data.first_name} {data.last_name}
|
|
|
</Text>
|
|
|
- <View
|
|
|
- style={{
|
|
|
- display: 'flex',
|
|
|
- justifyContent: 'space-between',
|
|
|
- flexDirection: 'row',
|
|
|
- alignItems: 'center'
|
|
|
- }}
|
|
|
- >
|
|
|
- <View
|
|
|
- style={{
|
|
|
- display: 'flex',
|
|
|
- flexDirection: 'row',
|
|
|
- gap: 10,
|
|
|
- alignItems: 'center'
|
|
|
- }}
|
|
|
- >
|
|
|
+ <View style={styles.userInfoContainer}>
|
|
|
+ <View style={styles.userInfo}>
|
|
|
<Text
|
|
|
style={{ color: Colors.DARK_BLUE, fontWeight: '600', fontSize: getFontSize(12) }}
|
|
|
>
|
|
@@ -123,6 +146,7 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
</View>
|
|
|
</View>
|
|
|
</View>
|
|
|
+
|
|
|
<PersonalInfo
|
|
|
data={{
|
|
|
bio: data.bio,
|
|
@@ -180,7 +204,7 @@ const PersonalInfo: FC<PersonalInfoProps> = ({ data }) => {
|
|
|
<ScrollView
|
|
|
showsVerticalScrollIndicator={false}
|
|
|
contentContainerStyle={{ gap: 20 }}
|
|
|
- style={{ marginTop: 20 }}
|
|
|
+ style={{ paddingTop: 20 }}
|
|
|
>
|
|
|
<InfoItem inline={true} title={'RANKING'}>
|
|
|
<View style={{ flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'space-between' }}>
|