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}

diff --git a/lib/firebase.ts b/lib/firebase.ts index 2a88e7d..c27f243 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,15 @@ googleProvider.setCustomParameters({ hd: "garudahacks.com", }); +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"); +} + export default app; 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}`); } }