Skip to content

Commit

Permalink
feat: Main Page내 페이지별 라우팅 완성 (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
damilog committed Jun 8, 2021
1 parent be91cbe commit 673cced
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 18 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function App() {
<Route path="/login" component={LoginLoadingPage} />
<Route path="/main/milestones" component={Milestones} />
<Route path="/main/labels" component={Labels} />
<Route path="/main/new_issue" component={NewIssue} />
{/* <Route path="/main/new" component={NewIssue} /> */}
<Route path="*" component={NoMatch} />
</Switch>
</>
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Link } from "react-router-dom";

const Header = () => {
return (
<>
<div>메인의 헤더</div>
</>
);
};

export default Header;
5 changes: 5 additions & 0 deletions frontend/src/components/Header/Menu.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Menu = () => {
return <div></div>;
};

export default Menu;
5 changes: 5 additions & 0 deletions frontend/src/components/Header/Navigator.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Navigator = () => {
return <div>Navigator~~~~~~</div>;
};

export default Navigator;
28 changes: 11 additions & 17 deletions frontend/src/components/pages/MainPage.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import { Route, Switch, Link, Redirect, BrowserRouter } from "react-router-dom";

import { Route, Switch, Link, Redirect } from "react-router-dom";
import Labels from "../Labels/Labels";
import Milestones from "../Milestones/Milestones";
import { useState } from "react";
import NewIssue from "./NewIssue";
import NoMatch from "./NoMatch";

import Header from "../Header/Header";
import Navigator from "../Header/Navigator";
const MainPage = () => {
const { pathname } = window.location;
console.log(pathname);

return localStorage.getItem("token") ? (
<>
<div>메인의 헤더</div>
<ul>
<li>
<Link to="/main/milestones">milestones</Link>
</li>
<li>
<Link to="/main/labels">labels</Link>
</li>
<li>
<Link to="/main/new_issue">이슈 작성</Link>
</li>
<div>이슈리스트</div>
</ul>
<Header pathName={pathname} />
{(pathname === "/main/labels" || pathname === "/main/milestones") && (
<Navigator /> //이부분 switch 문으로 리팩토링(pathName = "/main"이면 Menu~)
)}
<Switch>
<Route exact path="/main/milestones" component={Milestones} />
<Route exact path="/main/labels" component={Labels} />
<Route exact path="/main/new_issue" component={NewIssue} />
<Route exact path="/main/new" component={NewIssue} />
<Route path="/main/*" component={NoMatch} />
</Switch>
</>
Expand Down

0 comments on commit 673cced

Please sign in to comment.