|
@@ -7,13 +7,18 @@
|
|
|
|
|
|
import React, { memo } from "react"
|
|
|
import { View, Text } from "react-native"
|
|
|
+import { TouchableOpacity } from "react-native-gesture-handler"
|
|
|
import { useAuth } from "../../data/Auth/AuthContext"
|
|
|
import { useLandmarks } from "../../data/landmarks"
|
|
|
import { UserProfile } from "../../data/profiles"
|
|
|
+import { navigate } from "../../navigation/RootNavigator"
|
|
|
|
|
|
-export const ProfileHeader: React.FC<{profile?: UserProfile}> = memo(({profile}) => {
|
|
|
+let seeUserLandmarks = false;
|
|
|
+
|
|
|
+export const ProfileHeader: React.FC<{ profile?: UserProfile }> = memo(({ profile }) => {
|
|
|
const landmarkQuery = useLandmarks()
|
|
|
- const {landmarkOwnedByUser} = useAuth()
|
|
|
+ const { landmarkOwnedByUser } = useAuth()
|
|
|
+ const delay = ms => new Promise(res => setTimeout(res, ms));
|
|
|
|
|
|
const getLandmarkCount = () => {
|
|
|
return landmarkQuery?.data?.filter(lm => landmarkOwnedByUser(lm)).length
|
|
@@ -22,26 +27,37 @@ export const ProfileHeader: React.FC<{profile?: UserProfile}> = memo(({profile})
|
|
|
const getTotalLandmarkRating = () => {
|
|
|
const userLandmarks = landmarkQuery?.data?.filter(lm => landmarkOwnedByUser(lm))
|
|
|
if (userLandmarks?.length > 0)
|
|
|
- return userLandmarks?.reduce((prev, current) => {return {rating: prev.rating + current.rating}}).rating
|
|
|
- else
|
|
|
+ return userLandmarks?.reduce((prev, current) => { return { rating: prev.rating + current.rating } }).rating
|
|
|
+ else
|
|
|
return 0
|
|
|
}
|
|
|
|
|
|
+ const seeOwnLandmarks = async () => {
|
|
|
+ navigate("Outdoor");
|
|
|
+ seeUserLandmarks = true;
|
|
|
+ await delay(1000); // Give the FilterPanel time to react to seeUserLandmarks changing
|
|
|
+ seeUserLandmarks = false
|
|
|
+ }
|
|
|
+
|
|
|
return (
|
|
|
- <View style={{marginTop: 10, flexDirection: 'row', width: '100%', marginBottom: 20}}>
|
|
|
- <View style={{flexBasis: "50%"}}>
|
|
|
- <Text style={{fontSize: 17, textAlign: 'center'}}>{getLandmarkCount()}</Text>
|
|
|
- <Text style={{textAlign: 'center'}}>Landmarks</Text>
|
|
|
+ <View style={{ marginTop: 10, flexDirection: 'row', width: '100%', marginBottom: 20 }}>
|
|
|
+ <View style={{ flexBasis: "50%" }}>
|
|
|
+ <TouchableOpacity onPress={() => {seeOwnLandmarks()}}>
|
|
|
+ <Text style={{ fontSize: 17, textAlign: 'center' }}>{getLandmarkCount()}</Text>
|
|
|
+ <Text style={{ textAlign: 'center' }}>Landmarks</Text>
|
|
|
+ </TouchableOpacity>
|
|
|
</View>
|
|
|
{/* This will be implemented when the social network feature is added
|
|
|
<View style={{flexBasis: "33%"}}>
|
|
|
<Text style={{fontSize: 10, textAlign: 'center'}}>Not yet implemented</Text>
|
|
|
<Text style={{textAlign: 'center'}}>Friends</Text>
|
|
|
</View> */}
|
|
|
- <View style={{flexBasis: "50%"}}>
|
|
|
- <Text style={{fontSize: 17, textAlign: 'center'}}>{getTotalLandmarkRating()}</Text>
|
|
|
- <Text style={{textAlign: 'center'}}>Rating</Text>
|
|
|
+ <View style={{ flexBasis: "50%" }}>
|
|
|
+ <Text style={{ fontSize: 17, textAlign: 'center' }}>{getTotalLandmarkRating()}</Text>
|
|
|
+ <Text style={{ textAlign: 'center' }}>Rating</Text>
|
|
|
</View>
|
|
|
</View>
|
|
|
)
|
|
|
-})
|
|
|
+})
|
|
|
+
|
|
|
+export {seeUserLandmarks};
|