-
Notifications
You must be signed in to change notification settings - Fork 3
♻️ Refactor: my-review의 탭 동작 수정 #144
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 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'use client'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useRouter } from 'next/navigation'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Divider } from '@mantine/core'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Tabs from '@/src/components/common/tab'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default function ReviewTabs() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const myPageTabs = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { label: '작성 가능한 리뷰', id: 'available-review', route: '/my-page/reviewable' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { label: '작성한 리뷰', id: 'my-review', route: '/my-page/my-review' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [currentTab, setCurrentTab] = useState(myPageTabs[0].id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const router = useRouter(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleTabClick = (id: string) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setCurrentTab(id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const selectedTab = myPageTabs.find((tab) => tab.id === id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (selectedTab?.route) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| router.push(selectedTab.route); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: reviewData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref: reviewRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isFetchingNextPage: isFetchingReviewNextPage, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } = useInfiniteScroll<ReviewInformResponse>({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryKey: ['review'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryFn: ({ pageParam = 0 }) => fetchMyReviewData(pageParam, 3), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getNextPageParam: (lastPage, allPages) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lastPage.hasNextPage ? allPages.length + 1 : undefined, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: gatheringData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ref: gatheringRef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isFetchingNextPage: isFetchingGatheringNextPage, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } = useInfiniteScroll<ReviewableGatheringCardInformResponse>({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryKey: ['crew'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryFn: ({ pageParam = 0 }) => getReviewableGatherings(pageParam), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getNextPageParam: (lastPage, allPages) => (lastPage.hasNext ? allPages.length + 1 : undefined), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="mt-12 flex flex-col"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h3 className="text-2xl font-semibold text-gray-900">나의 리뷰 모아보기</h3> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Divider mt={16} mb={24} size={2} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex justify-start"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Tabs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant="review" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tabs={myPageTabs} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activeTab={currentTab} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onTabClick={handleTabClick} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+63
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. 🛠️ Refactor suggestion 접근성 개선을 위한 aria 속성 추가가 필요합니다. 스크린 리더 사용자를 위해 탭 컴포넌트에 적절한 aria 레이블을 추가하면 좋겠습니다. <div className="mt-12 flex flex-col">
- <h3 className="text-2xl font-semibold text-gray-900">나의 리뷰 모아보기</h3>
+ <h3 className="text-2xl font-semibold text-gray-900" id="review-section-title">나의 리뷰 모아보기</h3>
<Divider mt={16} mb={24} size={2} />
- <div className="flex justify-start">
+ <div className="flex justify-start" role="tablist" aria-labelledby="review-section-title">
<Tabs
variant="review"
tabs={myPageTabs}
activeTab={currentTab}
onTabClick={handleTabClick}
+ aria-label="리뷰 탭 네비게이션"
/>
</div>
</div>📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import ProfileCardContainer from '@/src/app/(crew)/my-page/_components/profile-card/container'; | ||
| import ReviewTabs from './_components/review-tabs'; | ||
|
|
||
| export default function MyPage() { | ||
| return ( | ||
| <div className="container mx-auto my-0 min-h-screen max-w-pc bg-gray-50 px-3 py-11 md:px-8 lg:px-11"> | ||
| <div className="lg:gap-4.5 flex flex-col gap-3 md:gap-4"> | ||
| <ProfileCardContainer /> | ||
| </div> | ||
| <ReviewTabs /> | ||
| <div /> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function MyReviewPage() { | ||
| return <div>my review list component</div>; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,7 @@ | ||
| import ProfileCardContainer from '@/src/app/(crew)/my-page/_components/profile-card/container'; | ||
| import ReviewSection from '@/src/app/(crew)/my-page/_components/review-section'; | ||
| 'use client'; | ||
|
|
||
| import { redirect } from 'next/navigation'; | ||
|
|
||
| export default function MyPage() { | ||
| return ( | ||
| <div className="container mx-auto my-0 min-h-screen max-w-pc bg-gray-50 px-3 py-11 md:px-8 lg:px-11"> | ||
| <div className="lg:gap-4.5 flex flex-col gap-3 md:gap-4"> | ||
| <ProfileCardContainer /> | ||
| </div> | ||
| <ReviewSection /> | ||
| <div /> | ||
| </div> | ||
| ); | ||
| redirect('/my-page/reviewable'); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function ReviewableGatheringsPage() { | ||
| return <div>reviewable gathering list component</div>; | ||
| } |
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.
🛠️ Refactor suggestion
라우팅 에러 처리를 추가하는 것이 좋겠습니다.
현재 라우팅 실패에 대한 에러 처리가 없습니다. 사용자 경험 향상을 위해 에러 처리를 추가하는 것을 추천드립니다.
const handleTabClick = (id: string) => { setCurrentTab(id); const selectedTab = myPageTabs.find((tab) => tab.id === id); if (selectedTab?.route) { - router.push(selectedTab.route); + try { + router.push(selectedTab.route); + } catch (error) { + console.error('탭 이동 중 오류가 발생했습니다:', error); + // TODO: 사용자에게 에러 알림 표시 + } } };