Toggle navigation
Toggle navigation
This project
Loading...
Sign in
엄성진
/
Learn_In_Web
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sungjin
2021-12-04 20:27:44 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d9740a5aa05a86a1f6af750ff3b42230384a9ce8
d9740a5a
1 parent
5054ce5b
Add full support comment, with some design
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
12 deletions
src/api/auth/auth.js
src/api/post/post.js
src/api/runner/runner.js
src/components/Popular.js
src/pages/index.js
src/pages/login.js
src/pages/post/[id].js
src/api/auth/auth.js
View file @
d9740a5
...
...
@@ -66,6 +66,9 @@ export const refreshToken = async () => {
export
const
validateToken
=
async
()
=>
{
console
.
log
(
useSession
.
accessToken
);
if
(
useSession
.
accessToken
==
undefined
){
return
false
;
}
const
response
=
await
axios
.
post
(
`
${
SERVER_BASE_URL
}
/auth/validate`
,
{
token
:
useSession
.
accessToken
,
}).
catch
(
err
=>
{
...
...
src/api/post/post.js
View file @
d9740a5
...
...
@@ -12,7 +12,7 @@ export const newPost = async (
difficulty
,
)
=>
{
if
(
!
auth
.
validateToken
())
{
throw
new
Error
(
"plz login
"
);
throw
alert
(
"Please login first.
"
);
}
const
response
=
await
axios
.
post
(
`
${
SERVER_BASE_URL
}
/post`
,
{
token
:
auth
.
getToken
(),
...
...
@@ -60,6 +60,9 @@ export const getPostsByDifficulty = async (difficulty) => {
}
export
const
createComment
=
async
(
id
,
content
)
=>
{
if
(
!
await
auth
.
validateToken
())
{
throw
alert
(
"Please login first."
);
}
const
response
=
await
axios
.
post
(
`
${
SERVER_BASE_URL
}
/post/comment/
${
id
}
`
,
{
token
:
useSession
.
accessToken
,
content
,
...
...
src/api/runner/runner.js
View file @
d9740a5
...
...
@@ -6,7 +6,7 @@ import { useSession } from 'next-auth/client';
export
const
run
=
async
(
code
,
type
)
=>
{
if
(
!
auth
.
validateToken
())
{
throw
new
Error
(
"plz login
"
);
throw
alert
(
"Please login first.
"
);
}
const
response
=
await
axios
.
post
(
`
${
SERVER_BASE_URL
}
/runner`
,
{
token
:
auth
.
getToken
(),
...
...
src/components/Popular.js
View file @
d9740a5
...
...
@@ -26,7 +26,7 @@ export default function Popular() {
<
li
key
=
{
post
.
id
}
>
<
a
onClick
=
{()
=>
router
.
push
(
`/post/
${
post
.
id
}
`
)}
className
=
"cursor-pointer transition
duration-100 transform hover:text-white text-2xl"
>
<
a
>
{
post
.
title
}
<
/a
>
{
post
.
title
}
<
/a
>
<
span
className
=
"float-right"
>
{
DateType
(
post
.
createdAt
)}
<
/span
>
<
/li
>
...
...
src/pages/index.js
View file @
d9740a5
...
...
@@ -11,7 +11,7 @@ export default function Home() {
<
link
rel
=
"icon"
href
=
"/favicon.ico"
/>
<
/Head
>
{
/* 기본 컨텐츠 */
}
<
div
className
=
'ui container
fixed
left-10'
>
<
div
className
=
'ui container
relative
left-10'
>
<
h3
className
=
"text-3xl font-bold"
>
인기
문제
<
/h3
>
<
Popular
/>
<
/div
>
...
...
src/pages/login.js
View file @
d9740a5
...
...
@@ -7,7 +7,7 @@ export default function Login() {
return
(
<
div
className
=
"flex h-auto"
>
<
div
className
=
"w-auto inline-block p-3
bg-black
rounded-lg m-auto"
>
<
div
className
=
"w-auto inline-block p-3 rounded-lg m-auto"
>
<
h1
className
=
"font-bold text-4xl text-center"
>
로그인
<
/h1
>
<
form
onSubmit
=
{
handleSubmit
}
>
<
input
type
=
"email"
id
=
"email"
placeholder
=
"email"
className
=
"my-2 rounded-sm"
/>
...
...
src/pages/post/[id].js
View file @
d9740a5
...
...
@@ -36,22 +36,24 @@ export default function Post() {
const
[
comment
,
setComment
]
=
useState
(
""
);
const
addComment
=
async
()
=>
{
console
.
log
(
"comment is "
+
comment
);
const
{
id
}
=
router
.
query
const
response
=
await
createComment
(
id
,
comment
)
await
createComment
(
id
,
comment
)
}
const
displayComment
=
()
=>
{
console
.
log
(
post
.
comments
);
if
(
post
.
comments
!=
undefined
)
{
return
post
.
comments
.
map
(
comment
=>
(
<
div
className
=
"w-full"
>
<
div
className
=
"w-full flex justify-between"
>
<
div
className
=
"w-1/2"
>
<
span
className
=
"text-gray-700"
>
{
comment
.
username
}
<
/span
>
<
div
className
=
"flex w-full border-carbon border-4 rounded-xl my-2"
>
<
div
className
=
"w-full justify-between"
>
<
div
className
=
" mx-2"
>
<
p
className
=
"text-black w-[90%]"
>
{
comment
.
content
}
<
/p
>
<
span
className
=
"text-black float-right"
>
{
`작성자 :
${
comment
.
author
.
name
}
`
}
<
/span
>
<
/div
>
<
/div
>
<
/div>
)
)
<
/div
>
)
);
}
return
<
div
><
/div
>
}
...
...
Please
register
or
login
to post a comment