-
Notifications
You must be signed in to change notification settings - Fork 4
[Feat] 마이페이지 질문지 탭 실제 api 연결 및 리액트 쿼리 훅으로 분리해서 사용 #282
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
999f345
refactor: api 내부 폴더명 api 엔드포인트와 통일
yiseungyun c0b40b7
feat: tanstack query 사용 코드 훅으로 분리
yiseungyun 276c66e
fix: 세션 만들기 폼 모달 오류 수정
yiseungyun 393af8e
feat: 마이페이지 meta 데이터로 페이지네이션 적용
yiseungyun 28056fe
feat: 마이페이지 질문지 실제 api 데이터 넣고, 삭제 시 실시간 반영
yiseungyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import axios from "axios"; | ||
|
|
||
| interface QuestionListProps { | ||
| page: number; | ||
| limit: number; | ||
| } | ||
|
|
||
| interface Question { | ||
| id: number; | ||
| content: string; | ||
| index: number; | ||
| questionListId: number; | ||
| } | ||
|
|
||
| interface QuestionList { | ||
| id: number; | ||
| title: string; | ||
| contents: Question[]; | ||
| categoryNames: string[]; | ||
| isPublic: boolean; | ||
| usage: number; | ||
| } | ||
|
|
||
| interface ApiResponse { | ||
| success: boolean; | ||
| message: string; | ||
| data: { | ||
| myQuestionLists: QuestionList[]; | ||
| meta: { | ||
| itemsPerPage: number; | ||
| totalItems: number; | ||
| currentPage: string; | ||
| totalPages: number; | ||
| sortBy: [string[]]; | ||
| }; | ||
| }; | ||
| } | ||
|
|
||
| const getMyQuestionList = async ({ page, limit }: QuestionListProps) => { | ||
| const response = await axios.get<ApiResponse>("/api/question-list/my", { | ||
| params: { | ||
| page, | ||
| limit, | ||
| }, | ||
| }); | ||
|
|
||
| if (!response.data.success) { | ||
| throw new Error(response.data.message); | ||
| } | ||
|
|
||
| return response.data.data; | ||
| }; | ||
|
|
||
| export default getMyQuestionList; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import axios from "axios"; | ||
|
|
||
| const getQuestionContent = async (questionListId: number) => { | ||
| const response = await axios.post("/api/question-list/contents", { | ||
| questionListId, | ||
| }); | ||
|
|
||
| if (!response.data.success) { | ||
| throw new Error(response.data.message); | ||
| } | ||
|
|
||
| return response.data.data.questionListContents; | ||
| }; | ||
|
|
||
| export default getQuestionContent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import axios from "axios"; | ||
|
|
||
| interface QuestionListProps { | ||
| page: number; | ||
| limit: number; | ||
| } | ||
|
|
||
| interface Question { | ||
| id: number; | ||
| content: string; | ||
| index: number; | ||
| questionListId: number; | ||
| } | ||
|
|
||
| interface QuestionList { | ||
| id: number; | ||
| title: string; | ||
| contents: Question[]; | ||
| categoryNames: string[]; | ||
| isPublic: boolean; | ||
| usage: number; | ||
| } | ||
|
|
||
| interface ApiResponse { | ||
| success: boolean; | ||
| message: string; | ||
| data: { | ||
| questionLists: QuestionList[]; | ||
| meta: { | ||
| itemsPerPage: number; | ||
| totalItems: number; | ||
| currentPage: string; | ||
| totalPages: number; | ||
| sortBy: [string[]]; | ||
| }; | ||
| }; | ||
| } | ||
|
|
||
| const getScrapQuestionList = async ({ page, limit }: QuestionListProps) => { | ||
| const response = await axios.get<ApiResponse>("/api/question-list/scrap", { | ||
| params: { | ||
| page, | ||
| limit, | ||
| }, | ||
| }); | ||
|
|
||
| if (!response.data.success) { | ||
| throw new Error(response.data.message); | ||
| } | ||
|
|
||
| return response.data.data; | ||
| }; | ||
|
|
||
| export default getScrapQuestionList; |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
frontend/src/components/sessions/create/SessionForm/QuestionListSection/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
useModal로 생성한 modal은 모달로 만들고 싶은 컴포넌트에 전달하고, 모달을 여는 버튼에는 modal.openModal을 전달하는 방식이군요 활용해보겠슴니다