Repository navigation
[Feat/#110] 홈 API 연동 #111
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/#110] 홈 API 연동 #111
Changes from all commits
9c72c0a
34b876e
03daa53
b0ad3ed
8fc51a0
3fe3bf4
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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { queryOptions } from "@tanstack/react-query"; | ||
| import { FetchStudyCardsParams } from "@typedefs"; | ||
| import { fetchStudyCards } from "./card"; | ||
|
|
||
| export const CARD_QUERY_KEY = { | ||
| ALL: () => ["cards"] as const, | ||
| LIST: (params?: FetchStudyCardsParams) => ["cards", "list", params] as const, | ||
| } as const; | ||
|
|
||
| export const CARD_QUERY_OPTION = { | ||
| LIST: (params?: FetchStudyCardsParams) => | ||
| queryOptions({ | ||
| queryKey: CARD_QUERY_KEY.LIST(params), | ||
| queryFn: () => fetchStudyCards(params), | ||
| }), | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { apiGet } from "@apis/common/methods"; | ||
| import { END_POINTS } from "@constants/api"; | ||
| import { FetchStudyCardsParams, StudyCardListResponse } from "@typedefs"; | ||
|
|
||
| export const fetchStudyCards = (params?: FetchStudyCardsParams) => { | ||
| return apiGet<StudyCardListResponse, FetchStudyCardsParams>(END_POINTS.GET_CARDS_SORT_FILTER, params); | ||
| }; |
|
Contributor
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. 컨벤션이 조금 다른 거 같기도 하고 ....
Contributor
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. 나중에 한번 상의해보면 좋을 듯!! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { CARD_QUERY_OPTION } from "@apis/card/card-queries"; | ||
| import { FOLDER_QUERY_OPTION } from "@apis/folder/folder-queries"; | ||
| import { NOTE_QUERY_OPTION } from "@apis/note/note-queries"; | ||
| import { MainFolderProps } from "@pages/archive/components/MainFolderList/MainFolderList"; | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import { NoteItemProps, RecentMarkedFolder, RecentMarkedNote, ScheduledLearningItemProps, StudyCard } from "@typedefs"; | ||
|
|
||
| const mapToMainFolderProps = (folder: RecentMarkedFolder): MainFolderProps => ({ | ||
| folderId: folder.folderId, | ||
| folderName: folder.name, | ||
| folderColor: folder.color, | ||
| noteCount: folder.noteCount, | ||
| markState: folder.markState === "ACTIVE", | ||
| createdAt: folder.markDate, | ||
| }); | ||
|
|
||
| const mapToNoteItemProps = (note: RecentMarkedNote): NoteItemProps => ({ | ||
| noteId: note.noteId, | ||
| name: note.name, | ||
| folderId: note.folderId, | ||
| folderName: note.folderName, | ||
| folderColor: note.folderColor, | ||
| flashCardCount: note.flashCardCount, | ||
| markState: note.markState, | ||
| viewAt: null, | ||
| editDate: note.markAt, | ||
| createdAt: note.markAt, | ||
| isDownload: false, | ||
| isUpload: false, | ||
| content: note.noteContentPreview ?? undefined, | ||
| }); | ||
|
|
||
| const mapToScheduledLearningProps = (card: StudyCard): ScheduledLearningItemProps => ({ | ||
| noteid: card.studyCardSetId, | ||
| name: card.noteName, | ||
| folderId: 0, | ||
| folderName: card.folderName, | ||
| folderColor: card.color, | ||
| completedCards: card.studyStatus, | ||
| timeReachedCards: 5, | ||
| }); | ||
|
|
||
| export const useRecentMarkedFolders = () => { | ||
| const { data = [] } = useQuery(FOLDER_QUERY_OPTION.RECENT_MARKED()); | ||
| return data.map(mapToMainFolderProps); | ||
| }; | ||
|
|
||
| export const useRecentMarkedNotes = () => { | ||
| const { data = [] } = useQuery(NOTE_QUERY_OPTION.RECENT_MARKED()); | ||
| return data.map(mapToNoteItemProps); | ||
| }; | ||
|
|
||
| export const useScheduledLearningItems = () => { | ||
| const { data = [] } = useQuery(CARD_QUERY_OPTION.LIST({ order: "edit-newest" })); | ||
| return data.slice(0, 3).map(mapToScheduledLearningProps); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import type { SortOrder } from "../common"; | ||
|
|
||
| export interface FetchStudyCardsParams { | ||
| order?: SortOrder; | ||
| color?: string; | ||
| studyStatus?: number; | ||
| } | ||
|
Comment on lines
+3
to
+7
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🌐 Web query:
💡 Result: I couldn’t find documentation for a Cardify API endpoint named /cards/sort-filter. Which "Cardify" are you using (provide the base URL or a link)? I found several different Cardify sites (Cardify AI, Cardify Africa API, Cardify.cards) but no matching endpoint in their docs. Examples: app.cardify.co (API terms) and cardifyai.com. [1][2] If you share the base API URL or a docs link, I’ll fetch the exact parameter spec. [1] https://app.cardify.co/api.php 🏁 Script executed: # Search for backend API documentation, specs, or configuration in the codebase
find . -type f \( -name "*.md" -o -name "*.json" -o -name "*.yaml" -o -name "*.yml" -o -name "*api*" -o -name "*spec*" \) | head -30Repository: UMC-CARDIFY/Client Length of output: 556 🏁 Script executed: # Look for usage of FetchStudyCardsParams in the codebase
rg "FetchStudyCardsParams" -A 5 -B 2Repository: UMC-CARDIFY/Client Length of output: 1809 🏁 Script executed: # Search for any constants or enums related to order, color, or studyStatus
rg "(order|color|studyStatus)" --type ts --type js -B 2 -A 2 | head -100Repository: UMC-CARDIFY/Client Length of output: 4693 🏁 Script executed: # Check the API constants definition
cat src/constants/api.tsRepository: UMC-CARDIFY/Client Length of output: 968 🏁 Script executed: # Look for the color map to see what colors are valid
fd "color-map" -o "colors"Repository: UMC-CARDIFY/Client Length of output: 193 🏁 Script executed: # Search for test files or usage examples of these parameters
fd "\.test\.|\.spec\.|__tests__" -e ts -e tsx | head -20Repository: UMC-CARDIFY/Client Length of output: 44 🏁 Script executed: # Look for any documentation or comments about valid parameter values
rg "studyStatus|order.*color" --type ts --type md -B 3 -A 3 | head -80Repository: UMC-CARDIFY/Client Length of output: 8573 🏁 Script executed: # Find color-map or colors definition file
find . -type f -name "*color*map*" -o -name "*colors*" | grep -E "\.(ts|js|json)$"Repository: UMC-CARDIFY/Client Length of output: 110 🏁 Script executed: # Check README for API documentation
cat README.md | head -100Repository: UMC-CARDIFY/Client Length of output: 70 🏁 Script executed: # Look for components that use FetchStudyCardsParams to see example values
rg "fetchStudyCards\|FetchStudyCardsParams" -B 5 -A 10 --type ts --type tsxRepository: UMC-CARDIFY/Client Length of output: 89 🏁 Script executed: # Search for color constants or validation
rg "order.*=|color.*=|studyStatus" --type ts -B 2 -A 2 | grep -i "const\|enum\|type" | head -30Repository: UMC-CARDIFY/Client Length of output: 2995 🏁 Script executed: # Read the color-map to see valid colors
cat src/styles/color-map.tsRepository: UMC-CARDIFY/Client Length of output: 288 🏁 Script executed: # Read colors.ts to see color definitions
cat src/styles/colors.tsRepository: UMC-CARDIFY/Client Length of output: 2238 🏁 Script executed: # Search for order value assignments to understand valid values
rg "order.*=" --type ts -B 2 -A 2 | head -60Repository: UMC-CARDIFY/Client Length of output: 789 🏁 Script executed: # Search for studyStatus value patterns
rg "studyStatus" --type ts -B 2 -A 2 | head -80Repository: UMC-CARDIFY/Client Length of output: 781 🏁 Script executed: # Find and examine the Sort component to see valid order values
find . -type f -name "*Sort*" -o -name "*sort*" | grep -E "\.(ts|jsx)$"Repository: UMC-CARDIFY/Client Length of output: 44 🏁 Script executed: # Search for where Sort component is defined and what values it accepts
rg "Sort" --type ts -B 5 -A 15 | grep -A 15 "const Sort\|function Sort\|<Sort" | head -100Repository: UMC-CARDIFY/Client Length of output: 7825 🏁 Script executed: # Check if there's any backend documentation or API spec file
find . -type f \( -name "*.md" -o -name "*.swagger*" -o -name "*.openapi*" \) -exec grep -l "cards\|sort-filter" {} \;Repository: UMC-CARDIFY/Client Length of output: 44 🏁 Script executed: # Find the SortOrder type definition
rg "type SortOrder|interface SortOrder|enum SortOrder" --type ts -A 5Repository: UMC-CARDIFY/Client Length of output: 458 🏁 Script executed: # Search for Sort component definition to see what values it accepts
rg "const Sort|function Sort|export.*Sort" --type ts -B 2 -A 20 | head -100Repository: UMC-CARDIFY/Client Length of output: 3266 🏁 Script executed: # Check for any validation or constants related to sort/filter parameters
rg "edit-newest|card-most|card-less" --type ts -B 2 -A 2Repository: UMC-CARDIFY/Client Length of output: 4982 🏁 Script executed: # Search for studyStatus-related constants or type definitions
rg "studyStatus" --type ts -B 5 -A 5Repository: UMC-CARDIFY/Client Length of output: 1452 🏁 Script executed: # Check if there are any constants or enums for card study states
rg "study|card.*status|STUDY" --type ts | grep -i "const\|enum\|type" | head -30Repository: UMC-CARDIFY/Client Length of output: 229 🏁 Script executed: # Look at how studyStatus is used in components
rg "completedCards\|studyStatus" --type ts -B 3 -A 3 | head -80Repository: UMC-CARDIFY/Client Length of output: 44 파라미터 타입을 더욱 구체적으로 정의해주세요.
🤖 Prompt for AI Agents
Contributor
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. 이거 한번 확인좀 부탁드려요 !! 백엔드에서 전달해주는거! 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: Length of output: 666 🏁 Script executed: Length of output: 1238 🏁 Script executed: Length of output: 265 🏁 Script executed: Length of output: 121 🏁 Script executed: Length of output: 3721 🏁 Script executed: Length of output: 159 🏁 Script executed: Length of output: 495 @Sohyunnnn, 프론트엔드 레포지토리에서 백엔드 API 명세를 찾을 수 없었습니다. 하지만 같은 조직의 백엔드 레포지토리를 찾았습니다: 🔗 https://github.com/UMC-CARDIFY/Server 백엔드 팀에 다음 정보를 확인해주세요: 확인이 필요한 파라미터 정보1.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| export interface StudyCard { | ||
| studyStatus: number; | ||
| noteName: string; | ||
| color: string; | ||
| folderName: string; | ||
| recentStudyDate: string | null; | ||
| nextStudyDate: string | null; | ||
| studyCardSetId: number; | ||
| markStatus: "ACTIVE" | "INACTIVE"; | ||
| } | ||
|
|
||
| export type StudyCardListResponse = StudyCard[]; |
|
Contributor
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. 이것도 컨벤션.. 통일하면 좋을 거 같습니다! 얘기 나눠보기 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| export * from "./card-request"; | ||
| export * from "./card-response"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type SortOrder = "asc" | "desc" | "edit-newest" | "edit-oldest"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,3 +67,14 @@ export interface NotMarkElementList { | |
| folderList: FolderItem[]; | ||
| noteList: NoteItem[]; | ||
| } | ||
|
|
||
| export interface RecentMarkedFolder { | ||
| folderId: number; | ||
| name: string; | ||
| color: string; | ||
| markState: "ACTIVE" | "INACTIVE"; | ||
|
Contributor
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. markState response 에서 계속 쓰이고 있어서 전역에 type을 추가해두는 건 어떤지.. 생각이 들어요!.. 전체적으로 ..
Member
Author
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. 저도 그 생각을 했었는데, markState가 API별로 타입이 달라서 전역 타입으로 올리기엔 애매한 것 같아요.. |
||
| markDate: string; | ||
| noteCount: number; | ||
| } | ||
|
|
||
| export type RecentMarkedFoldersResponse = RecentMarkedFolder[]; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| export * from "./common"; | ||
| export * from "./folder"; | ||
| export * from "./note"; | ||
| export * from "./home"; | ||
| export * from "./card"; |
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.
이거 지금보니까 둘이 똑같은데 하나로 합치는 거는 어떤가요 ??
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.
하나로 통일하면 사용하는 곳에서 코드 읽기가 어려울 것 같아서, 저는 개인적으로 분리하는게 낫다고 생각합니다!
나중에 의논해보면 좋을 것 같아용