-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/#101
- Loading branch information
Showing
14 changed files
with
406 additions
and
93 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,33 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { TagType } from "../../types/experience"; | ||
import { AxiosError, AxiosResponse } from "axios"; | ||
import { getExperienceYears } from "../../services/Experience/experienceApi"; | ||
|
||
interface ExperienceYearsResType { | ||
years: number[]; | ||
yearTagInfos: { year: number; tags: TagType[] }[]; | ||
} | ||
|
||
export const useExperienceYearsQuery = (token: string) => { | ||
const queryKey = ["experienceYears", token]; | ||
|
||
const queryFn = async (): Promise<ExperienceYearsResType> => { | ||
if (token) { | ||
const response: AxiosResponse<ExperienceYearsResType> = | ||
await getExperienceYears(token); | ||
return response.data; | ||
} | ||
throw new Error("Missing parameters"); | ||
}; | ||
|
||
const { isLoading, isError, data, error, isSuccess, refetch } = useQuery< | ||
ExperienceYearsResType, | ||
AxiosError | ||
>({ | ||
queryKey, | ||
queryFn, | ||
enabled: !!token, | ||
}); | ||
|
||
return { isLoading, isError, data, error, isSuccess, refetch }; | ||
}; |
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,27 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { AxiosError, AxiosResponse } from "axios"; | ||
import { UserDataType } from "../../types/user"; | ||
import { getUserInfo } from "../../services/user"; | ||
|
||
export const useGetUserInfo = (token: string) => { | ||
const queryKey = ["userInfo", token]; | ||
|
||
const queryFn = async (): Promise<UserDataType> => { | ||
if (token) { | ||
const response: AxiosResponse<UserDataType> = await getUserInfo(token); | ||
return response.data; | ||
} | ||
throw new Error("Missing parameters"); | ||
}; | ||
|
||
const { isLoading, isError, data, error, isSuccess, refetch } = useQuery< | ||
UserDataType, | ||
AxiosError | ||
>({ | ||
queryKey, | ||
queryFn, | ||
enabled: !!token, | ||
}); | ||
|
||
return { isLoading, isError, data, error, isSuccess, refetch }; | ||
}; |
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,37 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getPrimeTagSubTags } from "../../services/Experience/tagApi"; | ||
import { TagMenuType } from "../../types/experience"; | ||
import { AxiosError, AxiosResponse } from "axios"; | ||
|
||
interface PrimeTagSubTagsResType { | ||
totalExperienceCount: number; | ||
tagInfos: TagMenuType[]; | ||
} | ||
|
||
export const useSubTagsQuery = ( | ||
year: number | null, | ||
primeTagId: string | undefined, | ||
token: string | ||
) => { | ||
const queryKey = ["primeTagSubTags", year, primeTagId, token]; | ||
|
||
const queryFn = async (): Promise<PrimeTagSubTagsResType> => { | ||
if (year && primeTagId && token) { | ||
const response: AxiosResponse<PrimeTagSubTagsResType> = | ||
await getPrimeTagSubTags(year, primeTagId, token); | ||
return response.data; | ||
} | ||
throw new Error("Missing parameters"); | ||
}; | ||
|
||
const { isLoading, isError, data, error, isSuccess, refetch } = useQuery< | ||
PrimeTagSubTagsResType, | ||
AxiosError | ||
>({ | ||
queryKey, | ||
queryFn, | ||
enabled: !!(year && primeTagId && token), | ||
}); | ||
|
||
return { isLoading, isError, data, error, isSuccess, refetch }; | ||
}; |
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
Oops, something went wrong.