-
Notifications
You must be signed in to change notification settings - Fork 1
Fix(estension): extension api v3 update및 edit error 해결 #302
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
8b05b25
7aacea1
bcf1f98
e12570f
7119383
f1e97f7
d0c709b
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 |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
| import { useGetArticleDetail, useGetArticleSaved } from '@apis/query/queries'; | ||
| import { useEffect, useState } from 'react'; | ||
| import './App.css'; | ||
| import DuplicatePop from './pages/DuplicatePop'; | ||
| import MainPop from './pages/MainPop'; | ||
| import { useState, useEffect } from 'react'; | ||
| import { useGetArticleSaved } from '@apis/query/queries'; | ||
| import { usePageMeta } from './hooks/usePageMeta'; | ||
| import DuplicatePop from './pages/DuplicatePop'; | ||
| import LogOutPop from './pages/LogOutPop'; | ||
| import MainPop from './pages/MainPop'; | ||
|
|
||
| const App = () => { | ||
| const { url } = usePageMeta(); | ||
| const { data: isSaved } = useGetArticleSaved(url); | ||
| const { data: savedArticle } = useGetArticleSaved(url); | ||
| const articleId = savedArticle?.data?.id; | ||
| const { data: articleDetail } = useGetArticleDetail(articleId!); | ||
|
|
||
| const [isDuplicatePop, setIsDuplicatePop] = useState(false); | ||
| const [mainPopType, setMainPopType] = useState<'add' | 'edit'>('add'); | ||
|
|
@@ -18,11 +21,13 @@ const App = () => { | |
| setIsToken(!!result.token); | ||
| }); | ||
| }, []); | ||
|
|
||
| // 이미 저장된 아티클이면 DuplicatePop 표시 | ||
| useEffect(() => { | ||
| if (isSaved?.data) { | ||
| if (savedArticle?.data) { | ||
| setIsDuplicatePop(true); | ||
| } | ||
| }, [isSaved]); | ||
| }, [savedArticle]); | ||
|
|
||
| const handleDuplicateLeftClick = () => { | ||
| setIsDuplicatePop(false); | ||
|
|
@@ -42,7 +47,7 @@ const App = () => { | |
| onRightClick={handleDuplicateRightClick} | ||
| /> | ||
| ) : ( | ||
| <MainPop type={mainPopType} /> | ||
| <MainPop type={mainPopType} savedData={articleDetail} /> | ||
|
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: articleDetail 데이터 흐름 및 타입 확인
echo "=== MainPop savedData prop 타입 확인 ==="
rg -n "savedData\?:" apps/extension/src/pages/MainPop.tsx -A2
echo ""
echo "=== useGetArticleDetail 반환 타입 확인 ==="
rg -n "useGetArticleDetail" apps/extension/src/apis/query/queries.ts -A10Repository: Pinback-Team/pinback-client Length of output: 481 🏁 Script executed: #!/bin/bash
echo "=== App.tsx의 useGetArticleDetail 사용 부분 ==="
rg -n "useGetArticleDetail\|articleDetail" apps/extension/src/App.tsx -B5 -A5
echo ""
echo "=== getArticleDetail 함수의 반환 타입 ==="
rg -n "getArticleDetail" apps/extension/src/apis/query/queries.ts -B2 -A8
echo ""
echo "=== ArticleResponse 타입 정의 확인 ==="
rg -n "type ArticleResponse\|interface ArticleResponse" apps/extension/src -A5Repository: Pinback-Team/pinback-client Length of output: 558 🏁 Script executed: #!/bin/bash
echo "=== App.tsx 전체 내용 확인 ==="
cat -n apps/extension/src/App.tsx | head -80
echo ""
echo "=== ArticleResponse 타입 정의 위치 찾기 ==="
rg -l "ArticleResponse" apps/extension/src/
echo ""
echo "=== getArticleDetail 함수 정의 찾기 ==="
fd -e ts -e tsx apps/extension/src/apis | xargs rg -l "getArticleDetail"Repository: Pinback-Team/pinback-client Length of output: 3027 🏁 Script executed: #!/bin/bash
echo "=== ArticleResponse 타입 정의 ==="
cat -n apps/extension/src/types/types.ts | head -100
echo ""
echo "=== getArticleDetail 및 useGetArticleDetail 전체 구현 ==="
sed -n '1,100p' apps/extension/src/apis/query/queries.ts | cat -nRepository: Pinback-Team/pinback-client Length of output: 2894 🏁 Script executed: #!/bin/bash
echo "=== getArticleDetail 함수 정의 (axios.ts) ==="
rg -n "getArticleDetail" apps/extension/src/apis/axios.ts -B2 -A10
echo ""
echo "=== Axios 응답 타입 구조 ==="
rg -n "export.*getArticleDetail\|^export const getArticleDetail\|return.*getArticleDetail" apps/extension/src/apis/axios.ts -B5 -A15Repository: Pinback-Team/pinback-client Length of output: 335
다음을 개선해주세요:
🤖 Prompt for AI Agents |
||
| ) | ||
| ) : ( | ||
| <LogOutPop /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -65,6 +65,13 @@ export const putArticle = async ( | |||||||||||||
| articleId: number, | ||||||||||||||
| data: PutArticleRequest | ||||||||||||||
| ) => { | ||||||||||||||
| const response = await apiRequest.put(`/api/v1/articles/${articleId}`, data); | ||||||||||||||
| return response.data; | ||||||||||||||
| const response = await apiRequest.put(`/api/v1/articles/${articleId}`, { | ||||||||||||||
| ...data, | ||||||||||||||
| }); | ||||||||||||||
| return response; | ||||||||||||||
|
Comment on lines
+68
to
+71
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.
다른 API 함수들( 또한 🐛 일관성 있는 반환값 수정 제안 export const putArticle = async (
articleId: number,
data: PutArticleRequest
) => {
- const response = await apiRequest.put(`/api/v1/articles/${articleId}`, {
- ...data,
- });
- return response;
+ const response = await apiRequest.put(`/api/v1/articles/${articleId}`, data);
+ return response.data;
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| export const getArticleDetail = async (articleId: number) => { | ||||||||||||||
| const response = await apiRequest.get(`/api/v3/articles/${articleId}`); | ||||||||||||||
| return response.data.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.
articleId추출 및 사용 불일치Line 12에서
savedArticle?.data?.id로 articleId를 추출하고, Line 42에서는savedArticle?.data?.articleId를 로깅합니다. API 응답에서 올바른 필드가 무엇인지 확인하고 일관되게 사용해주세요.또한
articleId!non-null assertion은articleId가undefined일 때 타입 에러를 숨깁니다.useGetArticleDetail훅 내부에서enabled: !!articleId로 보호되어 있어 런타임에는 안전하지만, 명시적으로 처리하는 것이 좋습니다.🐛 수정 제안
const { data: savedArticle } = useGetArticleSaved(url); - const articleId = savedArticle?.data?.id; - const { data: articleDetail } = useGetArticleDetail(articleId!); + const articleId = savedArticle?.data?.articleId; // 또는 id - API 응답 확인 후 결정 + const { data: articleDetail } = useGetArticleDetail(articleId);useGetArticleDetail이 이미articleId?: number를 받으므로 non-null assertion이 불필요합니다.📝 Committable suggestion
🤖 Prompt for AI Agents