aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/constants/api.ts2
-rw-r--r--src/screens/onboarding/InvitationCodeVerification.tsx2
-rw-r--r--src/screens/profile/CaptionScreen.tsx15
3 files changed, 15 insertions, 4 deletions
diff --git a/src/constants/api.ts b/src/constants/api.ts
index b1ec19aa..d5733592 100644
--- a/src/constants/api.ts
+++ b/src/constants/api.ts
@@ -12,5 +12,5 @@ export const COVER_PHOTO_ENDPOINT: string = API_URL + 'large-profile-pic/';
export const AVATAR_PHOTO_ENDPOINT: string = API_URL + 'small-profile-pic/';
export const GET_IG_POSTS_ENDPOINT: string = API_URL + 'posts-ig/';
export const SEARCH_ENDPOINT: string = API_URL + 'search/';
-export const MOMENTS_UPLOAD_ENDPOINT: string = API_URL + 'upload-moments/';
+export const MOMENTS_UPLOAD_ENDPOINT: string = API_URL + 'moments/';
export const VERIFY_INVITATION_CODE_ENDPOUNT: string = API_URL + 'verify-code/';
diff --git a/src/screens/onboarding/InvitationCodeVerification.tsx b/src/screens/onboarding/InvitationCodeVerification.tsx
index 9af288b4..fd5f828b 100644
--- a/src/screens/onboarding/InvitationCodeVerification.tsx
+++ b/src/screens/onboarding/InvitationCodeVerification.tsx
@@ -53,7 +53,7 @@ const InvitationCodeVerification: React.FC<InvitationCodeVerificationProps> = ({
});
const handleInvitationCodeVerification = async () => {
- if(value.length == 6){
+ if(value.length === 6){
try {
let verifyInviteCodeResponse = await fetch(VERIFY_INVITATION_CODE_ENDPOUNT + value + '/', {
method: 'DELETE',
diff --git a/src/screens/profile/CaptionScreen.tsx b/src/screens/profile/CaptionScreen.tsx
index 3eb6c47b..e3040509 100644
--- a/src/screens/profile/CaptionScreen.tsx
+++ b/src/screens/profile/CaptionScreen.tsx
@@ -42,6 +42,15 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
setCaption(caption);
};
+ const checkImageUploadStatus = (statusMap : object) => {
+ for(let [key, value] of Object.entries(statusMap)){
+ if (value != "Success"){
+ return false;
+ }
+ }
+ return true;
+ }
+
const handleShare = async () => {
try {
const token = await AsyncStorage.getItem('token');
@@ -59,7 +68,7 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
});
request.append('moment', title);
request.append('user_id', userId);
- request.append('caption', caption);
+ request.append('captions', JSON.stringify({'image':caption}));
let response = await fetch(MOMENTS_UPLOAD_ENDPOINT, {
method: 'POST',
headers: {
@@ -69,7 +78,9 @@ const CaptionScreen: React.FC<CaptionScreenProps> = ({route, navigation}) => {
body: request,
});
let statusCode = response.status;
- if (statusCode === 200) {
+ let data = await response.json();
+ if (statusCode === 200 && checkImageUploadStatus(data)) {
+ Alert.alert('The picture was uploaded successfully!');
navigation.navigate('Profile');
} else {
Alert.alert('An error occured while uploading. Please try again!');