|
@@ -2,13 +2,15 @@ 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';
|
|
|
+import Modal from 'react-native-modal';
|
|
|
|
|
|
import {
|
|
|
type Score,
|
|
|
type Series,
|
|
|
type SocialData,
|
|
|
usePostGetProfileInfoPublicQuery,
|
|
|
- usePostGetProfileInfoQuery
|
|
|
+ usePostGetProfileInfoQuery,
|
|
|
+ usePostGetProfileRegions
|
|
|
} from '@api/user';
|
|
|
|
|
|
import {
|
|
@@ -37,6 +39,7 @@ 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';
|
|
|
+import RegionsRenderer from './RegionsRenderer';
|
|
|
|
|
|
type Props = {
|
|
|
navigation: NavigationProp<any>;
|
|
@@ -47,6 +50,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 currentUserId = storage.get('uid', StoreType.STRING) as string;
|
|
|
+
|
|
|
const [isUserMapAvailable, setIsUserMapAvailable] = useState<boolean>(false);
|
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
|
@@ -157,6 +162,7 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
|
|
|
homebase2: data.homebase2_name,
|
|
|
series: data.series
|
|
|
}}
|
|
|
+ userId={isPublicView ? route.params?.userId : +currentUserId}
|
|
|
/>
|
|
|
</PageWrapper>
|
|
|
);
|
|
@@ -179,10 +185,16 @@ type PersonalInfoProps = {
|
|
|
homebase2: string;
|
|
|
series: Series[];
|
|
|
};
|
|
|
+ userId: number;
|
|
|
};
|
|
|
|
|
|
-const PersonalInfo: FC<PersonalInfoProps> = ({ data }) => {
|
|
|
+const PersonalInfo: FC<PersonalInfoProps> = ({ data, userId }) => {
|
|
|
const [showMoreSeries, setShowMoreSeries] = useState(false);
|
|
|
+ const [type, setType] = useState<string>('nm');
|
|
|
+ const [isModalVisible, setIsModalVisible] = useState(false);
|
|
|
+
|
|
|
+ const { data: regions } = usePostGetProfileRegions(userId, type);
|
|
|
+
|
|
|
const scores = ['NM1301', 'DARE', 'UN', 'UN+', 'TCC', 'SLOW', 'YES', 'WHS'];
|
|
|
|
|
|
const handleOpenUrl = (url: string | undefined) => {
|
|
@@ -200,111 +212,169 @@ const PersonalInfo: FC<PersonalInfoProps> = ({ data }) => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+ const handleOpenModal = (type: string) => {
|
|
|
+ switch (type) {
|
|
|
+ case 'NM1301':
|
|
|
+ setType('nm');
|
|
|
+ break;
|
|
|
+ case 'DARE':
|
|
|
+ setType('mqp');
|
|
|
+ break;
|
|
|
+ case 'UN':
|
|
|
+ setType('un');
|
|
|
+ break;
|
|
|
+ case 'UN+':
|
|
|
+ setType('unp');
|
|
|
+ break;
|
|
|
+ case 'TCC':
|
|
|
+ setType('tcc');
|
|
|
+ break;
|
|
|
+ case 'SLOW':
|
|
|
+ setType('slow');
|
|
|
+ break;
|
|
|
+ case 'YES':
|
|
|
+ setType('yes');
|
|
|
+ break;
|
|
|
+ case 'WHS':
|
|
|
+ setType('whs');
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ setIsModalVisible(true);
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
- <ScrollView
|
|
|
- showsVerticalScrollIndicator={false}
|
|
|
- contentContainerStyle={{ gap: 20, paddingBottom: 32}}
|
|
|
- style={{ paddingTop: 20 }}
|
|
|
- >
|
|
|
- <InfoItem inline={true} title={'RANKING'}>
|
|
|
- <View style={{ flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'space-between' }}>
|
|
|
- {scores.map((score, index) => {
|
|
|
- let scoreRank = data.scores?.find((s) => s.name === score && s.score > 0)?.score ?? '-';
|
|
|
+ <>
|
|
|
+ <ScrollView
|
|
|
+ showsVerticalScrollIndicator={false}
|
|
|
+ contentContainerStyle={{ gap: 20, paddingBottom: 32 }}
|
|
|
+ style={{ paddingTop: 20 }}
|
|
|
+ >
|
|
|
+ <InfoItem inline={true} title={'RANKING'}>
|
|
|
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'space-between' }}>
|
|
|
+ {scores.map((score, index) => {
|
|
|
+ let scoreRank =
|
|
|
+ data.scores?.find((s) => s.name === score && s.score > 0)?.score ?? '-';
|
|
|
|
|
|
- if (score === 'YES' && +scoreRank >= 4500) {
|
|
|
- scoreRank = '-';
|
|
|
- }
|
|
|
+ if (score === 'YES' && +scoreRank >= 4500) {
|
|
|
+ scoreRank = '-';
|
|
|
+ }
|
|
|
|
|
|
- return (
|
|
|
- <View key={index} style={styles.rankingItem}>
|
|
|
- <Text style={styles.rankingScore}>{scoreRank}</Text>
|
|
|
- <Text style={[styles.titleText, { flex: 0 }]}>{score}</Text>
|
|
|
+ return (
|
|
|
+ <TouchableOpacity
|
|
|
+ key={index}
|
|
|
+ style={styles.rankingItem}
|
|
|
+ onPress={() => handleOpenModal(score)}
|
|
|
+ >
|
|
|
+ <Text style={styles.rankingScore}>{scoreRank}</Text>
|
|
|
+ <Text style={[styles.titleText, { flex: 0 }]}>
|
|
|
+ {score === 'NM1301' ? 'NM' : score}
|
|
|
+ </Text>
|
|
|
+ </TouchableOpacity>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </View>
|
|
|
+ </InfoItem>
|
|
|
+ {data.series?.length > 0 && (
|
|
|
+ <InfoItem showMore={showMoreSeries} inline={true} title={'SERIES'}>
|
|
|
+ {data.series?.slice(0, showMoreSeries ? data.series.length : 8).map((data, index) => (
|
|
|
+ <View
|
|
|
+ key={index}
|
|
|
+ style={{ display: 'flex', flexDirection: 'column', gap: 5, alignItems: 'center' }}
|
|
|
+ >
|
|
|
+ <Image
|
|
|
+ source={{ uri: API_HOST + data.icon_png }}
|
|
|
+ style={{ width: 28, height: 28 }}
|
|
|
+ />
|
|
|
+ <Text style={[styles.headerText, { flex: 0 }]}>{data.score}</Text>
|
|
|
</View>
|
|
|
- );
|
|
|
- })}
|
|
|
- </View>
|
|
|
- </InfoItem>
|
|
|
- {data.series?.length > 0 && (
|
|
|
- <InfoItem showMore={showMoreSeries} inline={true} title={'SERIES BADGES'}>
|
|
|
- {data.series?.slice(0, showMoreSeries ? data.series.length : 8).map((data, index) => (
|
|
|
+ ))}
|
|
|
+ </InfoItem>
|
|
|
+ )}
|
|
|
+ {data.series?.length > 8 ? (
|
|
|
+ <TouchableOpacity onPress={() => setShowMoreSeries(!showMoreSeries)}>
|
|
|
<View
|
|
|
- key={index}
|
|
|
- style={{ display: 'flex', flexDirection: 'column', gap: 5, alignItems: 'center' }}
|
|
|
+ style={[
|
|
|
+ { alignItems: 'center' },
|
|
|
+ showMoreSeries
|
|
|
+ ? { transform: 'rotate(180deg)', paddingTop: 8 }
|
|
|
+ : { paddingBottom: 8 }
|
|
|
+ ]}
|
|
|
>
|
|
|
- <Image source={{ uri: API_HOST + data.icon_png }} style={{ width: 28, height: 28 }} />
|
|
|
- <Text style={[styles.headerText, { flex: 0 }]}>{data.score}</Text>
|
|
|
+ <ArrowIcon stroke={'#B7C6CB'} />
|
|
|
</View>
|
|
|
- ))}
|
|
|
- </InfoItem>
|
|
|
- )}
|
|
|
- {data.series?.length > 8 ? (
|
|
|
- <TouchableOpacity onPress={() => setShowMoreSeries(!showMoreSeries)}>
|
|
|
- <View
|
|
|
- style={[
|
|
|
- { alignItems: 'center' },
|
|
|
- showMoreSeries ? { transform: 'rotate(180deg)', paddingTop: 8 } : { paddingBottom: 8 }
|
|
|
- ]}
|
|
|
- >
|
|
|
- <ArrowIcon stroke={'#B7C6CB'} />
|
|
|
- </View>
|
|
|
- </TouchableOpacity>
|
|
|
- ) : null}
|
|
|
- <View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
|
- <Text style={styles.headerText}>DATE OF BIRTH</Text>
|
|
|
- <Text style={styles.titleText}>{new Date(data.date_of_birth).toDateString()}</Text>
|
|
|
- </View>
|
|
|
- <View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
|
- <Text style={styles.headerText}>REGION OF ORIGIN</Text>
|
|
|
- <Text style={styles.titleText}>{data.homebase}</Text>
|
|
|
- </View>
|
|
|
- {data.homebase2 ? (
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ {/* <View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
|
+ <Text style={styles.headerText}>DATE OF BIRTH</Text>
|
|
|
+ <Text style={styles.titleText}>{new Date(data.date_of_birth).toDateString()}</Text>
|
|
|
+ </View>
|
|
|
<View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
|
- <Text style={styles.headerText}>SECOND REGION</Text>
|
|
|
- <Text style={styles.titleText}>{data.homebase2}</Text>
|
|
|
+ <Text style={styles.headerText}>REGION OF ORIGIN</Text>
|
|
|
+ <Text style={styles.titleText}>{data.homebase}</Text>
|
|
|
</View>
|
|
|
- ) : null}
|
|
|
- {data.bio && data.bio.length > 0 && (
|
|
|
- <InfoItem title={'BIO'}>
|
|
|
- <Text style={[styles.titleText, { flex: 0 }]}>{data.bio}</Text>
|
|
|
- </InfoItem>
|
|
|
- )}
|
|
|
- {hasActiveLinks() && (
|
|
|
- <InfoItem title={'SOCIAL LINKS'}>
|
|
|
- <View style={styles.linksBox}>
|
|
|
- {data.links?.f?.link && data.links?.f?.active !== 0 ? (
|
|
|
- <TouchableOpacity onPress={() => handleOpenUrl(data.links?.f?.link)}>
|
|
|
- <IconFacebook fill={Colors.DARK_BLUE} />
|
|
|
- </TouchableOpacity>
|
|
|
- ) : null}
|
|
|
- {data.links?.i?.link && data.links?.i?.active !== 0 ? (
|
|
|
- <TouchableOpacity onPress={() => handleOpenUrl(data.links?.i?.link)}>
|
|
|
- <IconInstagram fill={Colors.DARK_BLUE} />
|
|
|
- </TouchableOpacity>
|
|
|
- ) : null}
|
|
|
- {data.links?.t?.link && data.links?.t?.active !== 0 ? (
|
|
|
- <TouchableOpacity onPress={() => handleOpenUrl(data.links?.t?.link)}>
|
|
|
- <IconTwitter fill={Colors.DARK_BLUE} />
|
|
|
- </TouchableOpacity>
|
|
|
- ) : null}
|
|
|
- {data.links?.y?.link && data.links?.y?.active !== 0 ? (
|
|
|
- <TouchableOpacity onPress={() => handleOpenUrl(data.links?.y?.link)}>
|
|
|
- <IconYouTube fill={Colors.DARK_BLUE} />
|
|
|
- </TouchableOpacity>
|
|
|
- ) : null}
|
|
|
- {data.links?.www?.link && data.links?.www?.active !== 0 ? (
|
|
|
- <TouchableOpacity onPress={() => handleOpenUrl(data.links?.www?.link)}>
|
|
|
- <IconGlobe fill={Colors.DARK_BLUE} />
|
|
|
- </TouchableOpacity>
|
|
|
- ) : null}
|
|
|
- {data.links?.other?.link && data.links?.other?.active !== 0 ? (
|
|
|
- <TouchableOpacity onPress={() => handleOpenUrl(data.links?.other?.link)}>
|
|
|
- <IconLink fill={Colors.DARK_BLUE} />
|
|
|
- </TouchableOpacity>
|
|
|
- ) : null}
|
|
|
+ {data.homebase2 ? (
|
|
|
+ <View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
|
+ <Text style={styles.headerText}>SECOND REGION</Text>
|
|
|
+ <Text style={styles.titleText}>{data.homebase2}</Text>
|
|
|
</View>
|
|
|
- </InfoItem>
|
|
|
- )}
|
|
|
- </ScrollView>
|
|
|
+ ) : null} */}
|
|
|
+ {data.bio && data.bio.length > 0 && (
|
|
|
+ <InfoItem title={'BIO'}>
|
|
|
+ <Text style={[styles.titleText, { flex: 0 }]}>{data.bio}</Text>
|
|
|
+ </InfoItem>
|
|
|
+ )}
|
|
|
+ {hasActiveLinks() && (
|
|
|
+ <InfoItem title={'SOCIAL LINKS'}>
|
|
|
+ <View style={styles.linksBox}>
|
|
|
+ {data.links?.f?.link && data.links?.f?.active !== 0 ? (
|
|
|
+ <TouchableOpacity onPress={() => handleOpenUrl(data.links?.f?.link)}>
|
|
|
+ <IconFacebook fill={Colors.DARK_BLUE} />
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ {data.links?.i?.link && data.links?.i?.active !== 0 ? (
|
|
|
+ <TouchableOpacity onPress={() => handleOpenUrl(data.links?.i?.link)}>
|
|
|
+ <IconInstagram fill={Colors.DARK_BLUE} />
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ {data.links?.t?.link && data.links?.t?.active !== 0 ? (
|
|
|
+ <TouchableOpacity onPress={() => handleOpenUrl(data.links?.t?.link)}>
|
|
|
+ <IconTwitter fill={Colors.DARK_BLUE} />
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ {data.links?.y?.link && data.links?.y?.active !== 0 ? (
|
|
|
+ <TouchableOpacity onPress={() => handleOpenUrl(data.links?.y?.link)}>
|
|
|
+ <IconYouTube fill={Colors.DARK_BLUE} />
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ {data.links?.www?.link && data.links?.www?.active !== 0 ? (
|
|
|
+ <TouchableOpacity onPress={() => handleOpenUrl(data.links?.www?.link)}>
|
|
|
+ <IconGlobe fill={Colors.DARK_BLUE} />
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ {data.links?.other?.link && data.links?.other?.active !== 0 ? (
|
|
|
+ <TouchableOpacity onPress={() => handleOpenUrl(data.links?.other?.link)}>
|
|
|
+ <IconLink fill={Colors.DARK_BLUE} />
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ </View>
|
|
|
+ </InfoItem>
|
|
|
+ )}
|
|
|
+ </ScrollView>
|
|
|
+ <Modal
|
|
|
+ isVisible={isModalVisible}
|
|
|
+ onBackdropPress={() => setIsModalVisible(false)}
|
|
|
+ onBackButtonPress={() => setIsModalVisible(false)}
|
|
|
+ style={styles.modal}
|
|
|
+ statusBarTranslucent={true}
|
|
|
+ presentationStyle="overFullScreen"
|
|
|
+ >
|
|
|
+ <RegionsRenderer
|
|
|
+ type={type}
|
|
|
+ regions={regions}
|
|
|
+ setIsModalVisible={setIsModalVisible}
|
|
|
+ />
|
|
|
+ </Modal>
|
|
|
+ </>
|
|
|
);
|
|
|
};
|
|
|
|