-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] 어드민 기대평 페이지 구현 #104
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5bc80e4
[file] 랜덤 문자열 생성 함수 분리
darkdulgi 2601053
[feat] 어드민 기대평에 pagination 적용
darkdulgi 6d2aded
[feat] 기대평 삭제 확인 알림 구현과 작성시간 양식 수정
darkdulgi 521a25b
[design] 삭제 시 모달 삽입
darkdulgi d8f4a94
Merge branch 'dev' of https://github.com/softeerbootcamp4th/Team6-Awe…
darkdulgi d6900ca
[feat] 기대평 전체 선택 기능 구현
darkdulgi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useMutation } from "@common/dataFetch/getQuery.js"; | ||
import openModal from "@common/modal/openModal.js"; | ||
import { fetchServer } from "@common/dataFetch/fetchServer.js"; | ||
import ConfirmModal from "@admin/modals/ConfirmModal.jsx"; | ||
import AlertModal from "@admin/modals/AlertModal.jsx"; | ||
|
||
export default function DeleteButton({ | ||
eventId, | ||
checkedComments, | ||
setCheckedComments, | ||
}) { | ||
const num = checkedComments.size; | ||
const mutation = useMutation(eventId, () => | ||
fetchServer("/api/v1/admin/comments", { | ||
method: "DELETE", | ||
body: { | ||
commentIds: [...checkedComments], | ||
}, | ||
}) | ||
.then(() => { | ||
openModal( | ||
<AlertModal title="삭제" description="기대평이 삭제되었습니다." />, | ||
); | ||
setCheckedComments(new Set()); | ||
}) | ||
.catch((e) => { | ||
alert("삭제 실패"); | ||
console.log(e); | ||
}), | ||
); | ||
|
||
const deleteConfirmModal = ( | ||
<ConfirmModal | ||
title="삭제" | ||
description={ | ||
<> | ||
<span>이 동작은 다시 돌이킬 수 없습니다.</span> | ||
<br /> | ||
<span>{num}개의 이벤트를 삭제하시겠습니까?</span> | ||
</> | ||
} | ||
onConfirm={mutation} | ||
/> | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 공통 컴포넌트를 사용하시는 거 좋습니다. |
||
|
||
function deleteComments() { | ||
if (!num) return; | ||
openModal(deleteConfirmModal); | ||
} | ||
|
||
return ( | ||
<button | ||
onClick={deleteComments} | ||
className="self-end px-5 py-1 bg-red-300 text-white hover:bg-red-500 rounded-lg" | ||
> | ||
삭제 | ||
</button> | ||
); | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventId 자체는 다른 useQuery 또는 useMutation에서 중복될 수 있는 값이므로, 고유한 자원을 위해 "admin-comment-(eventId)" 같은 걸로 바꾸면 좋을 겁니다.