Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ export const logout = async () => {
throw error
}
}

export const signout = async () => {
try {
await authApi.post('/auth/withdraw')
} catch (error) {
throw error
Copy link
Collaborator

Choose a reason for hiding this comment

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

이거 받아주는 곳 있나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이거 받아주는 곳 있나요?

srt/store/thunks/authThunks.ts -> 여기 thunk 단에서 받아줍니다. 근데 아직 redux thunk 계층 예외 처리 전략이 없어서 딱히 뭘 하고 있진 않음.

}
}
3 changes: 2 additions & 1 deletion src/app/poll/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default function PollDetailPage() {
try {
await deleteVote(data.voteId)
setDeleteModalOpen(false)
router.back()
Copy link
Collaborator

Choose a reason for hiding this comment

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

왜.. 왜 백이었죠

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

왜.. 왜 백이었죠

플로우가 게시글 클릭 -> 삭제 이거밖에 없는 줄 알았는데, 생성 페이지 -> 삭제도 있어가지고 바꿨습니다.

router.push('/balanse')
} catch (error) {
console.error('게시글 삭제 실패:', error)
alert('게시글 삭제에 실패했습니다.')
Expand Down Expand Up @@ -259,6 +259,7 @@ export default function PollDetailPage() {
comments={comments}
voteId={data.voteId}
onClose={() => setOpen(false)}
profile={profile}
/>
)}
{data && (
Expand Down
14 changes: 10 additions & 4 deletions src/components/pages/my/accountControlSection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useAppDispatch } from '@/hooks/utils/useAppDispatch'
import { logoutThunk } from '@/store/thunks/authThunks'
import { logoutThunk, signoutThunk } from '@/store/thunks/authThunks'

export default function AccountControlSection() {
const dispatch = useAppDispatch()
Expand All @@ -8,14 +8,20 @@ export default function AccountControlSection() {
dispatch(logoutThunk())
}

const handleSignout = () => {
dispatch(signoutThunk())
}

return (
<section className="bg-white px-4 py-4 text-md">
<div className="h-10 text-[#555555]">계정 관리</div>
<div className="flex flex-col gap-3">
<div className="text-left h-10 font-bold" onClick={handleLogout}>
<button className="text-left h-10 font-bold" onClick={handleLogout}>
로그아웃
</div>
<div className="text-left h-10 font-bold">탈퇴하기</div>
</button>
<button className="text-left h-10 font-bold" onClick={handleSignout}>
탈퇴하기
</button>
</div>
</section>
)
Expand Down
25 changes: 15 additions & 10 deletions src/components/pages/poll/Comment/commentDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,20 @@ import {
ModalBody,
ModalFooter,
} from '@/components/ui/modal'
import { Profile } from '@/types/member'

interface CommentDetailProps {
comments?: Comment[]
voteId?: number | string
onClose?: () => void
profile: Profile
}

const CommentDetail = ({
comments = [],
voteId,
onClose,
profile,
}: CommentDetailProps) => {
const [openReplies, setOpenReplies] = useState<Record<number, boolean>>({})
const [currentSort, setCurrentSort] = useState<'popular' | 'latest'>(
Expand Down Expand Up @@ -201,13 +204,12 @@ const CommentDetail = ({

const confirmDelete = async () => {
const { commentId } = deleteConfirmModal
if (!commentId) return
if (!commentId || !voteId) return

try {
await deleteComment(commentId)
setLocalComments((prev) =>
prev.filter((comment) => comment.commentId !== commentId),
)
const response = await fetchComments(voteId, { sort: currentSort })
setLocalComments(response.comments)
setDeleteConfirmModal({ isOpen: false, commentId: null })
} catch (error) {
console.error('댓글 삭제 실패:', error)
Expand Down Expand Up @@ -294,12 +296,15 @@ const CommentDetail = ({
</div>
</div>
<div className="relative menu-container">
<button
className="text-gray-400 hover:text-gray-600 p-1"
onClick={() => toggleMenu(comment.commentId)}
>
<MoreVertical size={16} />
</button>
{(profile.role === 'ADMIN' ||
comment.nickname === profile.nickname) && (
<button
className="text-gray-400 hover:text-gray-600 p-1"
onClick={() => toggleMenu(comment.commentId)}
>
<MoreVertical size={16} />
</button>
)}
{openMenus[comment.commentId] && (
<div className="absolute right-0 top-8 bg-white border border-gray-200 rounded-lg shadow-lg z-10 min-w-[120px]">
<button
Expand Down
12 changes: 11 additions & 1 deletion src/store/thunks/authThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AppDispatch } from '../store'
import { getRefreshToken } from '@/utils/tokenUtils'
import { saveTokens, clearTokens } from '@/utils/tokenUtils'
import { reissue } from '@/api/auth'
import { logout as logoutApi } from '@/api/auth'
import { logout as logoutApi, signout as signoutApi } from '@/api/auth'
import { login } from '@/api/auth'

export const loginThunk = (code: string) => async (dispatch: AppDispatch) => {
Expand Down Expand Up @@ -53,3 +53,13 @@ export const logoutThunk = () => async (dispatch: AppDispatch) => {
throw err
}
}

export const signoutThunk = () => async (dispatch: AppDispatch) => {
try {
await signoutApi()
dispatch(logout())
clearTokens()
} catch (err) {
throw err
}
}