-
Notifications
You must be signed in to change notification settings - Fork 0
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
π κ΄λ¦¬μ νλ‘ν λΆλ¬μ€κΈ° #89
Conversation
Walkthroughμ΄ PRμ κ΄λ¦¬μ κ΄λ ¨ APIμ UIμ κΈ°λ₯ νμ₯μ ν¬ν¨ν©λλ€. Changes
Sequence Diagram(s)sequenceDiagram
participant APW as AdminPageWrapper
participant UA as useAdminData Hook
participant GA as getAdminData
participant API as API Server (/admin/my)
APW ->> UA: useAdminData νΈμΆ
UA ->> GA: getAdminData νΈμΆ
GA ->> API: GET μμ² (ν ν° ν¬ν¨)
API -->> GA: μλ΅ (AdminData)
GA -->> UA: λ°μ΄ν° λ°ν
UA -->> APW: 쿼리 κ²°κ³Ό λ°ν
Possibly related PRs
Suggested reviewers
Poem
β¨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
π§Ή Nitpick comments (3)
src/app/api/admin/my/route.ts (1)
20-22
: μλ¬ λ©μμ§ κ°μ νμμλ¬ λ©μμ§κ° λ무 μΌλ°μ μ λλ€. λ ꡬ체μ μΈ μλ¬ λ©μμ§λ₯Ό μ 곡νλ©΄ λλ²κΉ μ λμμ΄ λ κ² κ°μ΅λλ€.
λ€μκ³Ό κ°μ΄ μμ νλ κ²μ μ μν©λλ€:
const message = - axiosError.response?.data?.message || 'admin data get failed'; + axiosError.response?.data?.message || 'κ΄λ¦¬μ μ 보λ₯Ό κ°μ Έμ€λ μ€ μ€λ₯κ° λ°μνμ΅λλ€.';src/widgets/admin/model/useAdminData.ts (1)
20-23
: μΊμ± μ€μ μΆκ° κΆμ₯κ΄λ¦¬μ λ°μ΄ν°μ νΉμ±μ κ³ λ €νμ¬ μ μ ν staleTimeκ³Ό cacheTimeμ μ€μ νλ©΄ μ’μ κ² κ°μ΅λλ€.
λ€μκ³Ό κ°μ΄ μμ νλ κ²μ μ μν©λλ€:
const requestAdminData = useQuery<AdminData, Error>({ queryKey: ['requestAdminData'], queryFn: getAdminData, + staleTime: 5 * 60 * 1000, // 5λΆ + cacheTime: 30 * 60 * 1000, // 30λΆ });src/entities/admin/ui/AdminProfile/index.tsx (1)
27-29
: λ°μ΄ν° λ°μΈλ©μ΄ μ¬λ°λ₯΄κ² ꡬνλμμ΅λλ€!
ProfileInfo
μ»΄ν¬λνΈλ₯Ό μ¬μ¬μ©νμ¬ κ΄λ¦¬μ μ 보λ₯Ό ν¨μ¨μ μΌλ‘ νμνκ³ μμ΅λλ€.λ€λ§, λ°μ΄ν°κ° μλ κ²½μ°μ λν μ²λ¦¬λ₯Ό μΆκ°νλ©΄ μ’μ κ² κ°μ΅λλ€.
- <ProfileInfo label="μ΄λ¦" value={data.name} /> - <ProfileInfo label="μμ΄λ" value={data.nickname} /> - <ProfileInfo label="μ΄λ©μΌ" value={data.email} /> + <ProfileInfo label="μ΄λ¦" value={data.name ?? '-'} /> + <ProfileInfo label="μμ΄λ" value={data.nickname ?? '-'} /> + <ProfileInfo label="μ΄λ©μΌ" value={data.email ?? '-'} />
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (6)
src/app/api/admin/my/route.ts
(1 hunks)src/entities/admin/ui/AdminProfile/index.tsx
(3 hunks)src/shared/types/admin/type.ts
(1 hunks)src/widgets/admin/api/getAdminData.ts
(2 hunks)src/widgets/admin/model/useAdminData.ts
(2 hunks)src/widgets/admin/ui/AdminPageWrapper/index.tsx
(2 hunks)
π Additional comments (4)
src/shared/types/admin/type.ts (1)
17-21
: μΈν°νμ΄μ€ κ΅¬μ‘°κ° μ μ μλμ΄ μμ΅λλ€!κ΄λ¦¬μ λ°μ΄ν°λ₯Ό μν μΈν°νμ΄μ€κ° λͺ ννκ³ κ°λ¨νκ² μ μλμ΄ μμ΅λλ€.
src/widgets/admin/ui/AdminPageWrapper/index.tsx (2)
14-15
: useAdminData ν μ λ°νκ°μ΄ μ¬λ°λ₯΄κ² ꡬ쑰λΆν΄λμμ΅λλ€!λ°μ΄ν°μ λ‘λ© μνλ₯Ό λͺ ννκ² λΆλ¦¬νμ¬ κ΄λ¦¬νκ³ μμ΅λλ€.
26-26
: μ‘°κ±΄λΆ λ λλ§μ΄ μ μ νκ² κ΅¬νλμμ΅λλ€!
requestAdmin
λ°μ΄ν°κ° μμ λλ§AdminProfile
μ»΄ν¬λνΈλ₯Ό λ λλ§νλ λ°©μμ΄ μμ ν©λλ€.Also applies to: 32-32
src/entities/admin/ui/AdminProfile/index.tsx (1)
3-3
: νμ μ μμ props κ΅¬μ‘°κ° μ ꡬνλμμ΅λλ€!
AdminData
νμ μ importνκ³ μ»΄ν¬λνΈμ propsλ‘ μ μ νκ² μ¬μ©νκ³ μμ΅λλ€.Also applies to: 14-14
export const getAdminData = async (): Promise<AdminData> => { | ||
const response = await axios.get('/api/admin/my'); | ||
return response.data; | ||
}; |
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
μλ¬ μ²λ¦¬ λ‘μ§ μΆκ° νμ
API νΈμΆ μ€ν¨ μμ μλ¬ μ²λ¦¬κ° λλ½λμ΄ μμ΅λλ€. try-catch λΈλ‘μ μΆκ°νμ¬ μλ¬λ₯Ό μ μ ν μ²λ¦¬ν΄ μ£ΌμΈμ.
λ€μκ³Ό κ°μ΄ μμ νλ κ²μ μ μν©λλ€:
export const getAdminData = async (): Promise<AdminData> => {
- const response = await axios.get('/api/admin/my');
- return response.data;
+ try {
+ const response = await axios.get('/api/admin/my');
+ return response.data;
+ } catch (error) {
+ console.error('κ΄λ¦¬μ λ°μ΄ν° μ‘°ν μ€ν¨:', error);
+ throw error;
+ }
};
π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
export const getAdminData = async (): Promise<AdminData> => { | |
const response = await axios.get('/api/admin/my'); | |
return response.data; | |
}; | |
export const getAdminData = async (): Promise<AdminData> => { | |
try { | |
const response = await axios.get('/api/admin/my'); | |
return response.data; | |
} catch (error) { | |
console.error('κ΄λ¦¬μ λ°μ΄ν° μ‘°ν μ€ν¨:', error); | |
throw error; | |
} | |
}; |
const cookieStore = cookies(); | ||
const accessToken = cookieStore.get('accessToken')?.value; | ||
|
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.
ν ν° μ ν¨μ± κ²μ¬ μΆκ° νμ
accessTokenμ΄ μλ κ²½μ°μ λν μ²λ¦¬κ° λλ½λμ΄ μμ΅λλ€.
λ€μκ³Ό κ°μ΄ μμ νλ κ²μ μ μν©λλ€:
const cookieStore = cookies();
const accessToken = cookieStore.get('accessToken')?.value;
+
+ if (!accessToken) {
+ return NextResponse.json(
+ { error: 'μΈμ¦ ν ν°μ΄ μμ΅λλ€.' },
+ { status: 401 }
+ );
+ }
π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const cookieStore = cookies(); | |
const accessToken = cookieStore.get('accessToken')?.value; | |
const cookieStore = cookies(); | |
const accessToken = cookieStore.get('accessToken')?.value; | |
if (!accessToken) { | |
return NextResponse.json( | |
{ error: 'μΈμ¦ ν ν°μ΄ μμ΅λλ€.' }, | |
{ status: 401 } | |
); | |
} |
@@ -13,7 +17,15 @@ export const useAdminData = () => { | |||
queryFn: getRequestSignUp, | |||
}); | |||
|
|||
const isLoading = expoListData.isLoading || requestSignUpData.isLoading; | |||
const requestAdminData = useQuery<AdminData, Error>({ | |||
queryKey: ['requestAdnubData'], |
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.
쿼리 ν€μ μ€νλ₯Ό μμ ν΄ μ£ΌμΈμ
'requestAdnubData'μ μ€νκ° μμ΅λλ€.
λ€μκ³Ό κ°μ΄ μμ νλ κ²μ μ μν©λλ€:
- queryKey: ['requestAdnubData'],
+ queryKey: ['requestAdminData'],
π Committable suggestion
βΌοΈ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
queryKey: ['requestAdnubData'], | |
queryKey: ['requestAdminData'], |
π‘ λ°°κ²½ λ° κ°μ
κ΄λ¦¬μ νλ‘ν λΆλ¬μ€κΈ°
π μμ λ΄μ©
admin νμ΄μ§μ κ΄λ¦¬μ νλ‘νμ λΆλ¬μ€λ apiλ₯Ό ν΅μ νλ€.
Summary by CodeRabbit
μλ‘μ΄ κΈ°λ₯
κ°μ μ¬ν