-
Notifications
You must be signed in to change notification settings - Fork 8
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/party room admin 페이지 구현 #1247 #1330
Merged
The head ref may contain hidden characters: "feat/party-room-admin-\uD398\uC774\uC9C0-\uAD6C\uD604-#1247"
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ffdc00a
[Feat] PartyRoom 관리 Admin 페이지
izone00 d3bca56
[Feat] Admin 파티룸 수정 모달
izone00 2eae34f
[Fix] PartyRoomList hook 일반유저와 Admin유저 분리
izone00 8611ce6
[Fix] PartyRoomAdmin categoryId -> catogoryName 변경
izone00 61b97a2
[Feat] AdminPartyRoom 공통css 반영 및 페이지네이션
izone00 153022e
[Feat] PartyRoomEdit 모달 마감,작성일 추가 및 줄바꿈 반영
izone00 4d31956
[Fix] roomStatus 옵션에 FAIL 추가
izone00 2317dbb
Merge branch '6th_party' into feat/party-room-admin-페이지-구현-#1247
izone00 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,104 @@ | ||
import { useState } from 'react'; | ||
import { useSetRecoilState } from 'recoil'; | ||
import { | ||
Paper, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableContainer, | ||
TableRow, | ||
} from '@mui/material'; | ||
import { PartyRoomColumn } from 'types/admin/adminPartyTypes'; | ||
import { dateToStringShort } from 'utils/handleTime'; | ||
import { modalState } from 'utils/recoil/modal'; | ||
import { tableFormat } from 'constants/admin/table'; | ||
import AdminSearchBar from 'components/admin/common/AdminSearchBar'; | ||
import { AdminTableHead } from 'components/admin/common/AdminTable'; | ||
import PageNation from 'components/Pagination'; | ||
import useAdminPartyRoomList from 'hooks/party/useAdminPartyRoomList'; | ||
import styles from 'styles/admin/party/AdminPartyCommon.module.scss'; | ||
|
||
const tableTitle: { [key: string]: string } = { | ||
roomId: 'ID', | ||
title: '제목', | ||
categoryName: '카테고리', | ||
createDate: '생성일', | ||
dueDate: '마감일', | ||
creatorIntraId: '작성자', | ||
roomStatus: '상태', // 숨김 보이기 표시 | ||
etc: '기타', | ||
}; | ||
|
||
export default function PartyRoomTable() { | ||
const setModal = useSetRecoilState(modalState); | ||
const [currentPage, setCurrentPage] = useState(1); | ||
const { partyRooms, totalPages } = useAdminPartyRoomList({ | ||
page: currentPage, | ||
}); | ||
// const [searchKeyword, setSearchKeyword] = useState(''); | ||
|
||
const rooms: PartyRoomColumn[] = partyRooms.map((room) => ({ | ||
roomId: room.roomId, | ||
title: room.title, | ||
categoryName: room.categoryName, | ||
createDate: dateToStringShort(new Date(room.createDate)), | ||
dueDate: dateToStringShort(new Date(room.dueDate)), | ||
creatorIntraId: room.creatorIntraId ?? '', | ||
roomStatus: room.status, | ||
})); | ||
|
||
return ( | ||
<div className={styles.AdminTableWrap}> | ||
<div className={styles.header}> | ||
<span className={styles.title}>파티방 관리</span> | ||
{/* <AdminSearchBar | ||
initSearch={(keyword) => { | ||
setSearchKeyword(keyword ?? ''); | ||
// updateRoomsByTitle(searchKeyword); | ||
}} | ||
/> */} | ||
</div> | ||
<TableContainer component={Paper} className={styles.tableContainer}> | ||
<Table aria-label='partyRoomTable' className={styles.table}> | ||
<AdminTableHead tableName={'partyRoom'} table={tableTitle} /> | ||
<TableBody className={styles.tableBody}> | ||
{rooms.map((room) => ( | ||
<TableRow key={room.roomId}> | ||
{tableFormat['partyRoom'].columns.map((columnName) => ( | ||
<TableCell key={columnName} className={styles.tableBodyItem}> | ||
{columnName !== 'etc' ? ( | ||
<div> | ||
{room[columnName as keyof PartyRoomColumn] ?? '없음'} | ||
</div> | ||
) : ( | ||
<button | ||
onClick={() => { | ||
setModal({ | ||
modalName: 'ADMIN-PARTY_EDIT', | ||
roomId: room.roomId, | ||
}); | ||
}} | ||
className={`${styles.button_1} ${styles.edit}`} | ||
> | ||
자세히 | ||
</button> | ||
)} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
<div className={styles.pageNationContainer}> | ||
<PageNation | ||
curPage={currentPage} | ||
totalPages={totalPages} | ||
pageChangeHandler={(pageNumber: number) => { | ||
setCurrentPage(pageNumber); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
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,136 @@ | ||
import Image from 'next/image'; | ||
import { ChangeEvent, useEffect, useState } from 'react'; | ||
import { useSetRecoilState } from 'recoil'; | ||
import { Switch } from '@mui/material'; | ||
import { | ||
PartyComment, | ||
PartyRoomDetail, | ||
PartyRoomStatus, | ||
} from 'types/partyTypes'; | ||
import { instanceInPartyManage } from 'utils/axios'; | ||
import { dateToStringShort } from 'utils/handleTime'; | ||
import { toastState } from 'utils/recoil/toast'; | ||
import styles from 'styles/admin/party/PartyRoomEdit.module.scss'; | ||
|
||
const roomStatusOpts: PartyRoomStatus[] = ['OPEN', 'START', 'FINISH', 'HIDDEN']; | ||
contemplation-person marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default function PartyRoomEditModal({ roomId }: { roomId: number }) { | ||
const setSnackBar = useSetRecoilState(toastState); | ||
const [room, setRoom] = useState<PartyRoomDetail>(); | ||
|
||
function handleStatus(e: ChangeEvent<HTMLSelectElement>) { | ||
setRoom({ | ||
...(room as PartyRoomDetail), | ||
status: e.target.value as PartyRoomStatus, | ||
}); | ||
} | ||
function handleCommentHidden(comment: PartyComment) { | ||
instanceInPartyManage | ||
.patch(`/comments/${comment.commentId}`, { | ||
isHidden: !comment.isHidden, | ||
}) | ||
.then(() => { | ||
setRoom({ | ||
...room!, | ||
comments: room!.comments.map((c) => | ||
c.commentId === comment.commentId | ||
? { ...c, isHidden: !comment.isHidden } | ||
: c | ||
), | ||
}); | ||
}) | ||
.catch(() => { | ||
setSnackBar({ | ||
toastName: 'PATCH request', | ||
message: '코멘트를 수정할 수 없습니다', | ||
severity: 'error', | ||
clicked: true, | ||
}); | ||
}); | ||
} | ||
|
||
useEffect(() => { | ||
instanceInPartyManage | ||
.get(`/rooms/${roomId}`) | ||
.then(({ data }: { data: PartyRoomDetail }) => { | ||
setRoom(data); | ||
}); | ||
}, []); | ||
|
||
if (!room) return null; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<header className={styles.roomHeader}> | ||
<h2> | ||
<span className={styles.categoryName}>#{room.categoryName}</span> | ||
{room.title} | ||
</h2> | ||
<select onChange={handleStatus}> | ||
{roomStatusOpts.map((opt) => ( | ||
<option key={opt} value={opt}> | ||
{opt} | ||
</option> | ||
))} | ||
</select> | ||
</header> | ||
<section className={styles.roomDate}> | ||
<div>작성일: {dateToStringShort(new Date(room.createDate))}</div> | ||
<div>마감일: {dateToStringShort(new Date(room.dueDate))}</div> | ||
</section> | ||
<section className={styles.roomContent}> | ||
<p>{room.content}</p> | ||
</section> | ||
<section className={styles.roomUsers}> | ||
<h3> | ||
현재 {room.roomUsers.length} | 모집인원{' '} | ||
{`${room.minPeople} - ${room.maxPeople}`} | ||
</h3> | ||
<ul> | ||
{room.roomUsers.map((user) => ( | ||
<li key={user.roomUserId}> | ||
<div className={styles.userImage}> | ||
<Image | ||
src={user.userImage ?? ''} | ||
objectFit='cover' | ||
fill | ||
alt='13' | ||
/> | ||
</div> | ||
<div>{user.nickname}</div> | ||
<div>({user.intraId})</div> | ||
</li> | ||
))} | ||
</ul> | ||
</section> | ||
<section className={styles.roomComments}> | ||
<h3>코멘트</h3> | ||
<ul> | ||
{room.comments.map((comment) => ( | ||
<li key={comment.commentId}> | ||
<header> | ||
<div> | ||
<span className={styles.commentUserName}> | ||
{comment.nickname} | ||
</span> | ||
<span className={styles.commentDate}> | ||
{dateToStringShort(new Date(comment.createDate))} | ||
</span> | ||
</div> | ||
<div> | ||
{comment.isHidden ? '숨겨짐' : ''} | ||
<Switch | ||
checked={comment.isHidden} | ||
onChange={() => handleCommentHidden(comment)} | ||
inputProps={{ 'aria-label': 'hidden switch' }} | ||
/> | ||
</div> | ||
</header> | ||
<p>{comment.content}</p> | ||
</li> | ||
))} | ||
</ul> | ||
</section> | ||
</div> | ||
); | ||
} |
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,38 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { PartyRoom } from 'types/partyTypes'; | ||
import { instanceInPartyManage } from 'utils/axios'; | ||
|
||
type PartyRoomListProps = { | ||
searchTitle?: string; | ||
page: number; | ||
}; | ||
type RoomListResponse = { | ||
adminRoomList: PartyRoom[]; | ||
totalPages: number; | ||
}; | ||
|
||
export default function useAdminPartyRoomList( | ||
{ searchTitle, page }: PartyRoomListProps = { page: 1 } | ||
) { | ||
const [partyRooms, setPartyRooms] = useState<PartyRoom[]>([]); | ||
const [totalPages, setTotalPages] = useState(1); | ||
|
||
const getRoomsAxios = (title?: string) => { | ||
const titleQuery = title ? `&title=${title}` : ''; | ||
return instanceInPartyManage.get<RoomListResponse>( | ||
`/rooms?page=${page}&size=10${titleQuery}` | ||
); | ||
}; | ||
|
||
useEffect(() => { | ||
getRoomsAxios().then(({ data }) => { | ||
setPartyRooms(data.adminRoomList); | ||
setTotalPages(data.totalPages); | ||
}); | ||
}, [searchTitle, page]); | ||
|
||
return { | ||
partyRooms, | ||
totalPages, | ||
}; | ||
} |
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 was deleted.
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.
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.
???