-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat/#86 : dm 타입 정리 * feat/#86 : 디엠 사이드바 목록 조회 * feat/#86 : dm 페이지 더미 데이터 추가 * feat/#86 : dm 페이지 모킹 API 연결
- Loading branch information
Showing
15 changed files
with
295 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
import { DMListResponseDto } from '@/apis/dm/dto'; | ||
import { DMListResponseDto, DMResponseDto } from '@/apis/dm/dto'; | ||
import https from '@/lib/https'; | ||
|
||
export const getDMList = async (): Promise<DMListResponseDto> => { | ||
const { data } = await https.get('/api/dms'); | ||
return data; | ||
}; | ||
|
||
export const getDMMessage = async (dmId: string): Promise<DMResponseDto> => { | ||
const { data } = await https.get(`api/dms/${dmId}`); | ||
return data; | ||
}; |
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,40 @@ | ||
import { useParams } from 'react-router'; | ||
import Message from '../common/Message'; | ||
import DMInfo from './DMInfo'; | ||
import { useGetDMMessages } from '@/hooks/dm/useGetDMMessages'; | ||
import DateBadge from '../common/DateBadge'; | ||
|
||
const DMContent = () => { | ||
const { dmId } = useParams(); | ||
const { data, isLoading, isError } = useGetDMMessages(dmId!); | ||
|
||
if (isLoading) return <p>로딩중입니다.</p>; | ||
if (isError) return <p>에러</p>; | ||
|
||
return ( | ||
<div> | ||
{data && data?.participants.length > 0 && ( | ||
<DMInfo {...data.participants[0]} /> | ||
)} | ||
{data?.messages ? ( | ||
Object.entries(data.messages).map(([date, messages]) => ( | ||
<div key={date}> | ||
<DateBadge date={date} /> | ||
{messages.map(msg => ( | ||
<Message | ||
key={msg.messageId} | ||
user={msg.user} | ||
content={msg.content} | ||
createdAt={msg.createdAt} | ||
/> | ||
))} | ||
</div> | ||
)) | ||
) : ( | ||
<p>메시지 없음</p> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default DMContent; |
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
34 changes: 8 additions & 26 deletions
34
frontend/src/components/workspace/WorkspaceChannelPanel/WorkspaceDirectMessageListItem.tsx
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,10 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { getDMMessage } from '@/apis/dm'; | ||
|
||
export const useGetDMMessages = (dmId: string) => { | ||
return useQuery({ | ||
queryKey: ['dmMessage', dmId], | ||
queryFn: () => getDMMessage(dmId), | ||
enabled: !!dmId, | ||
}); | ||
}; |
Oops, something went wrong.