Skip to content

Commit

Permalink
Fix: 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
milkbottle0305 committed Mar 18, 2024
1 parent 189ff78 commit a8ce348
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import CreateMystudy from "./pages/Mystudies/CreateMystudy";
import EditMystudy from "./pages/Mystudies/EditMystudy";
import Settings from "./pages/Settings/Settings";
import DetailMystudy from "./pages/Mystudies/DetailMystudy";
import Notfound from "./pages/Notfound/Notfound";

function App() {
return (
<Routes>
<Route path="/callback" element={<Callback />} />
<Route path="/" element={<Splash />} />
<Route path="*" element={<Notfound />} />
<Route element={<PrivateRoute authentication={true} />}>
<Route path="/home" element={<Home />} />
<Route path="/calendar" element={<Calendar />} />
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import { HashRouter } from "react-router-dom";
import { BrowserRouter } from "react-router-dom";
import { RecoilRoot } from "recoil";
import reportWebVitals from "./reportWebVitals";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
//<React.StrictMode>
<RecoilRoot>
<HashRouter>
<BrowserRouter>
<App />
</HashRouter>
</BrowserRouter>
</RecoilRoot>,
//</React.StrictMode>,
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Callback/Callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Callback() {
};

handleOAuthCallback();
}, [history]);
}, []);

return null;
}
Expand Down
19 changes: 19 additions & 0 deletions src/pages/Notfound/Notfound.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import styled from "styled-components";

const StyledNotfound = styled.div`
height: 100vh;
weight: 100vw;
background-color: #000000;
color: #ffffff;
font-size: 4rem;
font-family: roboto;
display: flex;
justify-content: center;
align-items: center;
`;

const Notfound = () => {
return <StyledNotfound>Not Found</StyledNotfound>;
};

export default Notfound;
28 changes: 14 additions & 14 deletions src/pages/PrivateRoute/PrivateRoute.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from "react";
import { Navigate, Outlet } from "react-router-dom";
// import { validateToken } from "../../services/api";
import { validateToken } from "../../services/api";
import Loading from "../../components/Loading";

function PrivateRoute({ authentication }) {
Expand All @@ -14,20 +14,20 @@ function PrivateRoute({ authentication }) {
useEffect(() => {
setIsAuthenticated(true);
setLoading(false);
// const checkAuthentication = async () => {
// try {
// const isAuthenticated = await validateToken(
// localStorage.getItem("studitAccessToken"),
// );
// setIsAuthenticated(isAuthenticated);
// } catch (error) {
// setIsAuthenticated(false);
// } finally {
// setLoading(false); // 비동기 작업 완료 후 로딩 상태 변경
// }
// };
const checkAuthentication = async () => {
try {
const isAuthenticated = await validateToken(
localStorage.getItem("studitAccessToken"),
);
setIsAuthenticated(isAuthenticated);
} catch (error) {
setIsAuthenticated(false);
} finally {
setLoading(false); // 비동기 작업 완료 후 로딩 상태 변경
}
};

// checkAuthentication();
checkAuthentication();
}, []);

if (loading) {
Expand Down

0 comments on commit a8ce348

Please sign in to comment.