|
@@ -1,10 +1,16 @@
|
|
|
import { FC, useCallback, useEffect, useState } from 'react';
|
|
|
import { TouchableOpacity, View, Text, Image, Dimensions } from 'react-native';
|
|
|
-import { Series, usePostGetProfileRegions, usePostGetUpdateQuery } from '@api/user';
|
|
|
+import {
|
|
|
+ Series,
|
|
|
+ usePostAuthenticateMutation,
|
|
|
+ usePostGetProfileRegions,
|
|
|
+ usePostGetUpdateQuery
|
|
|
+} from '@api/user';
|
|
|
import { NavigationProp } from '@react-navigation/native';
|
|
|
import Modal from 'react-native-modal';
|
|
|
import Tooltip from 'react-native-walkthrough-tooltip';
|
|
|
import RegionsRenderer from '../RegionsRenderer';
|
|
|
+import moment from 'moment';
|
|
|
|
|
|
import CompassIcon from 'assets/icons/travels-section/compass.svg';
|
|
|
import FlagsIcon from 'assets/icons/travels-section/flags.svg';
|
|
@@ -13,6 +19,7 @@ import SeriesIcon from 'assets/icons/travels-section/series.svg';
|
|
|
import WHSIcon from 'assets/icons/travels-section/whs.svg';
|
|
|
import ArrowIcon from 'assets/icons/next.svg';
|
|
|
import UNPIcon from 'assets/icons/travels-section/unp.svg';
|
|
|
+import AuthIcon from 'assets/icons/authenticate-user.svg';
|
|
|
|
|
|
import { styles } from './styles';
|
|
|
import { InfoItem } from './InfoItem';
|
|
@@ -24,7 +31,6 @@ import { usePostFriendRequestMutation, usePostUpdateFriendStatusMutation } from
|
|
|
import FriendStatus from './FriendStatus';
|
|
|
import UpdatesRenderer from '../UpdatesRenderer';
|
|
|
import { useFriendsNotificationsStore } from 'src/stores/friendsNotificationsStore';
|
|
|
-import moment from 'moment';
|
|
|
|
|
|
type PersonalInfoProps = {
|
|
|
data: {
|
|
@@ -50,6 +56,8 @@ type PersonalInfoProps = {
|
|
|
lastSeenRegion: string | null;
|
|
|
lastSeenDate: string;
|
|
|
lastSeenFlag: string | null;
|
|
|
+ canBeAuthenticated: 0 | 1;
|
|
|
+ setCanBeAuthenticated: (value: 0 | 1) => void;
|
|
|
};
|
|
|
updates: {
|
|
|
un_visited: number;
|
|
@@ -87,6 +95,7 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
|
const [tooltipUser, setTooltipUser] = useState<number | null>(null);
|
|
|
const { mutateAsync: sendFriendRequest } = usePostFriendRequestMutation();
|
|
|
const { mutateAsync: updateFriendStatus } = usePostUpdateFriendStatusMutation();
|
|
|
+ const { mutateAsync: authenticateUser } = usePostAuthenticateMutation();
|
|
|
const [friendStatus, setFriendStatus] = useState<number | null>(null);
|
|
|
const [modalInfo, setModalInfo] = useState({
|
|
|
type: 'friend',
|
|
@@ -223,6 +232,17 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
|
return date.fromNow();
|
|
|
};
|
|
|
|
|
|
+ const handleAuthenticate = () => {
|
|
|
+ authenticateUser(
|
|
|
+ { token: token as string, profile_id: userId },
|
|
|
+ {
|
|
|
+ onSuccess: () => {
|
|
|
+ data.setCanBeAuthenticated(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
const screenWidth = Dimensions.get('window').width;
|
|
|
const availableWidth = screenWidth * (1 - 2 * SCREEN_PADDING_PERCENT);
|
|
|
const maxAvatars = Math.floor(availableWidth / (AVATAR_SIZE - AVATAR_MARGIN)) - 2;
|
|
@@ -253,13 +273,33 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
|
|
|
</View>
|
|
|
|
|
|
{isPublicView && token ? (
|
|
|
- <FriendStatus
|
|
|
- status={friendStatus}
|
|
|
- data={data}
|
|
|
- setModalInfo={setModalInfo}
|
|
|
- handleSendFriendRequest={handleSendFriendRequest}
|
|
|
- handleUpdateFriendStatus={handleUpdateFriendStatus}
|
|
|
- />
|
|
|
+ <View style={{ gap: 8, flexDirection: 'row', alignItems: 'flex-end' }}>
|
|
|
+ <FriendStatus
|
|
|
+ status={friendStatus}
|
|
|
+ data={data}
|
|
|
+ setModalInfo={setModalInfo}
|
|
|
+ handleSendFriendRequest={handleSendFriendRequest}
|
|
|
+ handleUpdateFriendStatus={handleUpdateFriendStatus}
|
|
|
+ authButton={data.canBeAuthenticated}
|
|
|
+ />
|
|
|
+ {data.canBeAuthenticated ? (
|
|
|
+ <TouchableOpacity
|
|
|
+ onPress={() =>
|
|
|
+ setModalInfo({
|
|
|
+ isVisible: true,
|
|
|
+ type: 'authenticate',
|
|
|
+ message: `Please confirm that you have personally met ${data.firstName} ${data.lastName}.`,
|
|
|
+ action: handleAuthenticate,
|
|
|
+ title: ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ style={styles.authBtn}
|
|
|
+ >
|
|
|
+ <AuthIcon />
|
|
|
+ <Text style={styles.authText}>Authenticate</Text>
|
|
|
+ </TouchableOpacity>
|
|
|
+ ) : null}
|
|
|
+ </View>
|
|
|
) : null}
|
|
|
|
|
|
{data.friends.length > 0 ? (
|