Showing
6 changed files
with
27 additions
and
6 deletions
1 | -import { Link } from "@nextui-org/react"; | 1 | +import { Button, Link } from "@nextui-org/react"; |
2 | import { getPosts } from "../api/post"; | 2 | import { getPosts } from "../api/post"; |
3 | import { useState } from "react"; | 3 | import { useState } from "react"; |
4 | import { useEffect } from "react"; | 4 | import { useEffect } from "react"; |
5 | +import { useRouter } from "next/router"; | ||
5 | 6 | ||
6 | export default function Popular() { | 7 | export default function Popular() { |
7 | const [posts, setPosts] = useState([]); | 8 | const [posts, setPosts] = useState([]); |
9 | + const router = useRouter(); | ||
8 | useEffect(() => { | 10 | useEffect(() => { |
9 | getPosts(10).then(setPosts); | 11 | getPosts(10).then(setPosts); |
10 | }, []); | 12 | }, []); |
... | @@ -22,9 +24,10 @@ export default function Popular() { | ... | @@ -22,9 +24,10 @@ export default function Popular() { |
22 | <ul> | 24 | <ul> |
23 | {posts.map(post => ( | 25 | {posts.map(post => ( |
24 | <li key={post.id}> | 26 | <li key={post.id}> |
25 | - <Link href={`/post/${post.id}`} className="text-xl"> | 27 | + <a onClick={() => router.push(`/post/${post.id}`)} className="cursor-pointer transition |
28 | + duration-100 transform hover:text-white text-2xl"> | ||
26 | <a>{post.title}</a> | 29 | <a>{post.title}</a> |
27 | - </Link> | 30 | + </a> |
28 | <span className="float-right">{DateType(post.createdAt)}</span> | 31 | <span className="float-right">{DateType(post.createdAt)}</span> |
29 | </li> | 32 | </li> |
30 | ))} | 33 | ))} | ... | ... |
... | @@ -26,7 +26,10 @@ export default function Login() { | ... | @@ -26,7 +26,10 @@ export default function Login() { |
26 | if(!login) { | 26 | if(!login) { |
27 | alert("Login failed"); | 27 | alert("Login failed"); |
28 | } | 28 | } |
29 | + else { | ||
30 | + alert("Login success"); | ||
29 | return router.push("/"); | 31 | return router.push("/"); |
30 | } | 32 | } |
33 | + } | ||
31 | } | 34 | } |
32 | 35 | ... | ... |
src/pages/logout.js
0 → 100644
... | @@ -24,8 +24,6 @@ export default function Post() { | ... | @@ -24,8 +24,6 @@ export default function Post() { |
24 | }) | 24 | }) |
25 | }, [router.isReady]); | 25 | }, [router.isReady]); |
26 | 26 | ||
27 | - console.log(post); | ||
28 | - | ||
29 | const [value, setValue] = useState("c"); | 27 | const [value, setValue] = useState("c"); |
30 | 28 | ||
31 | const [code, setCode] = useState(""); | 29 | const [code, setCode] = useState(""); |
... | @@ -47,6 +45,9 @@ export default function Post() { | ... | @@ -47,6 +45,9 @@ export default function Post() { |
47 | <option value="c">c</option> | 45 | <option value="c">c</option> |
48 | <option value="cpp">cpp</option> | 46 | <option value="cpp">cpp</option> |
49 | <option value="js">javascript</option> | 47 | <option value="js">javascript</option> |
48 | + <option value="ts">typescript</option> | ||
49 | + <option value="go">golang</option> | ||
50 | + <option value="py">python</option> | ||
50 | </select> | 51 | </select> |
51 | <span className="left-100 fixed text-2xl font-semibold">문제 설명</span> | 52 | <span className="left-100 fixed text-2xl font-semibold">문제 설명</span> |
52 | <br></br> | 53 | <br></br> |
... | @@ -69,7 +70,7 @@ export default function Post() { | ... | @@ -69,7 +70,7 @@ export default function Post() { |
69 | </div> | 70 | </div> |
70 | <div className="w-6/12 inline-block align-top">{post.explain}</div> | 71 | <div className="w-6/12 inline-block align-top">{post.explain}</div> |
71 | <Button onClick={runCode} className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Run</Button> | 72 | <Button onClick={runCode} className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Run</Button> |
72 | - <p>{runCode}</p> | 73 | + <div className="">{answer}</div> |
73 | 74 | ||
74 | <p>{post.example}</p> | 75 | <p>{post.example}</p> |
75 | </div> | 76 | </div> | ... | ... |
... | @@ -29,5 +29,8 @@ function handleSubmit(event) { | ... | @@ -29,5 +29,8 @@ function handleSubmit(event) { |
29 | if(!signup) { | 29 | if(!signup) { |
30 | alert("Signup failed"); | 30 | alert("Signup failed"); |
31 | } | 31 | } |
32 | + else { | ||
33 | + alert("Signup success"); | ||
32 | return push("/"); | 34 | return push("/"); |
35 | + } | ||
33 | } | 36 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment