|
@@ -1,6 +1,6 @@
|
|
import { FC, useCallback, useEffect, useState } from 'react';
|
|
import { FC, useCallback, useEffect, useState } from 'react';
|
|
import { TouchableOpacity, View, Text, Image, Dimensions } from 'react-native';
|
|
import { TouchableOpacity, View, Text, Image, Dimensions } from 'react-native';
|
|
-import { Series, usePostGetProfileRegions } from '@api/user';
|
|
|
|
|
|
+import { Series, usePostGetProfileRegions, usePostGetUpdateQuery } from '@api/user';
|
|
import { NavigationProp } from '@react-navigation/native';
|
|
import { NavigationProp } from '@react-navigation/native';
|
|
import Modal from 'react-native-modal';
|
|
import Modal from 'react-native-modal';
|
|
import Tooltip from 'react-native-walkthrough-tooltip';
|
|
import Tooltip from 'react-native-walkthrough-tooltip';
|
|
@@ -22,6 +22,7 @@ import { NAVIGATION_PAGES } from 'src/types';
|
|
import { AvatarWithInitials, WarningModal } from 'src/components';
|
|
import { AvatarWithInitials, WarningModal } from 'src/components';
|
|
import { usePostFriendRequestMutation, usePostUpdateFriendStatusMutation } from '@api/friends';
|
|
import { usePostFriendRequestMutation, usePostUpdateFriendStatusMutation } from '@api/friends';
|
|
import FriendStatus from './FriendStatus';
|
|
import FriendStatus from './FriendStatus';
|
|
|
|
+import UpdatesRenderer from '../UpdatesRenderer';
|
|
|
|
|
|
type PersonalInfoProps = {
|
|
type PersonalInfoProps = {
|
|
data: {
|
|
data: {
|
|
@@ -88,8 +89,11 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
action: () => {},
|
|
action: () => {},
|
|
title: ''
|
|
title: ''
|
|
});
|
|
});
|
|
|
|
+ const [isUpdatesModalVisible, setIsUpdatesModalVisible] = useState(false);
|
|
|
|
+ const [updateType, setUpdateType] = useState<string>('un');
|
|
|
|
|
|
const { data: regions } = usePostGetProfileRegions(token as string, userId, type);
|
|
const { data: regions } = usePostGetProfileRegions(token as string, userId, type);
|
|
|
|
+ const { data: update } = usePostGetUpdateQuery(token as string, userId, updateType, true);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (data.isFriend === 1) {
|
|
if (data.isFriend === 1) {
|
|
@@ -188,6 +192,11 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
[updateFriendStatus, token, data.friendDbId]
|
|
[updateFriendStatus, token, data.friendDbId]
|
|
);
|
|
);
|
|
|
|
|
|
|
|
+ const handleOpenUpdates = (type: string) => {
|
|
|
|
+ setUpdateType(type);
|
|
|
|
+ setIsUpdatesModalVisible(true);
|
|
|
|
+ };
|
|
|
|
+
|
|
const screenWidth = Dimensions.get('window').width;
|
|
const screenWidth = Dimensions.get('window').width;
|
|
const availableWidth = screenWidth * (1 - 2 * SCREEN_PADDING_PERCENT);
|
|
const availableWidth = screenWidth * (1 - 2 * SCREEN_PADDING_PERCENT);
|
|
const maxAvatars = Math.floor(availableWidth / (AVATAR_SIZE - AVATAR_MARGIN)) - 2;
|
|
const maxAvatars = Math.floor(availableWidth / (AVATAR_SIZE - AVATAR_MARGIN)) - 2;
|
|
@@ -321,7 +330,7 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
<InfoItem title={'Visited in the last 90 days'}>
|
|
<InfoItem title={'Visited in the last 90 days'}>
|
|
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
{updates.un_visited && updates.un_visited > 0 ? (
|
|
{updates.un_visited && updates.un_visited > 0 ? (
|
|
- <View style={styles.updates}>
|
|
|
|
|
|
+ <TouchableOpacity style={styles.updates} onPress={() => handleOpenUpdates('un')}>
|
|
<FlagsIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
<FlagsIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
{updates.un_new && updates.un_new > 0 ? (
|
|
{updates.un_new && updates.un_new > 0 ? (
|
|
<View>
|
|
<View>
|
|
@@ -333,11 +342,11 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
) : (
|
|
) : (
|
|
<Text style={styles.updatesText}>{updates.un_visited} UN countries</Text>
|
|
<Text style={styles.updatesText}>{updates.un_visited} UN countries</Text>
|
|
)}
|
|
)}
|
|
- </View>
|
|
|
|
|
|
+ </TouchableOpacity>
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
{updates.unp_visited && updates.unp_visited > 0 ? (
|
|
{updates.unp_visited && updates.unp_visited > 0 ? (
|
|
- <View style={styles.updates}>
|
|
|
|
|
|
+ <TouchableOpacity style={styles.updates} onPress={() => handleOpenUpdates('unp')}>
|
|
<UNPIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
<UNPIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
{updates.unp_new && updates.unp_new > 0 ? (
|
|
{updates.unp_new && updates.unp_new > 0 ? (
|
|
<View>
|
|
<View>
|
|
@@ -349,11 +358,11 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
) : (
|
|
) : (
|
|
<Text style={styles.updatesText}>{updates.unp_visited} UN+ states</Text>
|
|
<Text style={styles.updatesText}>{updates.unp_visited} UN+ states</Text>
|
|
)}
|
|
)}
|
|
- </View>
|
|
|
|
|
|
+ </TouchableOpacity>
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
{updates.nm_visited && updates.nm_visited > 0 ? (
|
|
{updates.nm_visited && updates.nm_visited > 0 ? (
|
|
- <View style={styles.updates}>
|
|
|
|
|
|
+ <TouchableOpacity style={styles.updates} onPress={() => handleOpenUpdates('nm')}>
|
|
<RegionsIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
<RegionsIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
{updates.nm_new && updates.nm_new > 0 ? (
|
|
{updates.nm_new && updates.nm_new > 0 ? (
|
|
<View>
|
|
<View>
|
|
@@ -365,28 +374,31 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
) : (
|
|
) : (
|
|
<Text style={styles.updatesText}>{updates.nm_visited} NM regions</Text>
|
|
<Text style={styles.updatesText}>{updates.nm_visited} NM regions</Text>
|
|
)}
|
|
)}
|
|
- </View>
|
|
|
|
|
|
+ </TouchableOpacity>
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
{updates.new_dare && updates.new_dare > 0 ? (
|
|
{updates.new_dare && updates.new_dare > 0 ? (
|
|
- <View style={styles.updates}>
|
|
|
|
|
|
+ <TouchableOpacity style={styles.updates} onPress={() => handleOpenUpdates('dare')}>
|
|
<CompassIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
<CompassIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
- <Text style={styles.updatesText}>{updates.new_dare} new DARE</Text>
|
|
|
|
- </View>
|
|
|
|
|
|
+ <Text style={styles.updatesText}>{updates.new_dare} new DAREs</Text>
|
|
|
|
+ </TouchableOpacity>
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
{updates.new_series && updates.new_series > 0 ? (
|
|
{updates.new_series && updates.new_series > 0 ? (
|
|
- <View style={styles.updates}>
|
|
|
|
|
|
+ <TouchableOpacity
|
|
|
|
+ style={styles.updates}
|
|
|
|
+ onPress={() => handleOpenUpdates('series')}
|
|
|
|
+ >
|
|
<SeriesIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
<SeriesIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
<Text style={styles.updatesText}>{updates.new_series} new Series</Text>
|
|
<Text style={styles.updatesText}>{updates.new_series} new Series</Text>
|
|
- </View>
|
|
|
|
|
|
+ </TouchableOpacity>
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
{updates.new_whs && updates.new_whs > 0 ? (
|
|
{updates.new_whs && updates.new_whs > 0 ? (
|
|
- <View style={styles.updates}>
|
|
|
|
|
|
+ <TouchableOpacity style={styles.updates} onPress={() => handleOpenUpdates('whs')}>
|
|
<WHSIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
<WHSIcon fill={Colors.DARK_BLUE} height={20} width={20} />
|
|
<Text style={styles.updatesText}>{updates.new_whs} new WHS</Text>
|
|
<Text style={styles.updatesText}>{updates.new_whs} new WHS</Text>
|
|
- </View>
|
|
|
|
|
|
+ </TouchableOpacity>
|
|
) : null}
|
|
) : null}
|
|
</View>
|
|
</View>
|
|
</InfoItem>
|
|
</InfoItem>
|
|
@@ -455,6 +467,21 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
<RegionsRenderer type={type} regions={regions} setIsModalVisible={setIsModalVisible} />
|
|
<RegionsRenderer type={type} regions={regions} setIsModalVisible={setIsModalVisible} />
|
|
</Modal>
|
|
</Modal>
|
|
|
|
|
|
|
|
+ <Modal
|
|
|
|
+ isVisible={isUpdatesModalVisible}
|
|
|
|
+ onBackdropPress={() => setIsUpdatesModalVisible(false)}
|
|
|
|
+ onBackButtonPress={() => setIsUpdatesModalVisible(false)}
|
|
|
|
+ style={styles.modal}
|
|
|
|
+ statusBarTranslucent={true}
|
|
|
|
+ presentationStyle="overFullScreen"
|
|
|
|
+ >
|
|
|
|
+ <UpdatesRenderer
|
|
|
|
+ type={updateType}
|
|
|
|
+ updates={update ?? null}
|
|
|
|
+ setIsModalVisible={setIsUpdatesModalVisible}
|
|
|
|
+ />
|
|
|
|
+ </Modal>
|
|
|
|
+
|
|
<WarningModal
|
|
<WarningModal
|
|
type={modalInfo.type}
|
|
type={modalInfo.type}
|
|
isVisible={modalInfo.isVisible}
|
|
isVisible={modalInfo.isVisible}
|