-
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 : 키워드 편지 상세 조회 답장 리스트 api 연동 (#315)
* chore : daycounter 로직 수정 * refactor : 폴더 및 로직 수정 * feat : 컨테이너 및 상세 개발 * story : 스토리 삭제 * feat : 라우팅 설정 * feat : api 호출 로직 작성 * chore : 폴더 경로 수정 * chore : UseNearbyLettersDetailProps 타입 변경 * story : 바뀐 유틸에 맞게 스토리 수정 * chore: simple layout 수정 * style : 전역 스타일 수정 * chore : ; 제거 및 안 쓰는 import 제거 * chore : url 수정 * chore : url 수정으로 인한 변경 * feat : 키워드 편지 상세 조회 삭제 기능 api 연동 * feat : id props 삭제 및 api 연동 * chore : 스토리북 수정 * chore : 키워드 편지 상세 조회 답장 리스트 타입 지정 * feat : 키워드 편지 상세 조회 답장 리스트 api 연동 * feat : 키워드 편지 상세 조회 답장 리스트 데이터 바인딩 --------- Co-authored-by: 남정욱 <[email protected]>
- Loading branch information
Showing
6 changed files
with
129 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,38 @@ | ||
import { NavLink } from 'react-router-dom'; | ||
import { KeywordReplyListResponseType } from '@/types/letter'; | ||
import { formatDate } from '@/util/formatDate'; | ||
import { NavLink, useLocation } from 'react-router-dom'; | ||
|
||
type ReplyListProps = { | ||
replies: { | ||
id: number; | ||
title: string; | ||
date: string; | ||
}[]; | ||
keywordReplyListData: KeywordReplyListResponseType['content']; | ||
}; | ||
|
||
export const ReplyList = ({ replies }: ReplyListProps) => { | ||
export const ReplyList = ({ keywordReplyListData }: ReplyListProps) => { | ||
const location = useLocation(); | ||
const basePath = location.pathname.split('/')[2]; | ||
|
||
return ( | ||
<NavLink | ||
to="/letter/reply/:id" | ||
className="bg-gray-300 rounded-2xl w-auto" | ||
> | ||
{replies.map((reply, index) => ( | ||
<div | ||
key={reply.id} | ||
<div className="bg-gray-300 rounded-2xl w-auto"> | ||
{keywordReplyListData.map((reply, index) => ( | ||
<NavLink | ||
key={reply.replyLetterId} | ||
to={`/letter/${basePath}/reply/${reply.replyLetterId}`} | ||
className={`flex items-center cursor-pointer h-1 p-6 ${ | ||
index < replies.length - 1 | ||
index < keywordReplyListData.length - 1 | ||
? 'border-b border-l-neutral-300' | ||
: '' | ||
}`} | ||
> | ||
<div | ||
className={`flex items-center justify-between w-full hover:opacity-70 `} | ||
> | ||
<div className="flex items-center justify-between w-full hover:opacity-70"> | ||
<span className="font-bold w-44 truncate mr-4"> | ||
Re: {reply.title} | ||
{reply.title} | ||
</span> | ||
<span className="text-sm truncate flex-1 text-gray-600"> | ||
{reply.date} | ||
{formatDate(reply.createdAt)} | ||
</span> | ||
<div className="text-2xl">{'>'}</div> | ||
</div> | ||
</div> | ||
</NavLink> | ||
))} | ||
</NavLink> | ||
</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,31 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { getKeywordReplyList } from '@/service/keyword/getKeywordReplyList'; | ||
import { KeywordReplyListResponseType } from '@/types/letter'; | ||
|
||
type KeywordReplyListRequestProps = { | ||
letterId: number; | ||
page: number; | ||
size: number; | ||
sort: string; | ||
}; | ||
|
||
export const useGetKeywordReplyList = ({ | ||
letterId, | ||
page, | ||
size, | ||
sort | ||
}: KeywordReplyListRequestProps) => { | ||
return useQuery<KeywordReplyListResponseType, Error>({ | ||
queryKey: ['getKeywordReplyLists', letterId, page, size, sort], | ||
queryFn: async () => { | ||
const response = await getKeywordReplyList({ | ||
letterId, | ||
page, | ||
size, | ||
sort | ||
}); | ||
return response.result; | ||
}, | ||
enabled: !!letterId | ||
}); | ||
}; |
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,28 @@ | ||
import { defaultApi } from '@/service/api'; | ||
import { ApiResponseType } from '@/types/apiResponse'; | ||
import { KeywordReplyListResponseType } from '@/types/letter'; | ||
|
||
type KeywordReplyListRequestProps = { | ||
letterId: number; | ||
page: number; | ||
size: number; | ||
sort: string; | ||
}; | ||
|
||
type KeywordReplyListResponse = ApiResponseType<KeywordReplyListResponseType>; | ||
|
||
export async function getKeywordReplyList({ | ||
letterId, | ||
page, | ||
size, | ||
sort | ||
}: KeywordReplyListRequestProps): Promise<KeywordReplyListResponse> { | ||
const api = defaultApi(); | ||
const response = await api.get<KeywordReplyListResponse>( | ||
`/letters/replies/${letterId}`, | ||
{ | ||
params: { page, size, sort } | ||
} | ||
); | ||
return response.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