From 5875b628901562e612f57ffd192f6747a6a9c6cf Mon Sep 17 00:00:00 2001 From: Heryan Djaruma Date: Sat, 19 Jul 2025 14:47:48 +0700 Subject: [PATCH 1/3] add local dev config --- lib/firebase.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/firebase.ts b/lib/firebase.ts index 2a88e7d..369562e 100644 --- a/lib/firebase.ts +++ b/lib/firebase.ts @@ -1,6 +1,6 @@ import { initializeApp } from 'firebase/app'; -import { getAuth, GoogleAuthProvider } from 'firebase/auth'; -import { getFirestore } from 'firebase/firestore'; +import { connectAuthEmulator, getAuth, GoogleAuthProvider } from 'firebase/auth'; +import { connectFirestoreEmulator, getFirestore } from 'firebase/firestore'; import { getStorage } from 'firebase/storage'; const firebaseConfig = { @@ -30,4 +30,12 @@ googleProvider.setCustomParameters({ hd: "garudahacks.com", }); +if (process.env.NEXT_PUBLIC_ENVIRONMENT === "development") { + connectAuthEmulator(auth, "http://localhost:9099", { + disableWarnings: false, + }); + connectFirestoreEmulator(db, "localhost", 8080); + console.log("Connected to Firebase emulators"); +} + export default app; From 4b1fb88e5026f8f9bfa3aa1c8f396fe58b5f5ce9 Mon Sep 17 00:00:00 2001 From: Heryan Djaruma Date: Sat, 19 Jul 2025 14:47:56 +0700 Subject: [PATCH 2/3] minor fix for optional fields --- app/mentorship/[mentorId]/page.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/mentorship/[mentorId]/page.tsx b/app/mentorship/[mentorId]/page.tsx index 5b31b40..4b0f03d 100644 --- a/app/mentorship/[mentorId]/page.tsx +++ b/app/mentorship/[mentorId]/page.tsx @@ -57,11 +57,10 @@ export default function MentorDetailPage() { }} className="rounded-full w-64 aspect-square" /> -

{mentor?.name}

-

{mentor?.email}

-

- Discord: {mentor?.discordUsername}

-

Specialization: {mentor?.specialization.toUpperCase()}

+ {mentor?.name &&

{mentor?.name}

} + {mentor?.email &&

{mentor?.email}

} + {mentor?.discordUsername &&

Discord: {mentor?.discordUsername}

} + {mentor?.specialization &&

Specialization: {mentor?.specialization.toUpperCase()}

}

Intro

{mentor?.intro}

From caeaab65dea9b840686425ebac94cfdcef81ca56 Mon Sep 17 00:00:00 2001 From: Heryan Djaruma Date: Sat, 19 Jul 2025 17:38:57 +0700 Subject: [PATCH 3/3] define emulator --- lib/firebase.ts | 5 ++++- lib/firebaseUtils.ts | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/firebase.ts b/lib/firebase.ts index 369562e..c27f243 100644 --- a/lib/firebase.ts +++ b/lib/firebase.ts @@ -30,11 +30,14 @@ googleProvider.setCustomParameters({ hd: "garudahacks.com", }); -if (process.env.NEXT_PUBLIC_ENVIRONMENT === "development") { +let emulatorsConnected = false; + +if (process.env.NEXT_PUBLIC_ENVIRONMENT === "development" && !emulatorsConnected) { connectAuthEmulator(auth, "http://localhost:9099", { disableWarnings: false, }); connectFirestoreEmulator(db, "localhost", 8080); + emulatorsConnected = true; console.log("Connected to Firebase emulators"); } diff --git a/lib/firebaseUtils.ts b/lib/firebaseUtils.ts index b612c53..f9d3ab7 100644 --- a/lib/firebaseUtils.ts +++ b/lib/firebaseUtils.ts @@ -455,8 +455,8 @@ export async function fetchMentors(): Promise { }); return users; - } catch { - throw new Error('Failed to fetch mentors'); + } catch (error){ + throw new Error(`Error when trying to fetch mentors: ${error}`); } }