From 098969cbd94fd74fe00ed974d9c019ad434a2f8a Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 20 Apr 2021 14:34:10 -0400 Subject: modified style to match figma --- src/components/notifications/Notification.tsx | 71 +++++++++++++++++---------- src/types/types.ts | 4 +- 2 files changed, 47 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index 8e008cf9..d66ca45e 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -57,6 +57,8 @@ const Notification: React.FC = (props) => { const [avatar, setAvatar] = useState(undefined); const [momentURI, setMomentURI] = useState(undefined); + const isSystemNotification = + username === 'Tagg' && notification_type === 'PROF_VIST'; useEffect(() => { (async () => { @@ -208,6 +210,9 @@ const Notification: React.FC = (props) => { const isOwnProfile = id === loggedInUser.userId; const navigateToProfile = async () => { + if (isSystemNotification) { + return; + } if (!userXInStore(state, screenType, id)) { await fetchUserX(dispatch, {userId: id, username: username}, screenType); } @@ -231,35 +236,47 @@ const Notification: React.FC = (props) => { } /> - - - - {first_name} {last_name} - - - - {verbage} - - - {notification_type === 'FRD_REQ' && ( - - + {isSystemNotification ? ( + // Only verbage + + {verbage} + ) : ( + <> + {/* Text content: Actor name and verbage*/} + + + + {first_name} {last_name} + + + + {verbage} + + + {/* Friend request accept/decline button */} + {notification_type === 'FRD_REQ' && ( + + + + )} + {/* Moment Image Preview */} + {(notification_type === 'CMT' || + notification_type === 'MOM_3+' || + notification_type === 'MOM_FRIEND') && + notification_object && ( + + + + )} + )} - {(notification_type === 'CMT' || - notification_type === 'MOM_3+' || - notification_type === 'MOM_FRIEND') && - notification_object && ( - - - - )} ); diff --git a/src/types/types.ts b/src/types/types.ts index 376c4be0..b8746eea 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -251,7 +251,9 @@ export type TypeOfNotification = // notification_object is MomentType | 'MOM_FRIEND' // notification_object is undefined - | 'INVT_ONBRD'; + | 'INVT_ONBRD' + // notification_object is undefined + | 'PROF_VIST'; export type UniversityBadge = { id: number; -- cgit v1.2.3-70-g09d2 From 419681ad0d832808caec5252fb65aa154b0e4ae2 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 20 Apr 2021 14:40:18 -0400 Subject: created SYSTEM_MSG --- src/components/notifications/Notification.tsx | 6 ++---- src/types/types.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/components/notifications/Notification.tsx b/src/components/notifications/Notification.tsx index d66ca45e..3cc1c7f1 100644 --- a/src/components/notifications/Notification.tsx +++ b/src/components/notifications/Notification.tsx @@ -57,8 +57,6 @@ const Notification: React.FC = (props) => { const [avatar, setAvatar] = useState(undefined); const [momentURI, setMomentURI] = useState(undefined); - const isSystemNotification = - username === 'Tagg' && notification_type === 'PROF_VIST'; useEffect(() => { (async () => { @@ -210,7 +208,7 @@ const Notification: React.FC = (props) => { const isOwnProfile = id === loggedInUser.userId; const navigateToProfile = async () => { - if (isSystemNotification) { + if (notification_type === 'SYSTEM_MSG') { return; } if (!userXInStore(state, screenType, id)) { @@ -236,7 +234,7 @@ const Notification: React.FC = (props) => { } /> - {isSystemNotification ? ( + {notification_type === 'SYSTEM_MSG' ? ( // Only verbage {verbage} diff --git a/src/types/types.ts b/src/types/types.ts index b8746eea..8d7f4aed 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -253,7 +253,7 @@ export type TypeOfNotification = // notification_object is undefined | 'INVT_ONBRD' // notification_object is undefined - | 'PROF_VIST'; + | 'SYSTEM_MSG'; export type UniversityBadge = { id: number; -- cgit v1.2.3-70-g09d2 From e050709c3be4e9bae828caa6a01bfdab5f4bcfcf Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Wed, 21 Apr 2021 12:23:37 -0400 Subject: updated to use the new endpoint --- src/constants/api.ts | 1 + src/screens/profile/ProfileScreen.tsx | 9 ++++++++- src/services/UserProfileService.ts | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/constants/api.ts b/src/constants/api.ts index cb45b238..dd934f0e 100644 --- a/src/constants/api.ts +++ b/src/constants/api.ts @@ -16,6 +16,7 @@ export const EDIT_PROFILE_ENDPOINT: string = API_URL + 'edit-profile/'; export const SEND_OTP_ENDPOINT: string = API_URL + 'send-otp/'; export const VERIFY_OTP_ENDPOINT: string = API_URL + 'verify-otp/'; export const USER_PROFILE_ENDPOINT: string = API_URL + 'profile/'; +export const USER_PROFILE_VISITED_ENDPOINT: string = API_URL + 'profile/visited/'; export const PROFILE_INFO_ENDPOINT: string = API_URL + 'user-profile-info/'; export const HEADER_PHOTO_ENDPOINT: string = API_URL + 'header-pic/'; export const PROFILE_PHOTO_ENDPOINT: string = API_URL + 'profile-pic/'; diff --git a/src/screens/profile/ProfileScreen.tsx b/src/screens/profile/ProfileScreen.tsx index 6d9ef020..3dd142e1 100644 --- a/src/screens/profile/ProfileScreen.tsx +++ b/src/screens/profile/ProfileScreen.tsx @@ -1,8 +1,9 @@ -import React from 'react'; +import React, {useEffect} from 'react'; import {StatusBar} from 'react-native'; import {Content, TabsGradient} from '../../components'; import {RouteProp} from '@react-navigation/native'; import {MainStackParams} from '../../routes/'; +import {visitedUserProfile} from '../../services'; type ProfileScreenRouteProps = RouteProp; @@ -14,6 +15,12 @@ const ProfileScreen: React.FC = ({route}) => { const {screenType} = route.params; let {userXId} = route.params; + useEffect(() => { + if (userXId) { + visitedUserProfile(userXId); + } + }); + return ( <> diff --git a/src/services/UserProfileService.ts b/src/services/UserProfileService.ts index 1ce1d0b5..a2237c94 100644 --- a/src/services/UserProfileService.ts +++ b/src/services/UserProfileService.ts @@ -16,6 +16,7 @@ import { SEND_OTP_ENDPOINT, TAGG_CUSTOMER_SUPPORT, USER_PROFILE_ENDPOINT, + USER_PROFILE_VISITED_ENDPOINT, VERIFY_OTP_ENDPOINT, } from '../constants'; import { @@ -412,3 +413,24 @@ export const patchEditProfile = async (form: FormData, userId: string) => { throw ERROR_DOUBLE_CHECK_CONNECTION; } }; + +export const visitedUserProfile = async (userId: string) => { + try { + const token = await AsyncStorage.getItem('token'); + const form = new FormData(); + form.append('user_id', userId); + const response = await fetch(USER_PROFILE_VISITED_ENDPOINT, { + method: 'POST', + headers: { + 'Content-Type': 'multipart/form-data', + Authorization: 'Token ' + token, + }, + body: form, + }); + if (response.status !== 200) { + console.error('Failed to submit a profile visit'); + } + } catch (error) { + return undefined; + } +}; -- cgit v1.2.3-70-g09d2