|
@@ -1,4 +1,4 @@
|
|
|
-import React, { FC } from 'react';
|
|
|
+import React, { FC, useState } from 'react';
|
|
|
import { Text, TouchableOpacity, View } from 'react-native';
|
|
|
import { Image } from 'expo-image';
|
|
|
import { useNavigation } from '@react-navigation/native';
|
|
@@ -6,8 +6,8 @@ import * as FileSystem from 'expo-file-system';
|
|
|
|
|
|
import { ProfileStyles, ScoreStyles, TBTStyles } from './styles';
|
|
|
|
|
|
-import { getOnlineStatus } from 'src/storage';
|
|
|
-import { AvatarWithInitials } from 'src/components';
|
|
|
+import { getOnlineStatus, storage, StoreType } from 'src/storage';
|
|
|
+import { AvatarWithInitials, WarningModal } from 'src/components';
|
|
|
|
|
|
import { API_HOST } from '../../../../constants';
|
|
|
import { getFontSize } from '../../../../utils';
|
|
@@ -61,6 +61,18 @@ export const Profile: FC<Props> = ({
|
|
|
|
|
|
const scoreNames = ['NM', 'DARE', 'UN', 'UN+', 'TCC', 'DEEP', 'YES', 'SLOW', 'WHS', 'KYE'];
|
|
|
const isOnline = getOnlineStatus();
|
|
|
+ const token = storage.get('token', StoreType.STRING);
|
|
|
+ const [modalType, setModalType] = useState<string | null>(null);
|
|
|
+
|
|
|
+ const handlePress = () => {
|
|
|
+ if (!isOnline) {
|
|
|
+ setModalType('offline');
|
|
|
+ } else if (!token) {
|
|
|
+ setModalType('unauthorized');
|
|
|
+ } else {
|
|
|
+ navigation.navigate(...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId }] as never));
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
const avatarBaseUri = isOnline
|
|
|
? `${API_HOST}/img/avatars/`
|
|
@@ -106,11 +118,7 @@ export const Profile: FC<Props> = ({
|
|
|
|
|
|
return (
|
|
|
<View>
|
|
|
- <TouchableOpacity
|
|
|
- onPress={() =>
|
|
|
- navigation.navigate(...([NAVIGATION_PAGES.PUBLIC_PROFILE_VIEW, { userId }] as never))
|
|
|
- }
|
|
|
- >
|
|
|
+ <TouchableOpacity onPress={() => handlePress()}>
|
|
|
<View style={adaptiveStyle(ProfileStyles.profileRoot, {})}>
|
|
|
<View style={{ paddingLeft: 20 }}>
|
|
|
{index + 1 < 100 ? (
|
|
@@ -196,6 +204,13 @@ export const Profile: FC<Props> = ({
|
|
|
})}
|
|
|
</View>
|
|
|
</View>
|
|
|
+ {modalType && (
|
|
|
+ <WarningModal
|
|
|
+ type={modalType}
|
|
|
+ isVisible={true}
|
|
|
+ onClose={() => setModalType(null)}
|
|
|
+ />
|
|
|
+ )}
|
|
|
</View>
|
|
|
);
|
|
|
};
|