-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from jooyong-boo/develop
merge develop
- Loading branch information
Showing
10 changed files
with
233 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import Link from 'next/link'; | ||
import { BurgerMenu } from '@/assets/svg/index'; | ||
import { deletePost } from '@/services/posts'; | ||
|
||
const PostMenu = ({ id }: { id: string }) => { | ||
const [isMenuOpen, setIsMenuOpen] = useState(false); | ||
|
||
const handleToggleMenu = () => { | ||
setIsMenuOpen((prev) => !prev); | ||
}; | ||
|
||
const handleDeletePost = async () => { | ||
if (confirm('삭제하시겠습니까?')) { | ||
await deletePost(id); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="relative"> | ||
<button onClick={handleToggleMenu}> | ||
<BurgerMenu /> | ||
</button> | ||
{isMenuOpen && ( | ||
<div className="absolute right-0 flex w-24 flex-col gap-2 rounded-md bg-slate-600 p-2 text-center"> | ||
<Link | ||
className="hover:text-sky-600 dark:hover:text-orange-600" | ||
href={`/posts/${id}/edit`} | ||
> | ||
수정하기 | ||
</Link> | ||
<button | ||
className="hover:text-sky-600 dark:hover:text-orange-600" | ||
onClick={handleDeletePost} | ||
> | ||
삭제하기 | ||
</button> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default PostMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.