summaryrefslogtreecommitdiffhomepage
path: root/frontend/src/routes/index.tsx
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2024-07-27 04:17:50 -0400
committerrealtradam <[email protected]>2024-07-27 04:17:50 -0400
commitcc04a47f4e1597b4fe3d92235929d553205dac4a (patch)
tree6732b2ce0e604910a656d5ac441272b80506b1d4 /frontend/src/routes/index.tsx
parentde3d80ce3ea20a869d700c3238020d44059de099 (diff)
downloadspring-blog-cc04a47f4e1597b4fe3d92235929d553205dac4a.tar.gz
spring-blog-cc04a47f4e1597b4fe3d92235929d553205dac4a.zip
implement search and better UX
Diffstat (limited to 'frontend/src/routes/index.tsx')
-rw-r--r--frontend/src/routes/index.tsx44
1 files changed, 28 insertions, 16 deletions
diff --git a/frontend/src/routes/index.tsx b/frontend/src/routes/index.tsx
index e77421c..b46315b 100644
--- a/frontend/src/routes/index.tsx
+++ b/frontend/src/routes/index.tsx
@@ -7,25 +7,37 @@ import NewArticle from "../pages/articles/New";
import Register from "../pages/auth/Register";
import Login from "../pages/auth/Login";
-type user = { set: React.Dispatch<React.SetStateAction<string | null>>, value: string | null };
+type user = {
+ set: React.Dispatch<React.SetStateAction<string | null>>;
+ value: string | null;
+};
+type articleSearch = user;
-export default function Index()
-{
+export default function Index() {
const [user, setUser] = useState<string | null>(null);
+ const [articleSearch, setArticleSearch] = useState<string | null>(null);
const userProp: user = { set: setUser, value: user };
+ const articleSearchProp: articleSearch = {
+ set: setArticleSearch,
+ value: articleSearch,
+ };
- return (<>
- <Router>
- <Routes>
- <Route path="/" element = {<Layout />}>
- <Route index element={<Home />} />
- <Route path="/article/:id" element={<Article />} />
- <Route path="/article/new" element={<NewArticle />} />
- <Route path="register" element={<Register />} />
- <Route path="login" element={<Login user={userProp}/>} />
- </Route>
- </Routes>
- </Router>
- </>);
+ return (
+ <>
+ <Router>
+ <Routes>
+ <Route
+ path="/"
+ element={<Layout user={userProp} articleSearch={articleSearchProp} />}>
+ <Route index element={<Home articleSearch={articleSearchProp} />} />
+ <Route path="/article/:id" element={<Article />} />
+ <Route path="/article/new" element={<NewArticle />} />
+ <Route path="register" element={<Register />} />
+ <Route path="login" element={<Login user={userProp} />} />
+ </Route>
+ </Routes>
+ </Router>
+ </>
+ );
}