mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-08 23:18:31 +01:00
feat(tv): seerr
This commit is contained in:
34
hooks/useTVRequestModal.ts
Normal file
34
hooks/useTVRequestModal.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { useCallback } from "react";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
import { tvRequestModalAtom } from "@/utils/atoms/tvRequestModal";
|
||||
import type { MediaType } from "@/utils/jellyseerr/server/constants/media";
|
||||
import type { MediaRequestBody } from "@/utils/jellyseerr/server/interfaces/api/requestInterfaces";
|
||||
import { store } from "@/utils/store";
|
||||
|
||||
interface ShowRequestModalParams {
|
||||
requestBody: MediaRequestBody;
|
||||
title: string;
|
||||
id: number;
|
||||
mediaType: MediaType;
|
||||
onRequested: () => void;
|
||||
}
|
||||
|
||||
export const useTVRequestModal = () => {
|
||||
const router = useRouter();
|
||||
|
||||
const showRequestModal = useCallback(
|
||||
(params: ShowRequestModalParams) => {
|
||||
store.set(tvRequestModalAtom, {
|
||||
requestBody: params.requestBody,
|
||||
title: params.title,
|
||||
id: params.id,
|
||||
mediaType: params.mediaType,
|
||||
onRequested: params.onRequested,
|
||||
});
|
||||
router.push("/(auth)/tv-request-modal");
|
||||
},
|
||||
[router],
|
||||
);
|
||||
|
||||
return { showRequestModal };
|
||||
};
|
||||
Reference in New Issue
Block a user