-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 롤링페이퍼 배포된 api로 연결 수정 #85
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e751d3b
style:롤링페이퍼 공지 애니메이션 수정
AAminha 663830f
fix: 롤링페이퍼가 진행되지 않을 때 화면에 보여지지 않도록 처리
AAminha 323703d
Merge branch 'develop' of https://github.com/prgrms-web-devcourse-fin…
AAminha 7020e71
feat: 새로운 롤링페이퍼 생성 api 연동
AAminha 92adecd
feat: 롤링페이퍼 목록 조회 api 연동
AAminha dfea402
feat: 롤링페이퍼 삭제 api 연동
AAminha 00d4526
feat: 롤링페이퍼 사용여부 변경 api 연동
AAminha 383a97c
feat: 롤링페이퍼 코멘트 목록 조회 api 연동
AAminha 4df7236
feat: 롤링페이퍼 등록 및 삭제 api 연동
AAminha 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,76 @@ | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
| import { AxiosError } from 'axios'; | ||
|
|
||
| import { deleteRollingPaper, patchRollingPaper } from '@/apis/rolling'; | ||
| import { DeleteIcon } from '@/assets/icons'; | ||
|
|
||
| interface RollingPaperItemProps { | ||
| information: AdminRollingPaperInformation; | ||
| } | ||
|
|
||
| export default function RollingPaperItem({ information }: RollingPaperItemProps) { | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| const { mutate: deleteMutate } = useMutation({ | ||
| mutationFn: () => deleteRollingPaper(information.eventPostId), | ||
| onSuccess: () => { | ||
| // TODO: 페이지네이션 적용 후, 현재 page에 대한 캐싱 날리는 방식으로 변경 | ||
| queryClient.invalidateQueries({ queryKey: ['admin-rolling-paper'] }); | ||
| }, | ||
| onError: (err) => { | ||
| console.error(err); | ||
| }, | ||
| }); | ||
|
|
||
| const { mutate: toggleStatus } = useMutation({ | ||
| mutationFn: () => patchRollingPaper(information.eventPostId), | ||
| onSuccess: () => { | ||
| // TODO: 기존 데이터 수정하는 방식으로 ㄱㄱㄱㄱㄱㄱㄱ | ||
| // 일단 임시로 캐싱 날리기 | ||
| queryClient.invalidateQueries({ queryKey: ['admin-rolling-paper'] }); | ||
| }, | ||
| onError: (err: AxiosError<{ code: string; message: string }>) => { | ||
| if (err.response?.data.code === 'EVENT-004') { | ||
| alert(err.response.data.message); | ||
| } | ||
| console.error(err); | ||
| }, | ||
| }); | ||
|
|
||
| // TODO: 진짜 삭제하겠냐고 물어보기 | ||
| return ( | ||
| <tr className="border-gray-40 h-14 border-b"> | ||
| <td className="w-14 text-center">{information.eventPostId}</td> | ||
| <td className="text-left"> | ||
| <div> | ||
| {information.used && ( | ||
| <span className="mr-2 rounded-full border border-amber-500 bg-amber-100/70 px-3 py-0.5 whitespace-nowrap text-amber-500"> | ||
| 진행 중 | ||
| </span> | ||
| )} | ||
| {information.title} | ||
| </div> | ||
| </td> | ||
| <td className="text-center"> | ||
| <button | ||
| type="button" | ||
| className="hover:bg-gray-10 text-gray-60 rounded-md px-3 py-1 hover:text-black" | ||
| onClick={() => toggleStatus()} | ||
| > | ||
| {information.used ? '중단하기' : '진행하기'} | ||
| </button> | ||
| </td> | ||
| <td className="w-6"> | ||
| {!information.used && ( | ||
| <button | ||
| type="button" | ||
| className="text-gray-60 flex items-center justify-center p-1 hover:text-black" | ||
| onClick={() => deleteMutate()} | ||
| > | ||
| <DeleteIcon className="h-5 w-5" /> | ||
| </button> | ||
| )} | ||
| </td> | ||
| </tr> | ||
| ); | ||
| } |
This file contains hidden or 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
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.
오홍 data를 이런식으로 받아와서 타입을 지정하는 군요!