Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
travel
Commits
f21493ca
Commit
f21493ca
authored
Aug 15, 2022
by
Lee Soobeom
Browse files
board
parent
a6e57583
Changes
1
Show whitespace changes
Inline
Side-by-side
frontend/src/board/board.tsx
View file @
f21493ca
...
...
@@ -17,6 +17,7 @@ export default function BoardPage() {
const
[
posts
,
setPosts
]
=
useState
<
PostType
[]
>
();
const
location
=
useLocation
()
as
Newpost
;
const
newPost
=
location
.
state
;
const
deletePostId
=
location
.
state
.
_id
;
const
navigate
=
useNavigate
();
const
{
user
}
=
useAuth
();
...
...
@@ -34,17 +35,17 @@ export default function BoardPage() {
setNewPosts
(
newPost
);
},
[]);
// posts
const
getDataList
=
async
()
=>
{
const
res
=
await
postApi
.
getData
();
setPosts
(
res
);
//posts = res
};
const
titleHandleClick
=
async
(
event
:
MouseEvent
<
HTMLButtonElement
>
)
=>
{
if
(
!
user
.
isLoggedIn
)
{
alert
(
"
로그인이 필요합니다.
"
);
navigate
(
"
/login
"
,
{
replace
:
true
});
}
else
{
const
deletePost
=
async
(
postId
:
string
)
=>
{
const
res
=
await
postApi
.
deletePost
(
postId
);
return
res
;
};
const
handleClick
=
async
(
event
:
MouseEvent
<
HTMLButtonElement
>
)
=>
{
const
postId
=
event
.
currentTarget
.
id
;
const
newpost
=
posts
?.
find
((
element
)
=>
{
if
(
element
.
_id
===
postId
)
{
...
...
@@ -55,8 +56,7 @@ export default function BoardPage() {
const
post
=
newpost
;
const
res
=
await
postApi
.
addCounts
(
post
.
_id
,
post
.
counts
);
// console.log(res);
setPosts
(
res
);
}
// setPosts(res);
}
};
...
...
@@ -94,7 +94,7 @@ export default function BoardPage() {
</
div
>
<
div
>
{
posts
?.
map
((
post
,
i
)
=>
(
<
Post
key
=
{
i
}
post
=
{
post
}
handleClick
=
{
titleH
andleClick
}
/>
<
Post
key
=
{
i
}
post
=
{
post
}
handleClick
=
{
h
andleClick
}
/>
))
}
</
div
>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment