Skip to content

Commit be5bba8

Browse files
committed
Add sample code for routing to individual question page
1 parent 7e871dc commit be5bba8

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

apps/question-service/src/app/page.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import {
3434
CategoriesOption,
3535
DifficultyOption,
3636
OrderOption,
37-
} from "./utils/SelectOptions";
37+
} from "../utils/SelectOptions";
38+
import Link from "next/link";
3839

3940
/**
4041
* defines the State of the page whe a user is deleing an object. Has 3 general states:
@@ -167,7 +168,16 @@ export default function Home() {
167168
title: "Title",
168169
dataIndex: "title",
169170
key: "title",
170-
render: (text: string) => <Button type="link">{text}</Button>, // TODO (Sean): Onclick links to the individual question page
171+
render: (text: string, question: Question) => (
172+
<Link
173+
href={{
174+
pathname: `/question/${question.id}`,
175+
query: { data: question.docRefId }, // the data
176+
}}
177+
>
178+
<Button type="link">{text}</Button>
179+
</Link>
180+
), // TODO (Sean): Onclick links to the individual question page
171181
},
172182
{
173183
title: "Categories",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use client";
2+
3+
import { useSearchParams } from "next/navigation";
4+
5+
const QuestionPage = (): JSX.Element => {
6+
const searchParams = useSearchParams();
7+
const docRefId = searchParams.get("data");
8+
9+
// TODO: use docRefId to fetch the data via the service function and display the data below
10+
return <div>Hello World! {docRefId}</div>;
11+
};
12+
13+
export default QuestionPage;
File renamed without changes.

0 commit comments

Comments
 (0)