Skip to content

Commit

Permalink
Merge pull request #529 from TAMUSHPE/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
JasonIsAzn authored Sep 13, 2024
2 parents 3c116c4 + eeb9e0f commit 397f9ba
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -54,7 +54,7 @@
"permissions": [
"android.permission.RECORD_AUDIO"
],
"versionCode": 87,
"versionCode": 90,
"userInterfaceStyle": "automatic",
"config": {
"googleMaps": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
46 changes: 37 additions & 9 deletions src/screens/home/MemberSHPE.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HomeStackParams>) => {
const userContext = useContext(UserContext);
Expand Down Expand Up @@ -95,22 +95,41 @@ const MemberSHPE = ({ navigation }: NativeStackScreenProps<HomeStackParams>) =>
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);
}
}
};

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();
Expand Down Expand Up @@ -166,10 +185,19 @@ const MemberSHPE = ({ navigation }: NativeStackScreenProps<HomeStackParams>) =>

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);
Expand Down

0 comments on commit 397f9ba

Please sign in to comment.