From dd64c50f4b580e0cb00d12425416000a79f197e9 Mon Sep 17 00:00:00 2001 From: Apurva Date: Mon, 6 Jul 2026 10:09:17 -0400 Subject: [PATCH 1/9] feat: created the FRQ Feedback Page Skeleton --- package-lock.json | 2 +- package.json | 2 +- src/app/frq-feedback/[id]/page.tsx | 58 +++++++++++++++++++++++++ src/components/frq/feedbackRenderer.tsx | 13 ++++++ src/lib/firebase.ts | 10 +++-- 5 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 src/app/frq-feedback/[id]/page.tsx create mode 100644 src/components/frq/feedbackRenderer.tsx diff --git a/package-lock.json b/package-lock.json index 0103dc5e..ba7816b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,7 +43,7 @@ "editorjs-math": "^1.0.2", "editorjs-parser": "^1.5.3", "editorjs-undo": "^2.0.28", - "firebase": "^10.13.0", + "firebase": "^10.14.1", "firebase-admin": "^12.3.1", "highlight.js": "^11.10.0", "katex": "^0.16.11", diff --git a/package.json b/package.json index 9ba74ca1..83658e5a 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "editorjs-math": "^1.0.2", "editorjs-parser": "^1.5.3", "editorjs-undo": "^2.0.28", - "firebase": "^10.13.0", + "firebase": "^10.14.1", "firebase-admin": "^12.3.1", "highlight.js": "^11.10.0", "katex": "^0.16.11", diff --git a/src/app/frq-feedback/[id]/page.tsx b/src/app/frq-feedback/[id]/page.tsx new file mode 100644 index 00000000..c349e36f --- /dev/null +++ b/src/app/frq-feedback/[id]/page.tsx @@ -0,0 +1,58 @@ + +"use client"; + +import FRQFeedbackRenderer from "@/components/frq/feedbackRenderer"; +import { db } from "@/lib/firebase"; +import { doc, getDoc } from "firebase/firestore"; +import { useEffect, useState } from "react"; + +type FeedbackStatus = "loading" | "found" | "not-found"; +type PageStuff = { + params: { + id: string; + }; +}; + +const Page = (props: PageStuff) => { + const frqId = props.params.id; + const [status, setStatus] = useState("loading"); + + useEffect(() => { + const fetchFeedback = async () => { + setStatus("loading"); + try { + const docRef = doc( + db, + "frq-feedback", + frqId + ); + const docSnap = await getDoc(docRef); + + if (docSnap.exists()) { + setStatus("found"); + } else { + setStatus("not-found"); + } + } catch (error: unknown) { + console.error("Error fetching FRQ feedback:", error); + setStatus("not-found"); + } + }; + + void fetchFeedback(); + }, [frqId]); + + if (status === "loading") { + return

Loading...

; + } + + return ( +
+ +
+ ); +}; + +export default Page; diff --git a/src/components/frq/feedbackRenderer.tsx b/src/components/frq/feedbackRenderer.tsx new file mode 100644 index 00000000..fc44315d --- /dev/null +++ b/src/components/frq/feedbackRenderer.tsx @@ -0,0 +1,13 @@ + + + +interface Props { + feedbackFound: boolean; +} + +export default function FRQFeedbackRenderer({ feedbackFound }: Props) { + if (feedbackFound) { + return

Success.

; + } + return

Failed.

+} diff --git a/src/lib/firebase.ts b/src/lib/firebase.ts index 858dd959..97d29e0b 100644 --- a/src/lib/firebase.ts +++ b/src/lib/firebase.ts @@ -1,10 +1,10 @@ "use client" -import { initializeApp } from "firebase/app"; -import { getAuth } from "firebase/auth"; -import { getFirestore } from "firebase/firestore"; import { getStorage } from "firebase/storage"; +import { initializeApp } from "firebase/app"; +import { connectAuthEmulator, getAuth } from "firebase/auth"; +import { connectFirestoreEmulator, getFirestore } from "firebase/firestore"; import { env } from "@/env.js"; const firebaseConfig = { @@ -18,8 +18,12 @@ const firebaseConfig = { }; const app = initializeApp(firebaseConfig); + const db = getFirestore(app); +connectFirestoreEmulator(db, "127.0.0.1", 8080); + const auth = getAuth(app); +connectAuthEmulator(auth, "http://127.0.0.1:9099"); const storage = getStorage(app); export { db, auth, storage }; From 5a94268c196b6fa2a1a8483a19f23936d90294d2 Mon Sep 17 00:00:00 2001 From: Apurva Srimat Kandala Date: Tue, 7 Jul 2026 19:32:07 -0400 Subject: [PATCH 2/9] Emulator issue during production fixed Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/lib/firebase.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib/firebase.ts b/src/lib/firebase.ts index 97d29e0b..3c1dbc6d 100644 --- a/src/lib/firebase.ts +++ b/src/lib/firebase.ts @@ -20,10 +20,26 @@ const firebaseConfig = { const app = initializeApp(firebaseConfig); const db = getFirestore(app); -connectFirestoreEmulator(db, "127.0.0.1", 8080); + +if ( + process.env.NODE_ENV === "development" && + typeof window !== "undefined" && + (window.location.hostname === "localhost" || + window.location.hostname === "127.0.0.1") +) { + connectFirestoreEmulator(db, "127.0.0.1", 8080); +} const auth = getAuth(app); -connectAuthEmulator(auth, "http://127.0.0.1:9099"); + +if ( + process.env.NODE_ENV === "development" && + typeof window !== "undefined" && + (window.location.hostname === "localhost" || + window.location.hostname === "127.0.0.1") +) { + connectAuthEmulator(auth, "http://127.0.0.1:9099"); +} const storage = getStorage(app); export { db, auth, storage }; From 6e9d659a17c9debab721faaf24bd71e7e5f2f51a Mon Sep 17 00:00:00 2001 From: Apurva Date: Tue, 7 Jul 2026 19:41:59 -0400 Subject: [PATCH 3/9] Fixed pull request --- src/app/frq-feedback/[id]/page.tsx | 11 ++++------- src/components/frq/feedbackRenderer.tsx | 17 ++++++++--------- src/lib/firebase.ts | 14 +++++++++++--- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/app/frq-feedback/[id]/page.tsx b/src/app/frq-feedback/[id]/page.tsx index c349e36f..1187fb1f 100644 --- a/src/app/frq-feedback/[id]/page.tsx +++ b/src/app/frq-feedback/[id]/page.tsx @@ -5,16 +5,13 @@ import FRQFeedbackRenderer from "@/components/frq/feedbackRenderer"; import { db } from "@/lib/firebase"; import { doc, getDoc } from "firebase/firestore"; import { useEffect, useState } from "react"; +import usePathname from "@/components/client/pathname"; type FeedbackStatus = "loading" | "found" | "not-found"; -type PageStuff = { - params: { - id: string; - }; -}; -const Page = (props: PageStuff) => { - const frqId = props.params.id; +const Page = () => { + const pathname = usePathname() ?? ""; + const frqId = pathname.split("/").at(-1) ?? ""; const [status, setStatus] = useState("loading"); useEffect(() => { diff --git a/src/components/frq/feedbackRenderer.tsx b/src/components/frq/feedbackRenderer.tsx index fc44315d..8bcfb4bb 100644 --- a/src/components/frq/feedbackRenderer.tsx +++ b/src/components/frq/feedbackRenderer.tsx @@ -1,13 +1,12 @@ - - - interface Props { - feedbackFound: boolean; + feedbackFound: boolean; } export default function FRQFeedbackRenderer({ feedbackFound }: Props) { - if (feedbackFound) { - return

Success.

; - } - return

Failed.

-} + if (feedbackFound) { + return

Success.

; + } + return

Failed.

; + } + + diff --git a/src/lib/firebase.ts b/src/lib/firebase.ts index 97d29e0b..0f310aca 100644 --- a/src/lib/firebase.ts +++ b/src/lib/firebase.ts @@ -20,10 +20,18 @@ const firebaseConfig = { const app = initializeApp(firebaseConfig); const db = getFirestore(app); -connectFirestoreEmulator(db, "127.0.0.1", 8080); - const auth = getAuth(app); -connectAuthEmulator(auth, "http://127.0.0.1:9099"); + + + +const isLocalDevelopemnt = + process.env.NODE_ENV === "development" && typeof window !== "undefined" && ["localhost", "127.0.0.1"].includes(window.location.hostname); + +if (isLocalDevelopemnt) { + connectFirestoreEmulator(db, "127.0.0.1", 8080); + connectAuthEmulator(auth, "http://127.0.0.1:9099"); +} + const storage = getStorage(app); export { db, auth, storage }; From 053478533fea3a8f5db14160d34dc4554749a13f Mon Sep 17 00:00:00 2001 From: Apurva Date: Wed, 8 Jul 2026 14:35:19 -0400 Subject: [PATCH 4/9] fixed firebase.ts --- src/lib/firebase.ts | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/src/lib/firebase.ts b/src/lib/firebase.ts index b3babe41..7449de96 100644 --- a/src/lib/firebase.ts +++ b/src/lib/firebase.ts @@ -1,10 +1,10 @@ "use client" +import { initializeApp } from "firebase/app"; +import { getAuth } from "firebase/auth"; +import { getFirestore } from "firebase/firestore"; import { getStorage } from "firebase/storage"; -import { initializeApp } from "firebase/app"; -import { connectAuthEmulator, getAuth } from "firebase/auth"; -import { connectFirestoreEmulator, getFirestore } from "firebase/firestore"; import { env } from "@/env.js"; const firebaseConfig = { @@ -17,26 +17,10 @@ const firebaseConfig = { measurementId: env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID, }; - const app = initializeApp(firebaseConfig); - const db = getFirestore(app); - - if ( - process.env.NODE_ENV === "development" && - typeof window !== "undefined" && - (window.location.hostname === "localhost" || - window.location.hostname === "127.0.0.1") - ) { - connectFirestoreEmulator(db, "127.0.0.1", 8080); - } - const auth = getAuth(app); +const app = initializeApp(firebaseConfig); +const db = getFirestore(app); +const auth = getAuth(app); +const storage = getStorage(app); - if ( - process.env.NODE_ENV === "development" && - typeof window !== "undefined" && - (window.location.hostname === "localhost" || - window.location.hostname === "127.0.0.1") - ) { - connectAuthEmulator(auth, "http://127.0.0.1:9099"); - } - const storage = getStorage(app); - export { db, auth, storage }; \ No newline at end of file +export { db, auth, storage }; +export default app; \ No newline at end of file From 569a3a69970663a83991367298af0d3598d1b9a9 Mon Sep 17 00:00:00 2001 From: Apurva Date: Tue, 14 Jul 2026 13:30:05 -0400 Subject: [PATCH 5/9] Added FRQ footer component --- src/components/global/frqFooter.tsx | 81 +++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/components/global/frqFooter.tsx diff --git a/src/components/global/frqFooter.tsx b/src/components/global/frqFooter.tsx new file mode 100644 index 00000000..cf809106 --- /dev/null +++ b/src/components/global/frqFooter.tsx @@ -0,0 +1,81 @@ +import { ChevronLeft, ChevronRight, ChevronUp } from "lucide-react"; +import { Popover, PopoverContent, PopoverTrigger} from "@/components/ui/popover"; + + +interface FooterProps { + testName: string; + currentFrqIndex: number; + totalFrqs: number; + onPrevious: () => void; + onNext: () => void; + onJumpToFrq: (index: number) => void; +} + +export default function Footer({ + testName, + currentFrqIndex, + totalFrqs, + onPrevious, + onNext, + onJumpToFrq, +}: FooterProps) { + return ( +
+

{testName}

+ +
+ + + + + Question {currentFrqIndex + 1} of {totalFrqs} + + + + +
+ {Array.from({ length: totalFrqs }).map((_, index) => ( + + ))} +
+
+
+ + +
+ +
+ + + +
+
+ ); +} From 0ec65b44d9b4aee4e42e01c8224a139da44907a2 Mon Sep 17 00:00:00 2001 From: Apurva Date: Tue, 14 Jul 2026 13:43:55 -0400 Subject: [PATCH 6/9] Updated frq footer --- src/components/global/frqFooter.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/components/global/frqFooter.tsx b/src/components/global/frqFooter.tsx index cf809106..95a04ad3 100644 --- a/src/components/global/frqFooter.tsx +++ b/src/components/global/frqFooter.tsx @@ -11,14 +11,7 @@ interface FooterProps { onJumpToFrq: (index: number) => void; } -export default function Footer({ - testName, - currentFrqIndex, - totalFrqs, - onPrevious, - onNext, - onJumpToFrq, -}: FooterProps) { +export default function Footer({testName, currentFrqIndex, totalFrqs, onPrevious, onNext, onJumpToFrq,}: FooterProps) { return (