Skip to content

feat: 게시글 삭제 기능 추가 및 삭제 모달 구현#51

Merged
g-hyxn merged 1 commit intodevelopfrom
feature/post
Dec 30, 2025
Merged

feat: 게시글 삭제 기능 추가 및 삭제 모달 구현#51
g-hyxn merged 1 commit intodevelopfrom
feature/post

Conversation

@g-hyxn
Copy link
Collaborator

@g-hyxn g-hyxn commented Dec 30, 2025

💡 배경 및 개요

게시글 삭제 기능 추가 및 삭제 모달 구현

퍼블리싱의 경우 스크린샷/동영상도 추가해주면 좋아요!

📃 작업내용

게시글 삭제 기능 추가 및 삭제 모달 구현하였습니다

🙋‍♂️ 리뷰노트

구현 시에 고민이었던 점들 혹은 특정 부분에 대한 의도가 있었다면 PR 리뷰의 이해를 돕기 위해 서술해주세요!

또한 리뷰어에게 특정 부분에 대한 집중 혹은 코멘트 혹은 질문을 요청하는 경우에 작성하면 좋아요!

e.g. 작업을 끝내야할 시간이 얼마 없어 확장성보다는 동작을 위주로 만들었어요! 감안하고 리뷰해주세요!

✅ PR 체크리스트

템플릿 체크리스트 말고도 추가적으로 필요한 체크리스트는 추가해주세요!

  • 이 작업으로 인해 변경이 필요한 문서가 변경되었나요? (e.g. .env, 노션, README)
  • 이 작업을 하고나서 공유해야할 팀원들에게 공유되었나요? (e.g. "API 개발 완료됐어요", "환경값 추가되었어요")
  • 작업한 코드가 정상적으로 동작하나요?
  • Merge 대상 브랜치가 올바른가요?
  • PR과 관련 없는 작업이 있지는 않나요?

🎸 기타

@vercel
Copy link

vercel bot commented Dec 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
cklob-gami Ready Ready Preview, Comment Dec 30, 2025 4:47am

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @g-hyxn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 게시글 삭제 기능을 도입하고, 이를 위한 사용자 친화적인 삭제 확인 모달을 구현합니다. 기존의 단순한 window.confirm 대화 상자를 대체하여 사용자에게 더 명확한 피드백을 제공하며, 삭제 로직의 오류 처리도 개선하여 안정성을 높였습니다. 전반적으로 게시글 관리 기능의 완성도를 높이고 사용자 인터페이스를 개선하는 데 중점을 두었습니다.

Highlights

  • 게시글 삭제 기능 추가: 관리자 권한으로 게시글을 삭제할 수 있는 기능이 추가되었습니다.
  • 삭제 모달 구현: 게시글 삭제 시 사용자에게 확인을 요청하는 모달이 구현되어 사용자 경험이 개선되었습니다.
  • 코드 개선 및 리팩토링: PostContent.tsx 파일에서 기존 window.confirm 대신 모달을 사용하도록 handleAdminDelete 로직이 변경되었고, isAdmin 함수가 제거되어 코드 가독성이 향상되었습니다.
  • 오류 처리 강화: 게시글 삭제 실패 시 발생하는 다양한 오류 상황(로그인 필요, 권한 없음, 게시글 없음, 서버 통신 불가 등)에 대한 토스트 메시지가 세분화되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이번 PR은 게시글 삭제 기능과 관련 모달을 구현한 변경 사항을 담고 있습니다. 전반적으로 기능은 잘 구현되었으나, 몇 가지 개선점을 제안합니다.
첫째, 모든 사용자에게 삭제 버튼이 노출되는 것은 사용자 경험을 해칠 수 있습니다. 관리자에게만 버튼이 보이도록 조건부 렌더링을 다시 추가하는 것이 좋겠습니다. 기존의 isAdmin 함수는 컴포넌트 내에서 JWT를 직접 다루는 문제가 있었으므로, 이를 제거한 것은 좋지만 사용자 역할 확인은 중앙화된 방식(예: Context API)으로 개선하여 적용하는 것을 권장합니다.
둘째, API 에러 처리 시 axios.isAxiosError 타입 가드를 사용하면 코드를 더 안정적이고 명확하게 만들 수 있습니다.
자세한 내용은 각 파일의 인라인 코멘트를 참고해주세요.

Comment on lines 198 to 213
if (typeof error === 'object' && error !== null && 'response' in error) {
const status = (error as { response?: { status?: number } }).response
?.status;

if (status === 401) toast.error('로그인이 필요합니다.');
else if (status === 403) toast.error('관리자 권한이 없습니다.');
else if (status === 404) toast.error('게시글을 찾을 수 없습니다.');
else toast.error('게시글 삭제에 실패했습니다.');
if (status === 401) {
toast.error('로그인이 필요합니다.');
} else if (status === 403) {
toast.error('관리자 권한이 없습니다.');
} else if (status === 404) {
toast.error('게시글을 찾을 수 없습니다.');
} else {
toast.error('게시글 삭제에 실패했습니다.');
}
} else {
toast.error('서버와 통신할 수 없습니다.');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Axios 에러를 처리할 때 axios.isAxiosError 타입 가드를 사용하는 것이 더 안정적이고 간결합니다. 현재의 typeof error === 'object' && error !== null && 'response' in error 방식 대신 axios.isAxiosError(error)를 사용하면 코드가 더 명확해지고, Axios가 제공하는 타입 안전성을 활용할 수 있습니다. 이를 위해 파일 상단에 import axios from 'axios';를 추가해야 합니다.

      if (axios.isAxiosError(error)) {
        const status = error.response?.status;

        if (status === 401) {
          toast.error('로그인이 필요합니다.');
        } else if (status === 403) {
          toast.error('관리자 권한이 없습니다.');
        } else if (status === 404) {
          toast.error('게시글을 찾을 수 없습니다.');
        } else {
          toast.error('게시글 삭제에 실패했습니다.');
        }
      } else {
        toast.error('서버와 통신할 수 없습니다.');
      }

Comment on lines +353 to +358
<button
onClick={() => setIsDeleteModalOpen(true)}
className="cursor-pointer"
>
<Delete />
</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

삭제 버튼이 이제 모든 사용자에게 표시됩니다. 권한이 없는 사용자가 삭제 버튼을 클릭하고 모달에서 확인을 누르면 '관리자 권한이 없습니다'라는 오류 메시지를 받게 됩니다. 이는 사용자 경험에 좋지 않습니다.

이전의 isAdmin 함수는 컴포넌트 내에서 JWT를 직접 파싱하는 등 문제가 있어 제거한 것은 좋은 결정입니다. 하지만 사용자 역할에 따라 버튼을 조건부로 렌더링하는 로직은 유지하는 것이 좋습니다.

사용자 정보를 관리하는 전역 상태(Context API, Redux 등)나 커스텀 훅(예: useUser)을 사용하여 사용자의 역할을 확인하고, 관리자일 경우에만 이 삭제 버튼이 보이도록 수정하는 것을 권장합니다.

@g-hyxn g-hyxn merged commit 0dc6b6b into develop Dec 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants