-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 롤링페이퍼 추가 기능 구현 #95
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
Changes from all commits
bf057d2
b7ffbac
c96daf0
903a08f
fd985fb
f04c391
e96a891
43cd00d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,19 +3,22 @@ import { AxiosError } from 'axios'; | |
|
|
||
| import { deleteRollingPaper, patchRollingPaper } from '@/apis/rolling'; | ||
| import { DeleteIcon } from '@/assets/icons'; | ||
| import { useState } from 'react'; | ||
| import ConfirmModal from '@/components/ConfirmModal'; | ||
|
|
||
| interface RollingPaperItemProps { | ||
| information: AdminRollingPaperInformation; | ||
| currentPage: string | number; | ||
| } | ||
|
Comment on lines
9
to
12
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. props 인터페이스는 컴포넌트 파일에 있는게 직관성이 좋아보이는데 그래도 나중에 d.ts폴더로 옮기는게 좋을까요?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. d.ts는 아무래도 인터페이스를 전역적으로 사용할 수 있는 특징이 있다보니 컴포넌트 내에서만 사용되는 props의 경우에는 굳이 d.ts로 옮기지는 않아도 된다고 생각했어요! 오히려 수정이나 구성을 확인할 때 파일 이동이 있어서 번거로울 것 같기도 하구요! |
||
|
|
||
| export default function RollingPaperItem({ information }: RollingPaperItemProps) { | ||
| export default function RollingPaperItem({ information, currentPage }: RollingPaperItemProps) { | ||
| const [activeDeleteModal, setActiveDeleteModal] = useState(false); | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| const { mutate: deleteMutate } = useMutation({ | ||
| mutationFn: () => deleteRollingPaper(information.eventPostId), | ||
| onSuccess: () => { | ||
| // TODO: 페이지네이션 적용 후, 현재 page에 대한 캐싱 날리는 방식으로 변경 | ||
| queryClient.invalidateQueries({ queryKey: ['admin-rolling-paper'] }); | ||
| queryClient.invalidateQueries({ queryKey: ['admin-rolling-paper', currentPage] }); | ||
| }, | ||
| onError: (err) => { | ||
| console.error(err); | ||
|
|
@@ -25,9 +28,7 @@ export default function RollingPaperItem({ information }: RollingPaperItemProps) | |
| const { mutate: toggleStatus } = useMutation({ | ||
| mutationFn: () => patchRollingPaper(information.eventPostId), | ||
| onSuccess: () => { | ||
| // TODO: 기존 데이터 수정하는 방식으로 ㄱㄱㄱㄱㄱㄱㄱ | ||
| // 일단 임시로 캐싱 날리기 | ||
| queryClient.invalidateQueries({ queryKey: ['admin-rolling-paper'] }); | ||
| queryClient.invalidateQueries({ queryKey: ['admin-rolling-paper', currentPage] }); | ||
| }, | ||
| onError: (err: AxiosError<{ code: string; message: string }>) => { | ||
| if (err.response?.data.code === 'EVENT-004') { | ||
|
|
@@ -37,40 +38,53 @@ export default function RollingPaperItem({ information }: RollingPaperItemProps) | |
| }, | ||
| }); | ||
|
|
||
| // 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 && ( | ||
| <> | ||
| {activeDeleteModal && ( | ||
| <ConfirmModal | ||
| title="정말 롤링페이퍼를 삭제하시겠어요?" | ||
| description="롤링페이퍼를 삭제하는 경우 복구가 불가능합니다!" | ||
| cancelText="되돌아가기" | ||
| confirmText="삭제하기" | ||
| onCancel={() => { | ||
| setActiveDeleteModal(false); | ||
| }} | ||
| onConfirm={deleteMutate} | ||
| /> | ||
| )} | ||
| <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="text-gray-60 flex items-center justify-center p-1 hover:text-black" | ||
| onClick={() => deleteMutate()} | ||
| className="hover:bg-gray-10 text-gray-60 rounded-md px-3 py-1 hover:text-black" | ||
| onClick={() => toggleStatus()} | ||
| > | ||
| <DeleteIcon className="h-5 w-5" /> | ||
| {information.used ? '중단하기' : '진행하기'} | ||
| </button> | ||
|
Comment on lines
68
to
74
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 지금 빼먹은게 산더미라서 할 말 없지만 aria-label 속성이었나? 그걸 넣어야 접근성이 좋아진다고 gpt랑 승연님이 알려주셨어용(저도 나중에 수정해야 할 거 같아요🥲)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 aria-label에 대해서 잘 몰라서 질문하고 싶어요..! button 내부의 텍스트가 충분히 의도를 설명한다고 생각했는데, aria-label이 추가적으로 더 필요한 이유가 있을까요?!
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aria-label을 설정하면 시각 장애인등의 이용자가 스크린 리더 기능을 사용해서 해당 버튼에 대한 설명을 음성으로 들을수 있다고 하네요! 실제로 써 본적이 없어서 크게 도움이 될까 싶긴 한데 그래도 웹접근성을 높이는 방법 중에 하나라고 하니.. 일단 넣어두면 나쁘지 않을거 같습니다!!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오홍.. 제가 알기로는 aria-label이 스크린 리더로 읽을 때 충분히 의미가 전달되지 않는 요소에 대해서 적절하게 라벨을 붙여주는 것이라고 이해하고 있었어요. 그래서 이미 태그에 내용이 충분하게 있음에도 aria-label이 필요할까 했었구요! 아래 글을 참고해봤어요!! |
||
| )} | ||
| </td> | ||
| </tr> | ||
| </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={() => setActiveDeleteModal(true)} | ||
| > | ||
|
Comment on lines
+78
to
+82
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aria-label |
||
| <DeleteIcon className="h-5 w-5" /> | ||
| </button> | ||
| )} | ||
| </td> | ||
| </tr> | ||
| </> | ||
| ); | ||
| } | ||
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.
페이지네이션 사용은 괜찮으신가요?? 문제점이나 개선사항 있다면 수정하겠습니다!!
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.
제가 사용할 땐 괜찮았어요!! 굳굳입니당~~~