Browse Source

profile updates

Viktoriia 10 months ago
parent
commit
43d510e5c1

+ 9 - 0
assets/icons/travels-section/unp.svg

@@ -0,0 +1,9 @@
+<svg width="18" height="20" viewBox="0 0 18 20" fill="none" xmlns="http://www.w3.org/2000/svg">
+<mask id="mask0_3928_35979" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="18" height="20">
+<path d="M17.6177 0H0V19.753H17.6177V0Z" fill="white"/>
+</mask>
+<g mask="url(#mask0_3928_35979)">
+<path fill-rule="evenodd" clip-rule="evenodd" d="M0 18.686V3.73766C0 3.14705 0.477132 2.66992 1.06774 2.66992C1.65832 2.66992 2.13548 3.14705 2.13548 3.73766L2.13535 4.27105L4.43766 3.69092C5.7089 3.37394 7.05354 3.52075 8.22468 4.10799C9.76952 4.88208 11.588 4.88208 13.1328 4.10799L13.4531 3.94783C14.1404 3.60417 14.9479 4.10465 14.9479 4.87207V13.2168C14.9479 13.6639 14.671 14.061 14.2539 14.2178L13.0961 14.6516C11.5546 15.2321 9.84292 15.142 8.36815 14.4047C7.10359 13.774 5.65217 13.6139 4.28084 13.9576L2.13548 14.4946V18.686C2.13548 19.2765 1.65832 19.7536 1.06774 19.7536C0.477132 19.7536 0 19.2765 0 18.686ZM2.13545 12.8427L3.89046 12.4027C5.63549 11.9689 7.47395 12.1691 9.08218 12.9733C10.1566 13.5105 11.4078 13.5738 12.5322 13.1534L13.3463 12.8498V5.76961C11.4678 6.53369 9.3391 6.45694 7.50731 5.54272C6.67651 5.12898 5.72558 5.02555 4.8247 5.2491L2.13538 5.92282L2.13545 12.8427Z" fill="#0F3F4F"/>
+<path d="M3.73733 0C3.14671 0 2.66968 0.477036 2.66968 1.06765V2.56197C2.75165 2.71407 2.80301 2.88493 2.80301 3.06962V3.60394L5.10523 3.02617C6.37634 2.70913 7.72152 2.85629 8.89188 3.44295C10.4376 4.21727 12.2558 4.21727 13.8005 3.44295L14.1205 3.28295C14.8079 2.93925 15.6158 3.43999 15.6158 4.2074V11.9545C15.6662 11.9368 15.7166 11.921 15.7659 11.9022L16.9235 11.4686C17.3412 11.3116 17.6178 10.9145 17.6178 10.4671V2.20543C17.6178 1.43802 16.8099 0.937282 16.1225 1.28098L15.8025 1.44098C14.2578 2.2153 12.4395 2.2153 10.8948 1.44098C9.72349 0.854319 8.37831 0.707159 7.1072 1.02419L4.80498 1.60197V1.06765C4.80498 0.477036 4.32795 0 3.73733 0ZM4.80498 13.2454L2.80301 13.7471V16.5234C2.98375 16.8563 3.3314 17.0834 3.73733 17.0834C4.32795 17.0834 4.80498 16.6064 4.80498 16.0158V13.2454Z" fill="#0F3F4F"/>
+</g>
+</svg>

+ 5 - 1
src/modules/api/user/queries/use-post-get-profile-updates.tsx

@@ -5,7 +5,11 @@ import { type PostGetProfileUpdatesReturn, userApi } from '../user-api';
 
 import type { BaseAxiosError } from '../../../../types';
 
-export const usePostGetProfileUpdatesQuery = (token: string, userId: number, enabled: boolean) => {
+export const usePostGetProfileUpdatesQuery = (
+  token: string,
+  userId: number,
+  enabled: boolean
+) => {
   return useQuery<PostGetProfileUpdatesReturn, BaseAxiosError>({
     queryKey: userQueryKeys.getProfileUpdates(userId),
     queryFn: async () => {

+ 9 - 9
src/modules/api/user/user-api.tsx

@@ -267,16 +267,16 @@ export interface PostGetProfileDataReturn extends ResponseType {
 export interface PostGetProfileUpdatesReturn extends ResponseType {
   data: {
     can_see_updates: 0 | 1;
-    friends_total: number;
     updates: {
-      countries: number;
-      dare: number;
-      friends: number;
-      new_nm: number;
-      photos: number;
-      series: number;
-      visited_regions: number;
-      whs: number;
+      un_visited: number;
+      un_new: number;
+      unp_visited: number;
+      unp_new: number;
+      nm_visited: number;
+      nm_new: number;
+      new_dare: number;
+      new_series: number;
+      new_whs: number;
     };
   };
 }

+ 70 - 74
src/screens/InAppScreens/ProfileScreen/Components/PersonalInfo.tsx

@@ -7,13 +7,12 @@ import Tooltip from 'react-native-walkthrough-tooltip';
 import RegionsRenderer from '../RegionsRenderer';
 
 import CompassIcon from 'assets/icons/travels-section/compass.svg';
-import FriendsIcon from 'assets/icons/user-group.svg';
 import FlagsIcon from 'assets/icons/travels-section/flags.svg';
-import PhotosIcon from 'assets/icons/travels-section/images.svg';
 import RegionsIcon from 'assets/icons/travels-section/regions.svg';
 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 { styles } from './styles';
 import { InfoItem } from './InfoItem';
@@ -46,15 +45,16 @@ type PersonalInfoProps = {
     ownProfile: 0 | 1;
   };
   updates: {
-    countries: number;
-    dare: number;
-    friends: number;
-    new_nm: number;
-    photos: number;
-    series: number;
-    visited_regions: number;
-    whs: number;
-  };
+    un_visited: number;
+    un_new: number;
+    unp_visited: number;
+    unp_new: number;
+    nm_visited: number;
+    nm_new: number;
+    new_dare: number;
+    new_series: number;
+    new_whs: number;
+  } | null;
   userId: number;
   navigation: NavigationProp<any>;
   isPublicView: boolean;
@@ -151,15 +151,15 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
   };
 
   const hasUpdates = () => {
+    if (!updates) return false;
+
     return (
-      (updates.countries && updates.countries > 0) ||
-      (updates.visited_regions && updates.visited_regions > 0) ||
-      (updates.dare && updates.dare > 0) ||
-      (updates.series && updates.series > 0) ||
-      (updates.whs && updates.whs > 0) ||
-      (updates.new_nm && updates.new_nm > 0) ||
-      (updates.photos && updates.photos > 0) ||
-      (updates.friends && updates.friends > 0)
+      (updates.un_visited && updates.un_visited > 0) ||
+      (updates.unp_visited && updates.unp_visited > 0) ||
+      (updates.nm_visited && updates.nm_visited > 0) ||
+      (updates.new_dare && updates.new_dare > 0) ||
+      (updates.new_series && updates.new_series > 0) ||
+      (updates.new_whs && updates.new_whs > 0)
     );
   };
 
@@ -228,7 +228,7 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
         ) : null}
 
         {data.friends.length > 0 ? (
-          <InfoItem inline={true} title={'FRIENDS'}>
+          <InfoItem inline={true} title={`FRIENDS (${data.friends.length})`}>
             <View style={{ flexDirection: 'row', flex: 1 }}>
               {data.friends.slice(0, maxAvatars).map((friend, index) => (
                 <Tooltip
@@ -317,79 +317,75 @@ export const PersonalInfo: FC<PersonalInfoProps> = ({
           </InfoItem>
         ) : null}
 
-        {hasUpdates() ? (
-          <InfoItem title={'UPDATES (last 90 days)'}>
+        {updates && hasUpdates() ? (
+          <InfoItem title={'Visited in the last 90 days'}>
             <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
-              {updates.countries && updates.countries > 0 ? (
+              {updates.un_visited && updates.un_visited > 0 ? (
                 <View style={styles.updates}>
                   <FlagsIcon fill={Colors.DARK_BLUE} height={20} width={20} />
-                  <View>
-                    <Text style={styles.updatesTextCount}>+{updates.countries}</Text>
-                    <Text style={styles.updatesText}>visited countries</Text>
-                  </View>
+                  {updates.un_new && updates.un_new > 0 ? (
+                    <View>
+                      <Text style={styles.updatesText}>
+                        {updates.un_visited} (+{updates.un_new} new)
+                      </Text>
+                      <Text style={styles.updatesText}>UN countries</Text>
+                    </View>
+                  ) : (
+                    <Text style={styles.updatesText}>{updates.un_visited} UN countries</Text>
+                  )}
+                </View>
+              ) : null}
+
+              {updates.unp_visited && updates.unp_visited > 0 ? (
+                <View style={styles.updates}>
+                  <UNPIcon fill={Colors.DARK_BLUE} height={20} width={20} />
+                  {updates.unp_new && updates.unp_new > 0 ? (
+                    <View>
+                      <Text style={styles.updatesText}>
+                        {updates.unp_visited} (+{updates.unp_new} new)
+                      </Text>
+                      <Text style={styles.updatesText}>UN+ states</Text>
+                    </View>
+                  ) : (
+                    <Text style={styles.updatesText}>{updates.unp_visited} UN+ states</Text>
+                  )}
                 </View>
               ) : null}
-              {updates.visited_regions && updates.visited_regions > 0 ? (
+
+              {updates.nm_visited && updates.nm_visited > 0 ? (
                 <View style={styles.updates}>
                   <RegionsIcon fill={Colors.DARK_BLUE} height={20} width={20} />
-                  <View>
-                    <Text style={styles.updatesTextCount}>+{updates.visited_regions}</Text>
-                    <Text style={styles.updatesText}>visited regions</Text>
-                  </View>
+                  {updates.nm_new && updates.nm_new > 0 ? (
+                    <View>
+                      <Text style={styles.updatesText}>
+                        {updates.nm_visited} (+{updates.nm_new} new)
+                      </Text>
+                      <Text style={styles.updatesText}>NM regions</Text>
+                    </View>
+                  ) : (
+                    <Text style={styles.updatesText}>{updates.nm_visited} NM regions</Text>
+                  )}
                 </View>
               ) : null}
-              {updates.dare && updates.dare > 0 ? (
+
+              {updates.new_dare && updates.new_dare > 0 ? (
                 <View style={styles.updates}>
                   <CompassIcon fill={Colors.DARK_BLUE} height={20} width={20} />
-                  <View>
-                    <Text style={styles.updatesTextCount}>+{updates.dare}</Text>
-                    <Text style={styles.updatesText}>new DARE places</Text>
-                  </View>
+                  <Text style={styles.updatesText}>{updates.new_dare} new DARE</Text>
                 </View>
               ) : null}
-              {updates.series && updates.series > 0 ? (
+
+              {updates.new_series && updates.new_series > 0 ? (
                 <View style={styles.updates}>
                   <SeriesIcon fill={Colors.DARK_BLUE} height={20} width={20} />
-                  <View>
-                    <Text style={styles.updatesTextCount}>+{updates.series}</Text>
-                    <Text style={styles.updatesText}>new series</Text>
-                  </View>
+                  <Text style={styles.updatesText}>{updates.new_series} new Series</Text>
                 </View>
               ) : null}
-              {updates.whs && updates.whs > 0 ? (
+
+              {updates.new_whs && updates.new_whs > 0 ? (
                 <View style={styles.updates}>
                   <WHSIcon fill={Colors.DARK_BLUE} height={20} width={20} />
-                  <View>
-                    <Text style={styles.updatesTextCount}>+{updates.whs}</Text>
-                    <Text style={styles.updatesText}>new WHS sites</Text>
-                  </View>
-                </View>
-              ) : null}
-              {updates.new_nm && updates.new_nm > 0 ? (
-                <View style={styles.updates}>
-                  <RegionsIcon fill={Colors.DARK_BLUE} height={20} width={20} />
-                  <View>
-                    <Text style={styles.updatesTextCount}>+{updates.new_nm}</Text>
-                    <Text style={styles.updatesText}>new NM regions</Text>
-                  </View>
-                </View>
-              ) : null}
-              {updates.photos && updates.photos > 0 ? (
-                <View style={styles.updates}>
-                  <PhotosIcon fill={Colors.DARK_BLUE} height={20} width={20} />
-                  <View>
-                    <Text style={styles.updatesTextCount}>+{updates.photos}</Text>
-                    <Text style={styles.updatesText}>new photos</Text>
-                  </View>
-                </View>
-              ) : null}
-              {updates.friends && updates.friends > 0 ? (
-                <View style={styles.updates}>
-                  <FriendsIcon fill={Colors.DARK_BLUE} height={20} width={20} />
-                  <View>
-                    <Text style={styles.updatesTextCount}>+{updates.friends}</Text>
-                    <Text style={styles.updatesText}>new friends</Text>
-                  </View>
+                  <Text style={styles.updatesText}>{updates.new_whs} new WHS</Text>
                 </View>
               ) : null}
             </View>

+ 2 - 3
src/screens/InAppScreens/ProfileScreen/index.tsx

@@ -4,7 +4,6 @@ import { CommonActions, NavigationProp, useFocusEffect } from '@react-navigation
 import ReactModal from 'react-native-modal';
 
 import { usePostGetProfileInfoDataQuery, usePostGetProfileUpdatesQuery } from '@api/user';
-
 import {
   PageWrapper,
   Loading,
@@ -100,7 +99,7 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
     }
   }, [userData]);
 
-  if (!userData?.data || !lastUpdates?.data || isFetching) return <Loading />;
+  if (!userData?.data || !lastUpdates || isFetching) return <Loading />;
 
   const data = userData.data;
   const links = JSON.parse(data.user_data.links_json);
@@ -325,7 +324,7 @@ const ProfileScreen: FC<Props> = ({ navigation, route }) => {
             friendDbId: data.friend_db_id,
             ownProfile: data.own_profile
           }}
-          updates={lastUpdates.data.updates}
+          updates={lastUpdates?.data ? lastUpdates.data?.updates : null}
           userId={isPublicView ? route.params?.userId : +currentUserId}
           navigation={navigation}
           isPublicView={isPublicView}

+ 1 - 1
src/types/api.ts

@@ -99,7 +99,7 @@ export enum API_ENDPOINT {
   GET_SUGGESTION_DATA = 'get-suggestion-data',
   SUBMIT_SUGGESTION = 'submit-suggestion',
   GET_PROGILE_DATA = 'get-profile-data',
-  GET_PROFILE_UPDATES = 'get-profile-updates',
+  GET_PROFILE_UPDATES = 'get-profile-updates-2',
   GET_FRIENDS = 'load-friends-app',
   SEND_FRIEND_REQUEST = 'send-friend-request',
   LOAD_FRIENDS_SETTINGS = 'load-friends-settings-app',