Date: Fri, 16 Aug 2024 14:00:59 -0500
Subject: [PATCH 06/12] delete user tab
---
shpe-app-web/app/(main)/users/page.tsx | 25 -------------------------
shpe-app-web/app/components/Navbar.tsx | 22 +++-------------------
2 files changed, 3 insertions(+), 44 deletions(-)
delete mode 100644 shpe-app-web/app/(main)/users/page.tsx
diff --git a/shpe-app-web/app/(main)/users/page.tsx b/shpe-app-web/app/(main)/users/page.tsx
deleted file mode 100644
index 6c122c97..00000000
--- a/shpe-app-web/app/(main)/users/page.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-'use client'
-import Header from "@/components/Header";
-import { useRouter } from "next/navigation";
-import { useEffect, useState } from "react";
-
-const Users = () => {
- const router = useRouter();
- const [loading, setLoading] = useState(true);
-
- if (loading) {
- return (
-
-
-
- );
- }
-
- return (
-
-
-
- );
-}
-
-export default Users;
\ No newline at end of file
diff --git a/shpe-app-web/app/components/Navbar.tsx b/shpe-app-web/app/components/Navbar.tsx
index d7ae4fdf..6ac98293 100644
--- a/shpe-app-web/app/components/Navbar.tsx
+++ b/shpe-app-web/app/components/Navbar.tsx
@@ -23,9 +23,9 @@ const Navbar = () => {
{path == '/dashboard' ?
-
- : ''
+
+ : ''
}
@@ -98,22 +98,6 @@ const Navbar = () => {
-
-
-
- {
-
- path == '/users' ?
-
- : ''
-
- }
-
-
From 51fe8b3f9ae2ac5c98ca6135eb573731b78b9d3f Mon Sep 17 00:00:00 2001
From: Jason
Date: Fri, 16 Aug 2024 14:20:19 -0500
Subject: [PATCH 07/12] fix destroy event on home screen, fix navigation in
home screen
---
src/api/firebaseUtils.ts | 4 +++-
src/navigation/EventsStack.tsx | 3 +++
src/screens/events/UpdateEvent.tsx | 13 ++++++++++---
src/screens/home/Home.tsx | 14 ++++++++++++--
src/types/navigation.ts | 1 +
5 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/src/api/firebaseUtils.ts b/src/api/firebaseUtils.ts
index 75eb1c02..83862aa7 100644
--- a/src/api/firebaseUtils.ts
+++ b/src/api/firebaseUtils.ts
@@ -1291,7 +1291,9 @@ export const getMyEvents = async (committees: string[], interests: string[], max
querySnapshots.forEach(querySnapshot => {
querySnapshot.forEach(doc => {
if (!allEvents.has(doc.id)) {
- allEvents.set(doc.id, doc.data());
+ const eventData = doc.data();
+ eventData.id = doc.id;
+ allEvents.set(doc.id, eventData);
}
});
});
diff --git a/src/navigation/EventsStack.tsx b/src/navigation/EventsStack.tsx
index 943bae1b..be994b35 100644
--- a/src/navigation/EventsStack.tsx
+++ b/src/navigation/EventsStack.tsx
@@ -13,6 +13,7 @@ import SetLocationEventDetails from "../screens/events/SetLocationEventDetails";
import EventVerification from "../screens/events/EventVerification";
import PublicProfileScreen from "../screens/userProfile/PublicProfile";
import PastEvents from "../screens/events/PastEvents";
+import Home from "../screens/home/Home";
const EventsStack = () => {
const Stack = createNativeStackNavigator();
@@ -35,6 +36,8 @@ const EventsStack = () => {
+
+
);
};
diff --git a/src/screens/events/UpdateEvent.tsx b/src/screens/events/UpdateEvent.tsx
index 23875008..73d03b5f 100644
--- a/src/screens/events/UpdateEvent.tsx
+++ b/src/screens/events/UpdateEvent.tsx
@@ -1,7 +1,7 @@
import { View, Text, TouchableOpacity, TextInput, Image, Platform, TouchableHighlight, Modal, Alert, ActivityIndicator, useColorScheme } from 'react-native'
import React, { useContext, useState } from 'react'
import { EventProps, UpdateEventScreenRouteProp } from '../../types/navigation'
-import { useRoute } from '@react-navigation/core';
+import { useNavigationState, useRoute } from '@react-navigation/core';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { Octicons, FontAwesome } from '@expo/vector-icons';
import { CommitteeMeeting, EventType, GeneralMeeting, IntramuralEvent, CustomEvent, SHPEEvent, SocialEvent, StudyHours, VolunteerEvent, Workshop } from '../../types/events';
@@ -26,9 +26,11 @@ import DismissibleModal from '../../components/DismissibleModal';
const UpdateEvent = ({ navigation }: EventProps) => {
const route = useRoute();
const { event } = route.params;
-
const userContext = useContext(UserContext);
const { userInfo } = userContext!;
+ const routes = useNavigationState(state => state.routes);
+ const isInHomeStack = routes.some(route => route.name === 'Home');
+
const fixDarkMode = userInfo?.private?.privateInfo?.settings?.darkMode;
const useSystemDefault = userInfo?.private?.privateInfo?.settings?.useSystemDefault;
@@ -157,9 +159,14 @@ const UpdateEvent = ({ navigation }: EventProps) => {
};
const handleDestroyEvent = async () => {
+ console.log("Destroying event with ID:", event.id);
const isDeleted = await destroyEvent(event.id!);
if (isDeleted) {
- navigation.navigate("EventsScreen", {})
+ if (isInHomeStack) {
+ navigation.navigate("Home")
+ } else {
+ navigation.navigate("EventsScreen", {})
+ }
} else {
console.log("Failed to delete the event.");
}
diff --git a/src/screens/home/Home.tsx b/src/screens/home/Home.tsx
index b7a11e65..db537a75 100644
--- a/src/screens/home/Home.tsx
+++ b/src/screens/home/Home.tsx
@@ -1,5 +1,5 @@
import { ActivityIndicator, Image, ScrollView, Text, TouchableOpacity, View, useColorScheme } from 'react-native';
-import React, { useContext, useEffect, useState } from 'react';
+import React, { useCallback, useContext, useEffect, useState } from 'react';
import { NativeStackScreenProps } from '@react-navigation/native-stack';
import { StatusBar } from 'expo-status-bar';
import { Octicons } from '@expo/vector-icons';
@@ -19,6 +19,7 @@ import { EventType, SHPEEvent } from '../../types/events';
import EventCard from '../events/EventCard';
import { reverseFormattedFirebaseName } from '../../types/committees';
import { doc, getDoc } from 'firebase/firestore';
+import { useFocusEffect } from '@react-navigation/core';
/**
* Renders the home screen of the application.
@@ -58,7 +59,7 @@ const Home = ({ navigation, route }: NativeStackScreenProps) =>
try {
setIsLoading(true);
- const events = await getMyEvents(userCommittees, userInterests, 3);
+ const events = await getMyEvents(userCommittees, userInterests, 4);
events.sort((a, b) => (a.startTime?.toDate().getTime() || 0) - (b.startTime?.toDate().getTime() || 0));
setMyEvents(events);
} catch (error) {
@@ -134,6 +135,15 @@ const Home = ({ navigation, route }: NativeStackScreenProps) =>
}
}, [currentUser]);
+ useFocusEffect(
+ useCallback(() => {
+ if (hasPrivileges) {
+
+ fetchEvents();
+ }
+ }, [hasPrivileges])
+ );
+
const isInterestChanged = () => {
if (!userInfo?.publicInfo?.interests) {
return userInterests.length > 0;
diff --git a/src/types/navigation.ts b/src/types/navigation.ts
index 9a662e25..81bc9dff 100644
--- a/src/types/navigation.ts
+++ b/src/types/navigation.ts
@@ -97,6 +97,7 @@ export type EventsStackParams = {
EventVerificationScreen: { id: string; mode: "sign-in" | "sign-out"; };
PublicProfile: { uid: string; };
+ Home: undefined;
}
export type CommitteesStackParams = {
From ab4965052a51f6be27a24007dfd2cfb2f9cc3893 Mon Sep 17 00:00:00 2001
From: Jason
Date: Fri, 16 Aug 2024 14:25:21 -0500
Subject: [PATCH 08/12] order request for committee
---
src/screens/admin/CommitteeConfirm.tsx | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/screens/admin/CommitteeConfirm.tsx b/src/screens/admin/CommitteeConfirm.tsx
index 96c98051..590ac9b2 100644
--- a/src/screens/admin/CommitteeConfirm.tsx
+++ b/src/screens/admin/CommitteeConfirm.tsx
@@ -47,10 +47,22 @@ const CommitteeConfirm = ({ navigation }: NativeStackScreenProps ({
- firebaseDocName: doc.id,
- ...doc.data() as Committee
- }))
+
+ const committees = await Promise.all(snapshot.docs.map(async doc => {
+ const firebaseDocName = doc.id;
+ const requestSnapshot = await getDocs(collection(db, `committeeVerification/${firebaseDocName}/requests`));
+ const requestCount = requestSnapshot.size; // Count the number of requests
+
+ return {
+ firebaseDocName,
+ requestCount, // Include request count
+ ...doc.data() as Committee
+ };
+ }));
+
+ // Sort committees by request count in descending order
+ committees.sort((a, b) => b.requestCount - a.requestCount);
+
setCommittees(committees);
} catch (err) {
console.error("Error fetching open committees:", err);
From e1edcdf3f548a524451c6066125c48243bf6f162 Mon Sep 17 00:00:00 2001
From: Jason
Date: Fri, 16 Aug 2024 14:28:49 -0500
Subject: [PATCH 09/12] add committee count scheduler
---
functions/src/committees.ts | 12 +++++++++---
functions/src/index.ts | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/functions/src/committees.ts b/functions/src/committees.ts
index ebc9577e..2a6c15db 100644
--- a/functions/src/committees.ts
+++ b/functions/src/committees.ts
@@ -1,7 +1,7 @@
import * as functions from 'firebase-functions';
-import { db } from "./firebaseConfig"
+import { db } from "./firebaseConfig";
-export const updateCommitteeCount = functions.https.onCall(async (data, context) => {
+async function updateCommitteeCounts() {
const committeesCount: CommitteeCounts = {};
const usersRef = db.collection('users');
@@ -24,10 +24,16 @@ export const updateCommitteeCount = functions.https.onCall(async (data, context)
console.log('Committee counts updated:', committeesCount);
return { message: 'Committee counts updated successfully', committeesCount };
+}
+
+export const updateCommitteeCount = functions.https.onCall(async (data, context) => {
+ return updateCommitteeCounts();
+});
+export const scheduleCommitteeCount = functions.pubsub.schedule('every 24 hours').onRun(async (context) => {
+ return updateCommitteeCounts();
});
interface CommitteeCounts {
[key: string]: number;
}
-
diff --git a/functions/src/index.ts b/functions/src/index.ts
index 7087a736..5c691d8c 100644
--- a/functions/src/index.ts
+++ b/functions/src/index.ts
@@ -1,6 +1,6 @@
export { notifyUpcomingEvents, sendNotificationOfficeHours, sendNotificationMemberSHPE, sendNotificationCommitteeRequest, sendNotificationResumeConfirm } from "./pushNotification";
export { updateUserPoints, updateAllUserPoints, scheduledUpdateAllPoints } from "./pointSheet";
-export { updateCommitteeCount } from "./committees";
+export { updateCommitteeCount, scheduleCommitteeCount } from "./committees";
// export { resetOfficeScheduler } from "./officeReset";
export { resetOfficeOnCall } from "./officeReset";
export { zipResume } from "./resume";
From 050fd3241ed7e0e44a56af2b2d3b9556812c202e Mon Sep 17 00:00:00 2001
From: Jason
Date: Fri, 16 Aug 2024 21:00:40 -0500
Subject: [PATCH 10/12] increase default image size
---
src/helpers/validation.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/helpers/validation.ts b/src/helpers/validation.ts
index c3d89468..04178f46 100644
--- a/src/helpers/validation.ts
+++ b/src/helpers/validation.ts
@@ -135,7 +135,7 @@ export abstract class CommonMimeTypes {
* console.log("Valid File");
* }
*/
-export const validateFileBlob = (file: Blob, allowedMimeTypes: Array, alertUser: boolean = false, maxSize: number = 8388608): boolean => {
+export const validateFileBlob = (file: Blob, allowedMimeTypes: Array, alertUser: boolean = false, maxSize: number = 32000000): boolean => {
const isValidMimeType = allowedMimeTypes.includes(file.type)
const isValidSize = file.size < maxSize;
const bytesInMegabyte = 1048576;
From 3b070eaec25cd66efbc4a578736d8ff498a644ae Mon Sep 17 00:00:00 2001
From: Jason
Date: Sat, 17 Aug 2024 13:18:28 -0500
Subject: [PATCH 11/12] fix motm card to fetch latest profile
---
src/components/MOTMCard.tsx | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/components/MOTMCard.tsx b/src/components/MOTMCard.tsx
index a989a3a5..4926d6c0 100644
--- a/src/components/MOTMCard.tsx
+++ b/src/components/MOTMCard.tsx
@@ -3,7 +3,7 @@ import React, { useCallback, useContext, useEffect, useState } from 'react'
import { MemberCardProp } from '../types/navigation'
import { Images } from '../../assets'
import { PublicUserInfo } from '../types/user'
-import { getMOTM } from '../api/firebaseUtils'
+import { getMOTM, getPublicUserData } from '../api/firebaseUtils'
import { useFocusEffect } from '@react-navigation/core'
import { UserContext } from '../context/UserContext'
import { truncateStringWithEllipsis } from '../helpers/stringUtils'
@@ -11,7 +11,7 @@ import { auth } from '../config/firebaseConfig'
const MOTMCard: React.FC = ({ navigation }) => {
const userContext = useContext(UserContext);
- const { userInfo, setUserInfo } = userContext!;
+ const { userInfo } = userContext!;
const fixDarkMode = userInfo?.private?.privateInfo?.settings?.darkMode;
const useSystemDefault = userInfo?.private?.privateInfo?.settings?.useSystemDefault;
@@ -35,7 +35,10 @@ const MOTMCard: React.FC = ({ navigation }) => {
const fetchMOTM = async () => {
try {
const fetchedMOTM = await getMOTM();
- setMOTM(fetchedMOTM);
+ if (fetchedMOTM?.uid) {
+ const motmData = await getPublicUserData(fetchedMOTM.uid);
+ setMOTM(motmData);
+ }
} catch (error) {
console.error('Error fetching member of the month:', error);
}
@@ -83,7 +86,7 @@ const MOTMCard: React.FC = ({ navigation }) => {
}}
>
From 70e5cf37f860eb60174df71462dd5e81df4c42be Mon Sep 17 00:00:00 2001
From: Jason
Date: Sat, 17 Aug 2024 13:20:02 -0500
Subject: [PATCH 12/12] version bump
---
app.json | 6 +++---
package.json | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app.json b/app.json
index a98743da..08ab180a 100644
--- a/app.json
+++ b/app.json
@@ -2,7 +2,7 @@
"expo": {
"name": "TAMU SHPE",
"slug": "TAMU-SHPE",
- "version": "1.0.2",
+ "version": "1.0.3",
"owner": "tamu-shpe",
"orientation": "portrait",
"icon": "./assets/icon.png",
@@ -59,8 +59,8 @@
},
"ios": {
"bundleIdentifier": "com.tamu.shpe",
- "buildNumber": "1",
- "userInterfaceStyle": "automatic"
+ "userInterfaceStyle": "automatic",
+ "buildNumber": "2"
},
"extra": {
"eas": {
diff --git a/package.json b/package.json
index 7a97fa80..d3696dcb 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "shpe-app",
- "version": "1.0.2",
+ "version": "1.0.3",
"scripts": {
"start": "npx expo start --dev-client",
"test": "jest --coverage=true --verbose --bail --config ./jest.config.ts",