diff --git a/.pnp.cjs b/.pnp.cjs index 6197755..b8d4d31 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -43,6 +43,7 @@ const RAW_RUNTIME_STATE = ["lint-staged", "npm:15.4.3"],\ ["prettier", "npm:3.5.1"],\ ["react", "npm:19.0.0"],\ + ["react-cookie", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:7.2.2"],\ ["react-device-detect", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:2.2.3"],\ ["react-dom", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:19.0.0"],\ ["react-markdown", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:10.0.0"],\ @@ -78,6 +79,7 @@ const RAW_RUNTIME_STATE = ["lint-staged", "npm:15.4.3"],\ ["prettier", "npm:3.5.1"],\ ["react", "npm:19.0.0"],\ + ["react-cookie", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:7.2.2"],\ ["react-device-detect", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:2.2.3"],\ ["react-dom", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:19.0.0"],\ ["react-markdown", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:10.0.0"],\ @@ -1249,6 +1251,17 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["@types/hoist-non-react-statics", [\ + ["npm:3.3.6", {\ + "packageLocation": "./.yarn/cache/@types-hoist-non-react-statics-npm-3.3.6-62547ea2dd-149a4c217d.zip/node_modules/@types/hoist-non-react-statics/",\ + "packageDependencies": [\ + ["@types/hoist-non-react-statics", "npm:3.3.6"],\ + ["@types/react", "npm:19.0.10"],\ + ["hoist-non-react-statics", "npm:3.3.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["@types/json-schema", [\ ["npm:7.0.15", {\ "packageLocation": "./.yarn/cache/@types-json-schema-npm-7.0.15-fd16381786-a996a745e6.zip/node_modules/@types/json-schema/",\ @@ -1927,6 +1940,13 @@ const RAW_RUNTIME_STATE = }]\ ]],\ ["cookie", [\ + ["npm:0.7.2", {\ + "packageLocation": "./.yarn/cache/cookie-npm-0.7.2-6ea9ee4231-9596e8ccdb.zip/node_modules/cookie/",\ + "packageDependencies": [\ + ["cookie", "npm:0.7.2"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:1.0.2", {\ "packageLocation": "./.yarn/cache/cookie-npm-1.0.2-7a4273d897-fd25fe79e8.zip/node_modules/cookie/",\ "packageDependencies": [\ @@ -5319,6 +5339,31 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["react-cookie", [\ + ["npm:7.2.2", {\ + "packageLocation": "./.yarn/cache/react-cookie-npm-7.2.2-61248cf180-22948a42b9.zip/node_modules/react-cookie/",\ + "packageDependencies": [\ + ["react-cookie", "npm:7.2.2"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:7.2.2", {\ + "packageLocation": "./.yarn/__virtual__/react-cookie-virtual-1bd682303d/0/cache/react-cookie-npm-7.2.2-61248cf180-22948a42b9.zip/node_modules/react-cookie/",\ + "packageDependencies": [\ + ["react-cookie", "virtual:461e6af943b16da7f236f1e34be6e26223630ff89cd394ee5e389acdbb4b9127bfcb7f2ab83e187a9cb14aa7615ae5b0603b19b0bd8a93e8112d4d072c80e438#npm:7.2.2"],\ + ["@types/hoist-non-react-statics", "npm:3.3.6"],\ + ["@types/react", "npm:19.0.10"],\ + ["hoist-non-react-statics", "npm:3.3.2"],\ + ["react", "npm:19.0.0"],\ + ["universal-cookie", "npm:7.2.2"]\ + ],\ + "packagePeers": [\ + "@types/react",\ + "react"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["react-device-detect", [\ ["npm:2.2.3", {\ "packageLocation": "./.yarn/cache/react-device-detect-npm-2.2.3-307eab666a-396bbeeab0.zip/node_modules/react-device-detect/",\ @@ -6488,6 +6533,17 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["universal-cookie", [\ + ["npm:7.2.2", {\ + "packageLocation": "./.yarn/cache/universal-cookie-npm-7.2.2-c7f1748d18-214c5cf72b.zip/node_modules/universal-cookie/",\ + "packageDependencies": [\ + ["universal-cookie", "npm:7.2.2"],\ + ["@types/cookie", "npm:0.6.0"],\ + ["cookie", "npm:0.7.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["uri-js", [\ ["npm:4.4.1", {\ "packageLocation": "./.yarn/cache/uri-js-npm-4.4.1-66d11cbcaf-4ef57b45aa.zip/node_modules/uri-js/",\ diff --git a/.yarn/cache/@esbuild-linux-x64-npm-0.24.2-eb2f35022c-10c0.zip b/.yarn/cache/@esbuild-linux-x64-npm-0.24.2-eb2f35022c-10c0.zip new file mode 100644 index 0000000..176b1af Binary files /dev/null and b/.yarn/cache/@esbuild-linux-x64-npm-0.24.2-eb2f35022c-10c0.zip differ diff --git a/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.34.8-abde209531-10c0.zip b/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.34.8-abde209531-10c0.zip new file mode 100644 index 0000000..a2cefcd Binary files /dev/null and b/.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.34.8-abde209531-10c0.zip differ diff --git a/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.10.18-d7df891541-10c0.zip b/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.10.18-d7df891541-10c0.zip new file mode 100644 index 0000000..c7b0cad Binary files /dev/null and b/.yarn/cache/@swc-core-linux-x64-gnu-npm-1.10.18-d7df891541-10c0.zip differ diff --git a/.yarn/cache/@types-hoist-non-react-statics-npm-3.3.6-62547ea2dd-149a4c217d.zip b/.yarn/cache/@types-hoist-non-react-statics-npm-3.3.6-62547ea2dd-149a4c217d.zip new file mode 100644 index 0000000..0fc86d7 Binary files /dev/null and b/.yarn/cache/@types-hoist-non-react-statics-npm-3.3.6-62547ea2dd-149a4c217d.zip differ diff --git a/.yarn/cache/cookie-npm-0.7.2-6ea9ee4231-9596e8ccdb.zip b/.yarn/cache/cookie-npm-0.7.2-6ea9ee4231-9596e8ccdb.zip new file mode 100644 index 0000000..62f127c Binary files /dev/null and b/.yarn/cache/cookie-npm-0.7.2-6ea9ee4231-9596e8ccdb.zip differ diff --git a/.yarn/cache/react-cookie-npm-7.2.2-61248cf180-22948a42b9.zip b/.yarn/cache/react-cookie-npm-7.2.2-61248cf180-22948a42b9.zip new file mode 100644 index 0000000..e2fbc3e Binary files /dev/null and b/.yarn/cache/react-cookie-npm-7.2.2-61248cf180-22948a42b9.zip differ diff --git a/.yarn/cache/universal-cookie-npm-7.2.2-c7f1748d18-214c5cf72b.zip b/.yarn/cache/universal-cookie-npm-7.2.2-c7f1748d18-214c5cf72b.zip new file mode 100644 index 0000000..e97274c Binary files /dev/null and b/.yarn/cache/universal-cookie-npm-7.2.2-c7f1748d18-214c5cf72b.zip differ diff --git a/package.json b/package.json index 0d2dfda..e964364 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "dependencies": { "axios": "^1.7.9", "react": "^19.0.0", + "react-cookie": "^7.2.2", "react-device-detect": "^2.2.3", "react-dom": "^19.0.0", "react-markdown": "^10.0.0", diff --git a/src/App.jsx b/src/App.jsx index 3826693..39b4307 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -8,6 +8,7 @@ import Search from "./pages/Search"; import Wiki from "./pages/Wiki"; import Register from "./pages/RegisterForm.jsx"; import Edit from "./pages/EditForm.jsx"; +import Login from "./pages/Login.jsx"; function App() { return ( @@ -22,8 +23,9 @@ function App() { } /> - } /> + } /> + }/> ); } diff --git a/src/components/WikiCard.jsx b/src/components/WikiCard.jsx index d6093ab..9c53b88 100644 --- a/src/components/WikiCard.jsx +++ b/src/components/WikiCard.jsx @@ -3,7 +3,7 @@ import "./WikiCard.css"; export default function WikiCard({ title, enteredIn, college, department }) { return ( - +
{title}
diff --git a/src/main.jsx b/src/main.jsx index 98fce92..e8789dd 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -2,12 +2,15 @@ import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import './index.css' import { BrowserRouter } from 'react-router' +import { CookiesProvider } from "react-cookie"; import App from './App.jsx' createRoot(document.getElementById('root')).render( - - - + + + + + , ) diff --git a/src/pages/AboutUs.css b/src/pages/AboutUs.css index 7b165d4..4088e4a 100644 --- a/src/pages/AboutUs.css +++ b/src/pages/AboutUs.css @@ -20,7 +20,7 @@ min-height: 120px; align-items: center; text-align: left; - padding: 5px; + padding: 10px; font-size: 14px; } diff --git a/src/pages/BoothHome.jsx b/src/pages/BoothHome.jsx index 71d225b..7d0b7d4 100644 --- a/src/pages/BoothHome.jsx +++ b/src/pages/BoothHome.jsx @@ -7,6 +7,7 @@ import instagram from "../assets/instagram_3x.png"; import github from "../assets/github_3x.png"; import apply from "../assets/apply.svg"; import WikiMiniButton from "../components/WikiMiniButton"; +import { CheckLogin } from "../utils/cookie"; import Home from "./Home"; // ✅ PC 화면에서는 기존 Home 사용 import "./BoothHome.css"; @@ -39,6 +40,13 @@ function BoothMobileView({ recentPeople }) { navigate(`/search?name=${encodeURIComponent(query)}`); }; + + useEffect(() => { + if (CheckLogin) { + navigate('/login'); // 로그인 페이지로 리다이렉트 + } + }, [navigate]); + const handleKeyDown = (event) => { if (event.key === "Enter") { event.preventDefault(); @@ -74,6 +82,7 @@ function BoothMobileView({ recentPeople }) { fetchRecentWikis(); }, []); + return (
diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx new file mode 100644 index 0000000..73d2ebd --- /dev/null +++ b/src/pages/Login.jsx @@ -0,0 +1,64 @@ +import { useState } from "react"; +import axios from "axios"; + +export default function Login() { + + const [username, setUsername] = useState(""); + const [password, setPassword] = useState(""); + + const handleLogin = async (e) => { + e.preventDefault(); + const formData = new FormData(); + formData.append("id", username); + formData.append("password", password); + + try { + const response = await axios.post(`${import.meta.env.VITE_API_URL}/api/auth/sign-in`,formData, { + headers: { "Content-Type": "multipart/form-data" }, + withCredentials: true + }); + + console.log(response); + + if (response.ok) { + alert("로그인 성공!"); + } else { + alert("로그인 실패: " + response.data.message); + } + } catch (error) { + console.error("로그인 오류:", error); + alert("로그인 중 오류가 발생했습니다."); + } + }; + + return ( +
+

로그인

+
+ setUsername(e.target.value)} + style={styles.input} + /> + setPassword(e.target.value)} + style={styles.input} + /> + +
+
+ ); +}; + +const styles = { + container: { display: "flex", flexDirection: "column", alignItems: "center", marginTop: "50px" }, + form: { display: "flex", flexDirection: "column", width: "250px" }, + input: { marginBottom: "10px", padding: "10px", fontSize: "16px" }, + button: { padding: "10px", fontSize: "16px", backgroundColor: "#007bff", color: "#fff", border: "none", cursor: "pointer" } +}; + diff --git a/src/pages/Wiki.jsx b/src/pages/Wiki.jsx index fed04d0..eb8ec2a 100644 --- a/src/pages/Wiki.jsx +++ b/src/pages/Wiki.jsx @@ -92,10 +92,10 @@ hello() <> setSearch(e.target.value)} />
-
{post.name}
+ {/*
{post.name}
*/} +
{id}
- {post.content} {description_markdown}
diff --git a/src/stores/PostStore.js b/src/stores/PostStore.js index 5f87712..74d32a2 100644 --- a/src/stores/PostStore.js +++ b/src/stores/PostStore.js @@ -1,5 +1,5 @@ import { create } from "zustand"; -import * as axios from "axios"; +import axios from "axios"; const usePostStore = create((set) => ({ post: { diff --git a/src/utils/cookie.js b/src/utils/cookie.js new file mode 100644 index 0000000..5f47aa5 --- /dev/null +++ b/src/utils/cookie.js @@ -0,0 +1,24 @@ +import {Cookies} from 'react-cookie' + +const cookies = new Cookies(); + +export const setCookie = (name, value, options)=>{ + + return cookies.set(name, value, {...options}) +} + +export const getCookie = (name)=>{ + return cookies.get(name) +} + +export const removeCookie = (name)=>{ + return cookies.remove(name, { path: '/'}) +} + +export const CheckLogin = () => { + if(getCookie('access_token') && getCookie('access_token') !== "undefined"){ + return true; + }else{ + return false; + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index ff16e1b..a3e6fb9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -25,6 +25,7 @@ __metadata: lint-staged: "npm:^15.4.3" prettier: "npm:^3.5.0" react: "npm:^19.0.0" + react-cookie: "npm:^7.2.2" react-device-detect: "npm:^2.2.3" react-dom: "npm:^19.0.0" react-markdown: "npm:^10.0.0" @@ -984,6 +985,16 @@ __metadata: languageName: node linkType: hard +"@types/hoist-non-react-statics@npm:^3.3.5": + version: 3.3.6 + resolution: "@types/hoist-non-react-statics@npm:3.3.6" + dependencies: + "@types/react": "npm:*" + hoist-non-react-statics: "npm:^3.3.0" + checksum: 10c0/149a4c217d81f21f8a1e152160a59d5b99b6a9aa6d354385d5f5bc02760cbf1e170a8442ba92eb653befff44b0c5bc2234bb77ce33e0d11a65f779e8bab5c321 + languageName: node + linkType: hard + "@types/json-schema@npm:^7.0.15": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" @@ -1032,7 +1043,7 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:^19.0.8": +"@types/react@npm:*, @types/react@npm:^19.0.8": version: 19.0.10 resolution: "@types/react@npm:19.0.10" dependencies: @@ -1537,6 +1548,13 @@ __metadata: languageName: node linkType: hard +"cookie@npm:^0.7.2": + version: 0.7.2 + resolution: "cookie@npm:0.7.2" + checksum: 10c0/9596e8ccdbf1a3a88ae02cf5ee80c1c50959423e1022e4e60b91dd87c622af1da309253d8abdb258fb5e3eacb4f08e579dc58b4897b8087574eee0fd35dfa5d2 + languageName: node + linkType: hard + "cookie@npm:^1.0.1": version: 1.0.2 resolution: "cookie@npm:1.0.2" @@ -2724,7 +2742,7 @@ __metadata: languageName: node linkType: hard -"hoist-non-react-statics@npm:^3.3.1": +"hoist-non-react-statics@npm:^3.3.0, hoist-non-react-statics@npm:^3.3.1, hoist-non-react-statics@npm:^3.3.2": version: 3.3.2 resolution: "hoist-non-react-statics@npm:3.3.2" dependencies: @@ -4551,6 +4569,19 @@ __metadata: languageName: node linkType: hard +"react-cookie@npm:^7.2.2": + version: 7.2.2 + resolution: "react-cookie@npm:7.2.2" + dependencies: + "@types/hoist-non-react-statics": "npm:^3.3.5" + hoist-non-react-statics: "npm:^3.3.2" + universal-cookie: "npm:^7.0.0" + peerDependencies: + react: ">= 16.3.0" + checksum: 10c0/22948a42b986e22dad0817ffbad72fe52c907a9cd09c82e683807e21eb85ec82adb7b5121f9869bae418d589a05570a1e1043b3c930c293e3d94ddeaa98602e0 + languageName: node + linkType: hard + "react-device-detect@npm:^2.2.3": version: 2.2.3 resolution: "react-device-detect@npm:2.2.3" @@ -5613,6 +5644,16 @@ __metadata: languageName: node linkType: hard +"universal-cookie@npm:^7.0.0": + version: 7.2.2 + resolution: "universal-cookie@npm:7.2.2" + dependencies: + "@types/cookie": "npm:^0.6.0" + cookie: "npm:^0.7.2" + checksum: 10c0/214c5cf72b12b6d98a72e11a10adb3f1d06dbeadbd9a2d46ded8c288d86387e9ff25499f85d2f85728809484d678c02028ac674cb8747257b38d2c17fb93e896 + languageName: node + linkType: hard + "uri-js@npm:^4.2.2": version: 4.4.1 resolution: "uri-js@npm:4.4.1"