diff --git a/app.json b/app.json index 2b7d8682..ab63ad26 100644 --- a/app.json +++ b/app.json @@ -2,7 +2,7 @@ "expo": { "name": "TAMU SHPE", "slug": "TAMU-SHPE", - "version": "1.0.15", + "version": "1.0.16", "owner": "tamu-shpe", "orientation": "portrait", "icon": "./assets/icon.png", @@ -54,7 +54,7 @@ "permissions": [ "android.permission.RECORD_AUDIO" ], - "versionCode": 87, + "versionCode": 90, "userInterfaceStyle": "automatic", "config": { "googleMaps": { diff --git a/package.json b/package.json index a3f4181a..661ed312 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shpe-app", - "version": "1.0.15", + "version": "1.0.16", "scripts": { "start": "npx expo start --dev-client", "test": "jest --coverage=true --verbose --bail --config ./jest.config.ts", diff --git a/src/screens/home/MemberSHPE.tsx b/src/screens/home/MemberSHPE.tsx index 9a0b464c..0f15d046 100644 --- a/src/screens/home/MemberSHPE.tsx +++ b/src/screens/home/MemberSHPE.tsx @@ -20,7 +20,7 @@ import { HomeStackParams } from '../../types/navigation'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; import { Images } from '../../../assets'; -const linkIDs = ["6", "7", "8"]; // ids reserved for TAMU and SHPE National links +const linkIDs = ["6", "7", "8"]; // ids reserved for TAMU, SHPE National links, Google Form const MemberSHPE = ({ navigation }: NativeStackScreenProps) => { const userContext = useContext(UserContext); @@ -95,10 +95,18 @@ const MemberSHPE = ({ navigation }: NativeStackScreenProps) => else { const document = await selectDocument(); if (document) { - setLoading(true); - const path = `user-docs/${auth.currentUser?.uid}/${type}-verification`; + const { blob, extension } = document; + + if (!blob) { + alert("File Selection Error: The selected file is invalid."); + setLoading(false); + return; + } + + const path = `user-docs/${auth.currentUser?.uid}/${type}-verification.${extension}`; const onSuccess = type === 'national' ? onNationalUploadSuccess : onChapterUploadSuccess; - uploadFile(document, [...CommonMimeTypes.IMAGE_FILES, ...CommonMimeTypes.RESUME_FILES], path, onSuccess); + + uploadFile(blob, [...CommonMimeTypes.IMAGE_FILES, ...CommonMimeTypes.RESUME_FILES], path, onSuccess); } } }; @@ -106,11 +114,22 @@ const MemberSHPE = ({ navigation }: NativeStackScreenProps) => const selectDocument = async () => { const result = await selectFile(); if (result) { - const blob = await getBlobFromURI(result.assets![0].uri); - return blob; + const fileUri = result.assets![0].uri; + + const fileExtension = fileUri.split('.').pop(); + + if (!fileExtension) { + alert("The file does not have an extension. Please select a valid file."); + return null; + } + + const blob = await getBlobFromURI(fileUri); + + return { blob, extension: fileExtension }; } return null; - } + }; + const onNationalUploadSuccess = async (URL: string) => { const today = new Date(); @@ -166,10 +185,19 @@ const MemberSHPE = ({ navigation }: NativeStackScreenProps) => const document = await selectDocument(); if (document) { + const { blob, extension } = document; + + if (!blob) { + Alert.alert("File Selection Error", "The selected file is invalid."); + setLoading(false); + return; + } + setLoading(true); - const path = `user-docs/${auth.currentUser?.uid}/chapter-verification`; + const path = `user-docs/${auth.currentUser?.uid}/chapter-verification.${extension}`; const onSuccess = onChapterUploadSuccess; - uploadFile(document, [...CommonMimeTypes.IMAGE_FILES, ...CommonMimeTypes.RESUME_FILES], path, onSuccess); + + uploadFile(blob, [...CommonMimeTypes.IMAGE_FILES, ...CommonMimeTypes.RESUME_FILES], path, onSuccess); } setShowShirtModal(false);