-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] room을 동적 라우팅에서 쿼리문으로 라우팅 방식 변경
- Loading branch information
1 parent
be7c7af
commit 758616a
Showing
4 changed files
with
56 additions
and
3 deletions.
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
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,53 @@ | ||
import { useRouter } from 'next/router'; | ||
import { useEffect, useState } from 'react'; | ||
import { PartyRoomDetail } from 'types/partyTypes'; | ||
import { instance } from 'utils/axios'; | ||
import PartyDetailCommentBox from 'components/party/roomDetail/PartyDetailContentCommentBox'; | ||
import PartyDetailProfile from 'components/party/roomDetail/PartyDetailProfile'; | ||
import PartyDetailTitleBox from 'components/party/roomDetail/PartyDetailTitleBox'; | ||
import usePartyColorMode from 'hooks/party/usePartyColorMode'; | ||
import styles from 'styles/party/PartyDetailRoom.module.scss'; | ||
|
||
export default function PartyDetailPage() { | ||
const roomId = useRouter().query.id; | ||
const router = useRouter(); | ||
const [partyRoomDetail, setPartyRoomDetail] = useState< | ||
PartyRoomDetail | undefined | ||
>(undefined); | ||
|
||
useEffect(() => { | ||
fetchRoomDetail(); | ||
}, []); | ||
|
||
const fetchRoomDetail = () => { | ||
instance | ||
.get(`/party/rooms/${roomId}`) | ||
.then(({ data }) => { | ||
setPartyRoomDetail(data); | ||
}) | ||
.catch(() => { | ||
alert('방 정보를 불러오는데 실패했습니다.'); | ||
router.push('/party'); | ||
}); | ||
}; | ||
|
||
usePartyColorMode('PARTY-MAIN'); | ||
|
||
return partyRoomDetail && partyRoomDetail.status !== 'HIDDEN' ? ( | ||
<div className={styles.detailPage}> | ||
<PartyDetailTitleBox {...partyRoomDetail} /> | ||
<PartyDetailProfile | ||
partyRoomDetail={partyRoomDetail} | ||
fetchRoomDetail={fetchRoomDetail} | ||
/> | ||
<PartyDetailCommentBox | ||
partyRoomDetail={partyRoomDetail} | ||
fetchRoomDetail={fetchRoomDetail} | ||
/> | ||
</div> | ||
) : partyRoomDetail === undefined ? ( | ||
<div>loading...</div> | ||
) : ( | ||
<div>방이 존재하지 않습니다.</div> | ||
); | ||
} |