-
Notifications
You must be signed in to change notification settings - Fork 3
Feat/159/crew review #166
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
Feat/159/crew review #166
Changes from all commits
e99d7bf
50f2d61
16d4832
4d15e01
fbf8570
df2b9de
0dee256
2591599
bf23591
8d67fd4
1997e3c
182af6e
8f3cdfb
13c4578
3abd5bd
e68cfd2
c54256d
9e130dc
2d28f3d
59f5c64
f61383f
0945503
6513988
0ebb139
735f463
6de0938
c97c7bf
5a89fe7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { fetchApi } from '@/src/utils/api'; | ||
| import { CrewReviewResponse } from '@/src/types/review'; | ||
|
|
||
| // ํฌ๋ฃจ ๋ฆฌ๋ทฐ ์กฐํ | ||
| export async function getCrewReviews(crewId: number, page: number): Promise<CrewReviewResponse> { | ||
| const url = `/api/review/${crewId}?page=${page}&size=5`; | ||
|
|
||
| const response = await fetchApi<{ data: CrewReviewResponse }>(url, { | ||
| method: 'GET', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
|
|
||
| return response.data; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import { getCrewReviews } from '@/src/_apis/crew/crew-review-apis'; | ||
|
|
||
| export function useGetCrewReviewsQuery(crewId: number, page: number) { | ||
| return useQuery({ | ||
| queryKey: ['crewReviews', crewId, page], | ||
| queryFn: () => getCrewReviews(crewId, page - 1), | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import React from 'react'; | ||
| import { Pagination } from '@mantine/core'; | ||
| import { cn } from '@/src/utils/cn'; | ||
| import ReviewCard from '@/src/components/common/review-list/review-card'; | ||
| import { CrewReview } from '@/src/types/review'; | ||
|
|
||
|
|
@@ -21,7 +22,7 @@ export default function CrewReviewList({ | |
| return ( | ||
| <div className="flex flex-col justify-between p-6"> | ||
| <div className="mb-6 grid flex-grow gap-4"> | ||
| {/* {reviews.map((review) => ( | ||
| {reviews.map((review) => ( | ||
| <ReviewCard | ||
| key={review.id} | ||
| rate={review.rate} | ||
|
|
@@ -30,30 +31,27 @@ export default function CrewReviewList({ | |
| crewId={review.crewId} | ||
| reviewer={review.reviewer} | ||
| /> | ||
| ))} */} | ||
| ))} | ||
| </div> | ||
| <div className="mt-6 flex justify-center"> | ||
| <Pagination | ||
| total={totalPages} | ||
| value={currentPage} | ||
| onChange={onPageChange} | ||
| classNames={{ | ||
| control: cn( | ||
| 'data-[active="true"]:text-blue-500 data-[active="true"]:font-bold', | ||
| 'border-none bg-transparent hover:bg-transparent', | ||
| ), | ||
| }} | ||
|
Comment on lines
+41
to
+46
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 ํ์ด์ง๋ค์ด์ ์ปดํฌ๋ํธ์ ์ ๊ทผ์ฑ ๊ฐ์ ์ด ํ์ํฉ๋๋ค. ํ์ฌ ์คํ์ผ๋ง์ ๊น๋ํ๊ฒ ๊ตฌํ๋์์ง๋ง, ์ ๊ทผ์ฑ ์ธก๋ฉด์์ ๊ฐ์ ์ด ํ์ํฉ๋๋ค. ๋ค์๊ณผ ๊ฐ์ ์ ๊ทผ์ฑ ๊ฐ์ ์ฌํญ์ ์ถ๊ฐํด๋ณด์ธ์: classNames={{
control: cn(
'data-[active="true"]:text-blue-500 data-[active="true"]:font-bold',
- 'border-none bg-transparent hover:bg-transparent',
+ 'border-none bg-transparent hover:bg-transparent focus:ring-2 focus:ring-blue-500',
+ 'aria-label="ํ์ด์ง ์ด๋" role="button"',
),
}}์ถ๊ฐ๋ก ๋ค์ ์์ฑ๋ค๋ Pagination ์ปดํฌ๋ํธ์ ์ถ๊ฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค: <Pagination
total={totalPages}
value={currentPage}
onChange={onPageChange}
+ aria-label="ํ์ด์ง ๋ค๋น๊ฒ์ด์
"
+ getItemAriaLabel={(page) => `${page}ํ์ด์ง๋ก ์ด๋`}
classNames={{
|
||
| styles={{ | ||
| control: { | ||
| border: 'none', | ||
| backgroundColor: 'transparent', | ||
| '&[data-active]': { | ||
| backgroundColor: 'transparent', | ||
| fontWeight: 'var(--pagination-active-font-weight)', | ||
| color: 'var(--pagination-active-color)', | ||
| boxShadow: 'none', | ||
| }, | ||
| '&:hover': { | ||
| backgroundColor: 'transparent', | ||
| }, | ||
| }, | ||
| root: { | ||
| '--pagination-active-color': '#3388FF', | ||
| '--pagination-active-font-weight': 'bold', | ||
| }, | ||
| }} | ||
| size="sm" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,11 @@ export default function DetailCrew({ id }: DetailCrewContainerProps) { | |
| await refetch(); | ||
| } catch (joinError) { | ||
| if (joinError instanceof ApiError) { | ||
| toast.error(joinError.message); | ||
| if (joinError.status === 401) { | ||
| router.push(`/login?redirect=${encodeURIComponent(window.location.pathname)}`); | ||
| } else { | ||
| toast.error(joinError.message); | ||
| } | ||
|
Comment on lines
+65
to
+69
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. ๐ก Codebase verification 401 ์๋ฌ ์ฒ๋ฆฌ๊ฐ ์ผ๊ด๋์ง ์์ ๋ถ๋ถ์ด ๋ฐ๊ฒฌ๋์์ต๋๋ค.
๐ Analysis chain401 ์๋ฌ ์ฒ๋ฆฌ ๋ก์ง์ด ์ ์ ํ๊ฒ ๊ตฌํ๋์์ต๋๋ค. ์ธ์ฆ๋์ง ์์ ์ฌ์ฉ์์ ํฌ๋ฃจ ์ฐธ์ฌ ์๋๋ฅผ ์ ์ ํ๊ฒ ์ฒ๋ฆฌํ๊ณ ์์ต๋๋ค. ๋ก๊ทธ์ธ ํ ์๋ ํ์ด์ง๋ก ๋์์ฌ ์ ์๋๋ก ๋ค๋ง, ๋ค์ ์ฌํญ์ ํ์ธํด ์ฃผ์๋ฉด ์ข๊ฒ ์ต๋๋ค:
์๋ ์คํฌ๋ฆฝํธ๋ก ๋ค๋ฅธ API ํธ์ถ์ 401 ์๋ฌ ์ฒ๋ฆฌ ์ฌ๋ถ๋ฅผ ํ์ธํด๋ณด๊ฒ ์ต๋๋ค: ๐ Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check if other API calls handle 401 errors consistently
# Search for API call implementations
ast-grep --pattern 'catch (${_}Error) {
if (${_}Error instanceof ApiError) {
if (${_}Error.status === 401) {
$$$
}
}
}'
Length of output: 139 Script: #!/bin/bash
# Search for handleLeaveCrew and handleConfirmCancel functions
ast-grep --pattern 'async function handleLeaveCrew() {
$$$
}'
ast-grep --pattern 'async function handleConfirmCancel() {
$$$
}'
# Also search for any error handling patterns in these functions
rg "handleLeaveCrew|handleConfirmCancel" -A 10 -B 10
Length of output: 14725 |
||
| } else { | ||
| toast.error('๐ซ ํฌ๋ฃจ ์ฐธ์ฌ ์ค ์๋ฌ๊ฐ ๋ฐ์ํ์ต๋๋ค.'); | ||
| } | ||
|
|
||
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
์ฟผ๋ฆฌ ์ค์ ์ ๊ฐ์ ํด์ฃผ์ธ์.
ํ์ฌ ๊ตฌํ์์ ๋ช ๊ฐ์ง ๊ฐ์ ์ด ํ์ํฉ๋๋ค:
page - 1๋ณํ์ ๋ํ ์ฃผ์ ์ค๋ช ์ด ํ์ํฉ๋๋ค๋ค์๊ณผ ๊ฐ์ด ๊ฐ์ ํด๋ณด์ธ์:
export function useGetCrewReviewsQuery(crewId: number, page: number) { return useQuery({ queryKey: ['crewReviews', crewId, page], - queryFn: () => getCrewReviews(crewId, page - 1), + queryFn: () => getCrewReviews(crewId, page - 1), // API๋ 0-based ํ์ด์ง๋ค์ด์ ์ ์ฌ์ฉ + staleTime: 5 * 60 * 1000, // 5๋ถ + retry: 1, + onError: (error) => { + console.error('ํฌ๋ฃจ ๋ฆฌ๋ทฐ๋ฅผ ๋ถ๋ฌ์ค๋๋ฐ ์คํจํ์ต๋๋ค:', error); + }, }); }๐ Committable suggestion