From c8b579cffbb6757685d3816233146b15b2a94146 Mon Sep 17 00:00:00 2001 From: Emithen <86219540+Emithen@users.noreply.github.com> Date: Fri, 12 Dec 2025 23:21:18 +0900 Subject: [PATCH 01/31] =?UTF-8?q?feat:=20=EC=84=A4=EC=A0=95=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=ED=94=8C=EB=A1=9C=ED=84=B0=20UI=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/votes.ts | 9 +++++ src/app/poll/[id]/page.tsx | 20 ++++++++++- .../pages/poll/_admin/AdminFloatingButton.tsx | 34 +++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/components/pages/poll/_admin/AdminFloatingButton.tsx diff --git a/src/api/votes.ts b/src/api/votes.ts index 7561654..9ad58f2 100644 --- a/src/api/votes.ts +++ b/src/api/votes.ts @@ -104,3 +104,12 @@ export const fetchMineVotesVoted = async ( throw error } } + +// 투표 삭제 API +export const deleteVote = async (voteId: number) => { + try { + await authApi.delete(`/votes/${voteId}`) + } catch (error) { + throw error + } +} diff --git a/src/app/poll/[id]/page.tsx b/src/app/poll/[id]/page.tsx index debf3dc..6dbdd31 100644 --- a/src/app/poll/[id]/page.tsx +++ b/src/app/poll/[id]/page.tsx @@ -12,10 +12,11 @@ import { Comment, } from '@/api/comment/commentApi' import VoteChart from '@/components/pages/poll/statistics/statisics' -import { fetchBestVote } from '@/api/votes' +import { deleteVote, fetchBestVote } from '@/api/votes' import Header from '@/components/_shared/header' import BottomNavBar from '@/components/_shared/nav/bottomNavBar' import Loading from '@/components/_shared/loading' +import AdminFloatingButton from '@/components/pages/poll/_admin/AdminFloatingButton' interface PollOption { optionId: number @@ -156,6 +157,22 @@ export default function PollDetailPage() { ) if (!data) return null + // mock data + const isAdmin = true + + const handleDelete = async () => { + const confirmed = window.confirm('게시글을 삭제하시겠습니까?') + if (!confirmed) return + + try { + await deleteVote(data.voteId) + router.back() + } catch (error) { + console.error('게시글 삭제 실패:', error) + alert('게시글 삭제에 실패했습니다.') + } + } + return (