-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : 메인페이지 bottom sheet 키워드 api 연동 (#281)
* feat : 키워드 관련 api 연동 * chore : 사용자 키워드 등록 성공 시 콘솔 찍히던거 삭제
- Loading branch information
1 parent
45f35d0
commit 2985734
Showing
8 changed files
with
127 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 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 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,14 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { createUserKeyword } from '@/service/keyword/createUserKeyword'; | ||
|
||
export const useCreateUserKeywords = () => { | ||
const mutation = useMutation({ | ||
mutationFn: createUserKeyword, | ||
onSuccess: () => {}, | ||
onError: (error) => { | ||
console.error('키워드 생성 실패:', error); | ||
} | ||
}); | ||
|
||
return mutation; | ||
}; |
This file contains 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,9 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { getAllKeyword } from '@/service/keyword/getAllKeyword'; | ||
|
||
export const useGetAllKeywords = () => { | ||
return useQuery({ | ||
queryKey: ['allKeywords'], | ||
queryFn: getAllKeyword | ||
}); | ||
}; |
This file contains 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,9 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { getUserKeyword } from '@/service/keyword/getUserKeyword'; | ||
|
||
export const useGetUserKeywords = () => { | ||
return useQuery({ | ||
queryKey: ['userKeywords'], | ||
queryFn: getUserKeyword | ||
}); | ||
}; |
This file contains 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,17 @@ | ||
import { defaultApi } from '@/service/api'; | ||
|
||
type CraeteUserKeywordType = { | ||
isSuccess: boolean; | ||
code: string; | ||
message: string; | ||
result: string; | ||
}; | ||
|
||
export const createUserKeyword = async ( | ||
keywords: string[] | ||
): Promise<CraeteUserKeywordType> => { | ||
const api = defaultApi(); | ||
|
||
const response = await api.post('/keywords', { keywords }); | ||
return response.data; | ||
}; |
This file contains 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,20 @@ | ||
import { defaultApi } from '@/service/api'; | ||
|
||
type GetAllKeywordType = { | ||
isSuccess: boolean; | ||
code: string; | ||
message: string; | ||
result: { | ||
categories: { | ||
category: string; | ||
keywords: string[]; | ||
}[]; | ||
}; | ||
}; | ||
|
||
export const getAllKeyword = async (): Promise<GetAllKeywordType> => { | ||
const api = defaultApi(); | ||
|
||
const response = await api.get('/keywords/list'); | ||
return response.data; | ||
}; |
This file contains 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,17 @@ | ||
import { defaultApi } from '@/service/api'; | ||
|
||
type GetUserKeywordType = { | ||
isSuccess: boolean; | ||
code: string; | ||
message: string; | ||
result: { | ||
keywords: string[]; | ||
}; | ||
}; | ||
|
||
export const getUserKeyword = async (): Promise<GetUserKeywordType> => { | ||
const api = defaultApi(); | ||
|
||
const response = await api.get('/keywords'); | ||
return response.data; | ||
}; |