adding image queries and adding card component + usage

This commit is contained in:
Violet Caulfield
2024-11-29 09:15:04 -06:00
parent 7259c1c006
commit 40f34560f7
5 changed files with 88 additions and 18 deletions

View File

@@ -0,0 +1,12 @@
import { Api } from "@jellyfin/sdk/lib/api"
import { ImageType } from "@jellyfin/sdk/lib/generated-client/models"
import { getImageApi } from "@jellyfin/sdk/lib/utils/api"
export function fetchItemImage(api: Api, itemId: string, imageType?: ImageType) {
return getImageApi(api)
.getItemImage({
imageType: imageType ? imageType : ImageType.Primary,
itemId
})
}

9
api/queries/image.ts Normal file
View File

@@ -0,0 +1,9 @@
import { useQuery } from "@tanstack/react-query";
import { QueryKeys } from "../../enums/query-keys";
import { Api } from "@jellyfin/sdk";
import { fetchItemImage } from "./functions/images";
export const useItemImage = (api: Api, itemId: string) => useQuery({
queryKey: [QueryKeys.ItemImage, api, itemId],
queryFn: ({ queryKey }) => fetchItemImage(queryKey[1] as Api, queryKey[2] as string)
});