Implemented the new react version of the frontend
This commit is contained in:
1 parent
236e6e06fb
commit
ffe7e52527
65 files changed
+5228
-177
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { seasonsApi } from '@/api/seasons';
|
||||
|
||||
export const seasonKeys = {
|
||||
all: ['seasons'] as const,
|
||||
detail: (id: number) => ['seasons', id] as const,
|
||||
episodes: (id: number) => ['seasons', id, 'episodes'] as const,
|
||||
};
|
||||
|
||||
export function useSeason(id: number) {
|
||||
return useQuery({
|
||||
queryKey: seasonKeys.detail(id),
|
||||
queryFn: () => seasonsApi.getById(id),
|
||||
enabled: !!id,
|
||||
});
|
||||
}
|
||||
|
||||
export function useSeasonEpisodes(id: number) {
|
||||
return useQuery({
|
||||
queryKey: seasonKeys.episodes(id),
|
||||
queryFn: () => seasonsApi.getEpisodes(id),
|
||||
enabled: !!id,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user