-
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 연동 (#311)
* 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 : 스토리북 수정 --------- Co-authored-by: 남정욱 <[email protected]>
- Loading branch information
Showing
8 changed files
with
126 additions
and
28 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
24 changes: 10 additions & 14 deletions
24
src/components/LetterDetailPage/Delete/DeleteModal.stories.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { DeleteModal } from './DeleteModal'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
|
||
const meta: Meta<typeof DeleteModal> = { | ||
component: DeleteModal, | ||
title: 'molecule/DeleteModal', | ||
tags: ['autodocs'], | ||
argTypes: { | ||
id: { | ||
control: 'text', | ||
description: '삭제할 편지 ID.', | ||
defaultValue: '1234' | ||
}, | ||
closeModal: { | ||
action: 'closeModal', | ||
description: '모달 닫기 이벤트 핸들러' | ||
} | ||
} | ||
argTypes: {}, | ||
decorators: [ | ||
(Story) => ( | ||
<MemoryRouter> | ||
<Story /> | ||
</MemoryRouter> | ||
) | ||
] | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof DeleteModal>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
id: '1234' | ||
} | ||
args: {} | ||
}; |
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,29 @@ | ||
import { useMutation, UseMutationOptions } from '@tanstack/react-query'; | ||
import { deleteKeywordLetterReplyKeywordLetter } from '@/service/detail/deleteKeywordLetterReplyKeywordLetter'; | ||
|
||
type UseDeleteKeywordLetterReplyKeywordLetterProps = { | ||
letterId: number; | ||
letterType: string; | ||
boxType: string; | ||
}; | ||
|
||
export const useDeleteKeywordLetterReplyKeywordLetter = ( | ||
{ | ||
letterId, | ||
letterType, | ||
boxType | ||
}: UseDeleteKeywordLetterReplyKeywordLetterProps, | ||
options?: UseMutationOptions<string, Error, void> | ||
) => { | ||
return useMutation<string, Error, void>({ | ||
mutationFn: async () => { | ||
const response = await deleteKeywordLetterReplyKeywordLetter({ | ||
letterId, | ||
letterType, | ||
boxType | ||
}); | ||
return response.result; | ||
}, | ||
...options | ||
}); | ||
}; |
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
31 changes: 31 additions & 0 deletions
31
src/service/detail/deleteKeywordLetterReplyKeywordLetter.ts
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 { defaultApi } from '@/service/api'; | ||
import { ApiResponseType } from '@/types/apiResponse'; | ||
|
||
type deleteKeywordLettersRequestProps = { | ||
letterId: number; | ||
letterType: string; | ||
boxType: string; | ||
}; | ||
|
||
type deleteKeywordLettersResponse = ApiResponseType<string>; | ||
|
||
export async function deleteKeywordLetterReplyKeywordLetter({ | ||
letterId, | ||
letterType, | ||
boxType | ||
}: deleteKeywordLettersRequestProps): Promise<deleteKeywordLettersResponse> { | ||
const api = defaultApi(); | ||
|
||
const response = await api.delete<deleteKeywordLettersResponse>( | ||
'/letters', | ||
{ | ||
data: { | ||
letterId, | ||
letterType, | ||
boxType | ||
} | ||
} | ||
); | ||
|
||
return response.data; | ||
} |