Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
chore(hooks): add react-query hook to fetch problem ranklist
Browse files Browse the repository at this point in the history
  ## what
  - add react-query hook to fetch problem ranklist

  ## how
  - fetch from endpoint `/api/problems/ranklist/[problemNum]`

  ## why

  ## where
  - ./src/hooks/index.ts

  ## usage
  • Loading branch information
Clumsy-Coder committed Jan 10, 2024
1 parent b953e0f commit c10b590
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export enum queryKey {
* React query key for fetching a problem num
*/
problemNum = "problem-num",
/**
* React query key for fetching a problem ranklist
*/
problemRanklist = "problem-ranklist",
/**
* React query key for fetching submission overtime count
*/
Expand Down Expand Up @@ -92,3 +96,15 @@ export const useFetchSubmissionLang = (problemNum: number) => {
});
}

/**
* Fetch problem ranklist
*/
export const useFetchProblemRanklist = (problemNum: number) => {
return useQuery({
queryKey: [queryKey.problemRanklist],
queryFn: async () =>
await axios
.get(`/api/problems/ranklist/${problemNum}`)
.then((res) => res.data),
});
}

0 comments on commit c10b590

Please sign in to comment.