-
Notifications
You must be signed in to change notification settings - Fork 0
[Fix] WTH-355: 어드민 QA - 게시판 관리 수정 #83
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
Merged
The head ref may contain hidden characters: "fix/WTH-355-\uC5B4\uB4DC\uBBFC-QA-\uAC8C\uC2DC\uD310-\uAD00\uB9AC-\uC218\uC815"
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fb9c17a
fix: 게시판 스켈레톤 컴포넌트 분리
JIN921 2af1f36
fix: 게시판 카드 댓글 허용 스위치 추가
JIN921 624b271
fix: 공지 게시판 댓글 허용 토글 표시
JIN921 a131e33
fix: 공지 게시판 댓글 허용 요청 안 되는 문제 해결
JIN921 5725e6c
fix: 게시판 mutation 토스트 추가
JIN921 a15a05c
fix: 댓글 허용 중 요청이 더 가지 않도록 가드
JIN921 0722c87
fix: 게시판 알림 문구 수정
JIN921 2bbf1ff
refactor: 레거시 코드 제거 및 버그 수정
JIN921 28be459
fix: 댓글 토글 틈새 제거
JIN921 e66fa32
fix: 서버 상태 페칭 변경
JIN921 566e6c9
fix: 멤버 기수최신 기수로 표시하도록 수정
JIN921 0a33ce8
Merge branch 'develop' into fix/WTH-355-어드민-QA-게시판-관리-수정
JIN921 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 hidden or 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,33 @@ | ||
| import { Skeleton } from '@/components/ui'; | ||
| import { BoardCardSkeleton } from './BoardCardSkeleton'; | ||
|
|
||
| export function BoardAdminSkeleton() { | ||
| return ( | ||
| <div className="flex min-w-0 flex-col gap-400 p-700"> | ||
| {/* Toolbar skeleton */} | ||
| <div className="flex flex-wrap items-center gap-300"> | ||
| <Skeleton className="h-20 min-w-65 flex-1 rounded-lg" /> | ||
| <Skeleton className="h-12 w-30 shrink-0 rounded-lg" /> | ||
| </div> | ||
|
|
||
| {/* Board card skeletons */} | ||
| <div className="flex flex-col gap-400"> | ||
| <div className="flex flex-col gap-400"> | ||
| <BoardCardSkeleton /> | ||
| <div className="border-line w-full border-t" /> | ||
| <BoardCardSkeleton /> | ||
| </div> | ||
|
|
||
| <div className="border-line w-full border-t" /> | ||
|
|
||
| <div className="flex flex-col gap-200"> | ||
| <BoardCardSkeleton /> | ||
| <BoardCardSkeleton /> | ||
| <BoardCardSkeleton /> | ||
| </div> | ||
|
|
||
| <Skeleton className="h-12 rounded-md" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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
|
JIN921 marked this conversation as resolved.
|
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -16,10 +16,9 @@ import { | |
| } from '@dnd-kit/sortable'; | ||
| import { useQueryClient } from '@tanstack/react-query'; | ||
|
|
||
| import { Icon, Skeleton } from '@/components/ui'; | ||
| import { Icon } from '@/components/ui'; | ||
| import { InfoCircleIcon } from '@/assets/icons'; | ||
| import { BoardCard } from '@/components/admin/board/BoardCard'; | ||
| import { BoardCardSkeleton } from '@/components/admin/board/BoardCardSkeleton'; | ||
| import { BoardToolbar } from '@/components/admin/board/BoardToolbar'; | ||
| import { CreateBoardModal } from '@/components/admin/board/modal/CreateBoardModal'; | ||
| import { EditBoardModal } from '@/components/admin/board/modal/EditBoardModal'; | ||
|
|
@@ -28,22 +27,43 @@ import { useBoardDragReorder } from '@/hooks/admin'; | |
| import { useAdminBoardsQuery } from '@/hooks/queries/admin/useAdminBoardsQuery'; | ||
| import { useCreateBoardMutation } from '@/hooks/queries/admin/useCreateBoardMutation'; | ||
| import { useUpdateBoardMutation } from '@/hooks/queries/admin/useUpdateBoardMutation'; | ||
| import { useToggleBoardCommentMutation } from '@/hooks/queries/admin/useToggleBoardCommentMutation'; | ||
| import { useDeleteBoardMutation } from '@/hooks/queries/admin/useDeleteBoardMutation'; | ||
| import { useUpdateBoardOrderMutation } from '@/hooks/queries/admin/useUpdateBoardOrderMutation'; | ||
| import { adminBoardQueryKeys } from '@/hooks/queries/admin/boardQueryKeys'; | ||
| import { ADMIN_BOARD_ERROR, getApiErrorCode, getApiErrorMessage } from '@/lib/apis/adminBoard'; | ||
| import { useClubId } from '@/stores'; | ||
| import { toastError } from '@/stores/useToastStore'; | ||
| import { toastError, toastSuccess } from '@/stores/useToastStore'; | ||
| import { toApiPermission } from '@/utils/admin/boardMapper'; | ||
| import { MAX_CUSTOM_BOARDS } from '@/constants/admin/board.constants'; | ||
| import type { Board, BoardListCache } from '@/types/admin/board'; | ||
| import type { Board, BoardKind, BoardListCache } from '@/types/admin/board'; | ||
| import type { BoardFormData } from '@/components/admin/board/modal/constants'; | ||
| import { SortableBoardCard } from './SortableBoardCard'; | ||
| import { BoardAdminSkeleton } from './BoardAdminSkeleton'; | ||
|
|
||
| function subscribeMounted() { | ||
| return () => {}; | ||
| } | ||
|
|
||
| const FIXED_BOARD_ORDER: BoardKind[] = ['ALL', 'NOTICE']; | ||
|
|
||
| function compareFixedBoards(a: Board, b: Board) { | ||
| const ai = FIXED_BOARD_ORDER.indexOf(a.kind); | ||
| const bi = FIXED_BOARD_ORDER.indexOf(b.kind); | ||
| return (ai === -1 ? FIXED_BOARD_ORDER.length : ai) - (bi === -1 ? FIXED_BOARD_ORDER.length : bi); | ||
| } | ||
|
|
||
| function handleNameMutationError(setNameError: (msg: string) => void) { | ||
| return (err: unknown) => { | ||
| const code = getApiErrorCode(err); | ||
| if (code === ADMIN_BOARD_ERROR.DUPLICATE_NAME) { | ||
| setNameError('같은 이름의 게시판이 이미 있어요.'); | ||
| } else { | ||
| toastError(getApiErrorMessage(err)); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| function BoardPageContent() { | ||
| const clubId = useClubId(); | ||
| const queryClient = useQueryClient(); | ||
|
|
@@ -53,6 +73,21 @@ function BoardPageContent() { | |
| const [createNameError, setCreateNameError] = useState<string | null>(null); | ||
| const [editingBoardId, setEditingBoardId] = useState<number | null>(null); | ||
| const [editNameError, setEditNameError] = useState<string | null>(null); | ||
| const [pendingToggleIds, setPendingToggleIds] = useState<Set<number>>(() => new Set()); | ||
|
|
||
| const addPendingToggle = (boardId: number) => | ||
| setPendingToggleIds((prev) => { | ||
| const next = new Set(prev); | ||
| next.add(boardId); | ||
| return next; | ||
| }); | ||
|
|
||
| const removePendingToggle = (boardId: number) => | ||
| setPendingToggleIds((prev) => { | ||
| const next = new Set(prev); | ||
| next.delete(boardId); | ||
| return next; | ||
| }); | ||
| const mounted = useSyncExternalStore( | ||
| subscribeMounted, | ||
| () => true, | ||
|
|
@@ -70,31 +105,26 @@ function BoardPageContent() { | |
| const { handleDragStart, handleDragEnd } = useBoardDragReorder({ onReorder: updateBoardOrder }); | ||
|
|
||
| const { mutate: createBoard } = useCreateBoardMutation({ | ||
| onSuccess: () => setCreateModalOpen(false), | ||
| onError: (err) => { | ||
| const code = getApiErrorCode(err); | ||
| if (code === ADMIN_BOARD_ERROR.DUPLICATE_NAME) { | ||
| setCreateNameError('같은 이름의 게시판이 이미 있어요.'); | ||
| } else { | ||
| toastError(getApiErrorMessage(err)); | ||
| } | ||
| onSuccess: () => { | ||
| setCreateModalOpen(false); | ||
| toastSuccess('게시판이 생성되었어요.'); | ||
| }, | ||
| onError: handleNameMutationError(setCreateNameError), | ||
| }); | ||
|
|
||
| const { mutate: updateBoard } = useUpdateBoardMutation({ | ||
| onSuccess: () => setEditingBoardId(null), | ||
| onError: (err) => { | ||
| const code = getApiErrorCode(err); | ||
| if (code === ADMIN_BOARD_ERROR.DUPLICATE_NAME) { | ||
| setEditNameError('같은 이름의 게시판이 이미 있어요.'); | ||
| } else { | ||
| toastError(getApiErrorMessage(err)); | ||
| } | ||
| onSuccess: () => { | ||
| setEditingBoardId(null); | ||
| toastSuccess('게시판이 수정되었어요.'); | ||
| }, | ||
| onError: handleNameMutationError(setEditNameError), | ||
| }); | ||
|
|
||
| const { mutate: deleteBoard } = useDeleteBoardMutation({ | ||
| onSuccess: () => setEditingBoardId(null), | ||
| onSuccess: () => { | ||
| setEditingBoardId(null); | ||
| toastSuccess('게시판이 삭제되었어요.'); | ||
| }, | ||
| onError: (err) => { | ||
| const code = getApiErrorCode(err); | ||
| if (code === ADMIN_BOARD_ERROR.BOARD_NOT_FOUND) { | ||
|
|
@@ -105,7 +135,8 @@ function BoardPageContent() { | |
| }, | ||
| }); | ||
|
|
||
| const { mutate: toggleComment } = useUpdateBoardMutation({ | ||
| const { mutate: toggleComment } = useToggleBoardCommentMutation({ | ||
| onSuccess: () => toastSuccess('댓글 허용 설정을 변경했어요.'), | ||
| onError: (err) => toastError(getApiErrorMessage(err)), | ||
| }); | ||
|
|
||
|
|
@@ -114,36 +145,7 @@ function BoardPageContent() { | |
| useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }), | ||
| ); | ||
|
|
||
| if (isLoading || !data) { | ||
| return ( | ||
| <div className="flex min-w-0 flex-col gap-400 p-700"> | ||
| {/* Toolbar skeleton */} | ||
| <div className="flex flex-wrap items-center gap-300"> | ||
| <Skeleton className="h-20 min-w-65 flex-1 rounded-lg" /> | ||
| <Skeleton className="h-12 w-30 shrink-0 rounded-lg" /> | ||
| </div> | ||
|
|
||
| {/* Board card skeletons */} | ||
| <div className="flex flex-col gap-400"> | ||
| <div className="flex flex-col gap-400"> | ||
| <BoardCardSkeleton /> | ||
| <div className="border-line w-full border-t" /> | ||
| <BoardCardSkeleton /> | ||
| </div> | ||
|
|
||
| <div className="border-line w-full border-t" /> | ||
|
|
||
| <div className="flex flex-col gap-200"> | ||
| <BoardCardSkeleton /> | ||
| <BoardCardSkeleton /> | ||
| <BoardCardSkeleton /> | ||
| </div> | ||
|
|
||
| <Skeleton className="h-12 rounded-md" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| if (isLoading || !data) return <BoardAdminSkeleton />; | ||
|
|
||
| const { boards } = data; | ||
|
|
||
|
|
@@ -159,6 +161,8 @@ function BoardPageContent() { | |
| }; | ||
|
|
||
| const handleToggleComments = (boardId: number, next: boolean) => { | ||
| if (pendingToggleIds.has(boardId)) return; | ||
|
|
||
| const target = boards.find((b) => b.boardId === boardId); | ||
| if (!target) return; | ||
|
|
||
|
|
@@ -169,11 +173,12 @@ function BoardPageContent() { | |
| boards: prev.boards.map((b) => (b.boardId === boardId ? { ...b, commentEnabled: next } : b)), | ||
| })); | ||
|
|
||
| addPendingToggle(boardId); | ||
|
|
||
| toggleComment( | ||
| { | ||
| boardId, | ||
| body: { | ||
| name: target.name, | ||
| description: target.description, | ||
| commentEnabled: next, | ||
| ...toApiPermission(target.visibility), | ||
|
|
@@ -183,6 +188,7 @@ function BoardPageContent() { | |
| onError: () => { | ||
| queryClient.setQueryData(cacheKey, snapshot); | ||
| }, | ||
| onSettled: () => removePendingToggle(boardId), | ||
| }, | ||
| ); | ||
| }; | ||
|
|
@@ -225,14 +231,24 @@ function BoardPageContent() { | |
| ? boards.filter((b) => b.name.toLowerCase().includes(query)) | ||
| : boards; | ||
|
|
||
| const fixedBoards = filteredBoards.filter((b) => !b.editable); | ||
| const fixedBoards = filteredBoards.filter((b) => !b.editable).sort(compareFixedBoards); | ||
| const customBoards = filteredBoards.filter((b) => b.editable); | ||
| const totalCustomCount = boards.filter((b) => b.editable).length; | ||
| const reachedLimit = totalCustomCount >= MAX_CUSTOM_BOARDS; | ||
|
|
||
| const editingBoard = | ||
| editingBoardId !== null ? (boards.find((b) => b.boardId === editingBoardId) ?? null) : null; | ||
|
|
||
| const getToggleProps = (board: Board) => ({ | ||
| onToggleComments: (next: boolean) => handleToggleComments(board.boardId, next), | ||
| commentTogglePending: pendingToggleIds.has(board.boardId), | ||
| }); | ||
|
|
||
| const getEditableProps = (board: Board) => ({ | ||
| onEdit: () => setEditingBoardId(board.boardId), | ||
| onDelete: () => handleMoveToTrash(board), | ||
| }); | ||
|
|
||
| return ( | ||
| <div className="flex min-w-0 flex-col gap-400 p-700"> | ||
| <BoardToolbar | ||
|
|
@@ -243,7 +259,7 @@ function BoardPageContent() { | |
| // onTrashClick={() => setTrashModalOpen(true)} | ||
| onCreateClick={ | ||
| reachedLimit | ||
| ? () => toastError(`추가 게시판은 최대 ${MAX_CUSTOM_BOARDS}개까지 만들 수 있어요.`) | ||
| ? () => toastError(`게시판은 최대 ${MAX_CUSTOM_BOARDS}개까지 만들 수 있어요.`) | ||
| : () => setCreateModalOpen(true) | ||
| } | ||
| /> | ||
|
|
@@ -254,11 +270,7 @@ function BoardPageContent() { | |
| {fixedBoards.map((board, index) => ( | ||
| <Fragment key={board.boardId}> | ||
|
JIN921 marked this conversation as resolved.
|
||
| {index > 0 && <div className="border-line w-full border-t" />} | ||
| <BoardCard | ||
| board={board} | ||
| draggable={false} | ||
| onToggleComments={(next) => handleToggleComments(board.boardId, next)} | ||
| /> | ||
| <BoardCard board={board} draggable={false} {...getToggleProps(board)} /> | ||
| </Fragment> | ||
| ))} | ||
| </div> | ||
|
|
@@ -276,9 +288,8 @@ function BoardPageContent() { | |
| key={board.boardId} | ||
| board={board} | ||
| draggable={false} | ||
| onToggleComments={(next) => handleToggleComments(board.boardId, next)} | ||
| onEdit={() => setEditingBoardId(board.boardId)} | ||
| onDelete={() => handleMoveToTrash(board)} | ||
| {...getToggleProps(board)} | ||
| {...getEditableProps(board)} | ||
| /> | ||
| ))} | ||
| </div> | ||
|
|
@@ -298,9 +309,8 @@ function BoardPageContent() { | |
| <SortableBoardCard | ||
| key={board.boardId} | ||
| board={board} | ||
| onToggleComments={(next) => handleToggleComments(board.boardId, next)} | ||
| onEdit={() => setEditingBoardId(board.boardId)} | ||
| onDelete={() => handleMoveToTrash(board)} | ||
| {...getToggleProps(board)} | ||
| {...getEditableProps(board)} | ||
| /> | ||
| ))} | ||
| </div> | ||
|
|
@@ -311,7 +321,7 @@ function BoardPageContent() { | |
| <div className="bg-container-neutral-alternative flex h-12 items-center gap-200 rounded-md p-300"> | ||
| <Icon src={InfoCircleIcon} size={20} className="text-icon-alternative" /> | ||
| <p className="typo-body2 text-text-alternative min-w-0 flex-1"> | ||
| 추가 게시판은 최대 {MAX_CUSTOM_BOARDS}개입니다. | ||
| 게시판 추가는 최대 {MAX_CUSTOM_BOARDS}개까지 가능 합니다. | ||
|
Comment on lines
323
to
+324
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. 안내 문구 띄어쓰기를 다듬어 주세요.
🤖 Prompt for AI Agents |
||
| </p> | ||
| </div> | ||
| </div> | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.