Skip to content

Commit 2b998cc

Browse files
committed
Merge changes and fix conflicts
2 parents 8b95d68 + 5788b54 commit 2b998cc

File tree

16 files changed

+972
-774
lines changed

16 files changed

+972
-774
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: 571 additions & 757 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
"@mui/icons-material": "^6.1.0",
1717
"@mui/material": "^6.1.0",
1818
"@uiw/react-md-editor": "^4.0.4",
19+
"axios": "^1.7.7",
1920
"firebase": "^10.13.1",
2021
"react": "^18.3.1",
2122
"react-dom": "^18.3.1",
2223
"react-router-dom": "^6.26.2",
2324
"react-toastify": "^10.0.5",
25+
"markdown-to-jsx": "^7.5.0",
2426
"uuid": "^10.0.0"
2527
},
2628
"devDependencies": {
@@ -33,7 +35,7 @@
3335
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
3436
"eslint-plugin-react-refresh": "^0.4.9",
3537
"globals": "^15.9.0",
36-
"typescript": "^5.5.3",
38+
"typescript": "^5.6.2",
3739
"typescript-eslint": "^8.0.1",
3840
"vite": "^5.4.1"
3941
}

frontend/src/App.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import { BrowserRouter, Routes, Route } from "react-router-dom";
2+
import Layout from "./components/Layout";
23
import NewQuestion from "./pages/NewQuestion";
4+
import QuestionDetail from "./pages/QuestionDetail";
5+
import PageNotFound from "./pages/Error";
36

47
function App() {
58
return (
69
<BrowserRouter>
710
<Routes>
8-
<Route path="/question" element={<>question page list</>} />
9-
<Route path="/question/new" element={<NewQuestion />} />
11+
<Route path="/" element={<Layout />}>
12+
<Route path="/questions" element={<>question page list</>} />
13+
<Route path="/questions/new" element={<NewQuestion />} />
14+
<Route path="/questions/:questionId" element={<QuestionDetail />} />
15+
<Route path="*" element={<PageNotFound />} />
16+
</Route>
1017
</Routes>
1118
</BrowserRouter>
1219
);
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;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { AppBar, Box, Link, Toolbar, Typography } from "@mui/material";
2+
import { grey } from "@mui/material/colors";
3+
import { FunctionComponent } from "react";
4+
import AppMargin from "../AppMargin";
5+
import { useNavigate } from "react-router-dom";
6+
7+
type NavbarItem = { label: string; link: string };
8+
9+
type NavbarProps = { navbarItems?: Array<NavbarItem> };
10+
11+
const Navbar: FunctionComponent<NavbarProps> = (props: NavbarProps) => {
12+
const { navbarItems = [{ label: "Questions", link: "/" }] } = props;
13+
const navigate = useNavigate();
14+
15+
return (
16+
<AppBar
17+
component={"nav"}
18+
position="sticky"
19+
sx={{
20+
backgroundColor: "common.white",
21+
color: "primary.main",
22+
boxShadow: "none",
23+
borderBottom: "1px solid",
24+
borderColor: grey[300],
25+
}}
26+
>
27+
<AppMargin>
28+
<Toolbar>
29+
<Typography
30+
component={Box}
31+
variant="h5"
32+
sx={[{ flexGrow: 1, "&:hover": { cursor: "pointer" } }]}
33+
onClick={() => navigate("/")}
34+
>
35+
PeerPrep
36+
</Typography>
37+
<Box>
38+
{navbarItems.map((item) => (
39+
<Link
40+
key={item.label}
41+
href={item.link}
42+
underline="none"
43+
sx={{ color: "common.black" }}
44+
>
45+
{item.label}
46+
</Link>
47+
))}
48+
</Box>
49+
</Toolbar>
50+
</AppMargin>
51+
</AppBar>
52+
);
53+
};
54+
55+
export default Navbar;

frontend/src/main.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { createRoot } from "react-dom/client";
33
import App from "./App.tsx";
44
import theme from "./theme";
55
import { ThemeProvider } from "@mui/material/styles";
6+
import { CssBaseline } from "@mui/material";
67

78
createRoot(document.getElementById("root")!).render(
89
<StrictMode>
910
<ThemeProvider theme={theme}>
11+
<CssBaseline />
1012
<App />
1113
</ThemeProvider>
1214
</StrictMode>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.fullheight {
2+
flex: 1;
3+
}
4+
5+
.center {
6+
display: flex;
7+
flex-direction: column;
8+
align-items: center;
9+
justify-content: center;
10+
}

0 commit comments

Comments
 (0)