-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from CS3219-AY2425S1/frontendQuestion
Link question service frontend to backend
- Loading branch information
Showing
22 changed files
with
1,448 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,3 +131,5 @@ dist | |
|
||
# Redis dump | ||
redis-data/ | ||
|
||
frontend/peerprep/next.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
frontend/peerprep/app/questions-management/edit/[id]/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function SettingsLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<section className="flex flex-col items-start justify-center gap-4 py-8 md:py-6"> | ||
<div className="inline-block w-full min-w-lg text-center justify-center"> | ||
{children} | ||
</div> | ||
</section> | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
frontend/peerprep/app/questions-management/edit/[id]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use client"; | ||
import EditQuestionForm from "@/components/editquestionform"; | ||
|
||
export default function AddQuestionsPage() { | ||
return ( | ||
<div className="flex"> | ||
<EditQuestionForm /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,44 @@ | ||
"use client"; | ||
import QuestionsTable from "@/components/questionstable"; | ||
import Questions from "../mockdata/sample_getAllQuestions.json"; | ||
import { categoryOptions, setCategoryOptions } from "./columns"; | ||
import { Question, setCategoryOptions } from "./columns"; | ||
import useSWR from "swr"; | ||
|
||
export default async function QuestionsPage() { | ||
let questions = Questions.questions; | ||
// async function getQuestions(): Promise<Question[]> { | ||
// // Make sure the fetch URL includes http:// or https:// | ||
// const res = await fetch("http://localhost:8003/api/questions/categories/unique"); | ||
|
||
const allCategories = questions.flatMap((question) => question.category); | ||
const uniqueCategories = Array.from(new Set(allCategories)); | ||
// // Check for a successful response | ||
// if (!res.ok) { | ||
// throw new Error(`Failed to fetch questions: ${res.statusText}`); | ||
// } | ||
|
||
setCategoryOptions(uniqueCategories); | ||
// // Parse the response as JSON | ||
// const data = await res.json(); | ||
|
||
// // Return the questions part of the JSON response | ||
// return data.uniqueCategories; | ||
// } | ||
|
||
export default function QuestionsPage() { | ||
// const { data, isLoading } = useSWR( | ||
// `http://localhost:8003/api/questions/categories/unique`, | ||
// fetcher | ||
// ); | ||
// let questions = await getQuestions(); | ||
|
||
// console.log(questions); | ||
|
||
// let questions = Questions.questions; | ||
|
||
// const allCategories = questions.flatMap((question) => question.category); | ||
// const uniqueCategories = Array.from(new Set(allCategories)); | ||
|
||
// setCategoryOptions(Array.from(data?.uniqueCategories)); | ||
|
||
return ( | ||
<div> | ||
<QuestionsTable questions={questions} /> | ||
<QuestionsTable /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.