Skip to content

Commit 3b41350

Browse files
committed
Add question details and error page
1 parent e6a4efe commit 3b41350

File tree

15 files changed

+584
-42
lines changed

15 files changed

+584
-42
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ dist-ssr
1414

1515
# Editor directories and files
1616
.vscode/*
17+
!.vscode/settings.json
1718
!.vscode/extensions.json
1819
.idea
1920
.DS_Store

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"[typescript]": {
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"editor.formatOnSave": true,
5+
"prettier.tabWidth": 2
6+
}
7+
}

frontend/package-lock.json

Lines changed: 157 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
"@emotion/styled": "^11.13.0",
1515
"@mdxeditor/editor": "^3.11.4",
1616
"@mui/material": "^6.1.0",
17+
"axios": "^1.7.7",
18+
"markdown-to-jsx": "^7.5.0",
1719
"react": "^18.3.1",
18-
"react-dom": "^18.3.1"
20+
"react-dom": "^18.3.1",
21+
"react-router-dom": "^6.26.2"
1922
},
2023
"devDependencies": {
2124
"@eslint/js": "^9.9.0",
@@ -26,7 +29,7 @@
2629
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
2730
"eslint-plugin-react-refresh": "^0.4.9",
2831
"globals": "^15.9.0",
29-
"typescript": "^5.5.3",
32+
"typescript": "^5.6.2",
3033
"typescript-eslint": "^8.0.1",
3134
"vite": "^5.4.1"
3235
}

frontend/src/App.tsx

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,19 @@
1-
import { useState } from 'react'
2-
import reactLogo from './assets/react.svg'
3-
import viteLogo from '/vite.svg'
4-
import './App.css'
1+
import { BrowserRouter, Routes, Route } from "react-router-dom";
2+
import Layout from "./components/Layout";
3+
import QuestionDetail from "./pages/QuestionDetail";
4+
import PageNotFound from "./pages/Error";
55

66
function App() {
7-
const [count, setCount] = useState(0)
8-
97
return (
10-
<>
11-
<div>
12-
<a href="https://vitejs.dev" target="_blank">
13-
<img src={viteLogo} className="logo" alt="Vite logo" />
14-
</a>
15-
<a href="https://react.dev" target="_blank">
16-
<img src={reactLogo} className="logo react" alt="React logo" />
17-
</a>
18-
</div>
19-
<h1>Vite + React</h1>
20-
<div className="card">
21-
<button onClick={() => setCount((count) => count + 1)}>
22-
count is {count}
23-
</button>
24-
<p>
25-
Edit <code>src/App.tsx</code> and save to test HMR
26-
</p>
27-
</div>
28-
<p className="read-the-docs">
29-
Click on the Vite and React logos to learn more
30-
</p>
31-
</>
32-
)
8+
<BrowserRouter>
9+
<Routes>
10+
<Route path="/" element={<Layout />}>
11+
<Route path="/questions/:questionId" element={<QuestionDetail />} />
12+
<Route path="*" element={<PageNotFound />} />
13+
</Route>
14+
</Routes>
15+
</BrowserRouter>
16+
);
3317
}
3418

35-
export default App
19+
export default App;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Box } from "@mui/material";
2+
import { FunctionComponent, ReactNode } from "react";
3+
4+
type AppMarginProps = { classname?: string; children: ReactNode };
5+
6+
const AppMargin: FunctionComponent<AppMarginProps> = (
7+
props: AppMarginProps
8+
) => {
9+
const { classname, children } = props;
10+
return (
11+
<Box
12+
className={classname}
13+
sx={(theme) => ({
14+
marginLeft: theme.spacing(16),
15+
marginRight: theme.spacing(16),
16+
})}
17+
>
18+
{children}
19+
</Box>
20+
);
21+
};
22+
23+
export default AppMargin;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Box } from "@mui/material";
2+
import { FunctionComponent } from "react";
3+
import { Outlet } from "react-router-dom";
4+
import Navbar from "../Navbar";
5+
6+
const Layout: FunctionComponent = () => {
7+
return (
8+
<Box
9+
sx={{
10+
display: "flex",
11+
flexDirection: "column",
12+
minHeight: "100vh",
13+
minInlineSize: "100vw",
14+
}}
15+
>
16+
<Navbar />
17+
<Outlet />
18+
</Box>
19+
);
20+
};
21+
22+
export default Layout;

0 commit comments

Comments
 (0)