Files
streamyfin/hooks/useTVAccountSelectModal.ts
Fredrik Burmester 85a74a9a6a refactor: login page
2026-01-31 10:52:21 +01:00

35 lines
982 B
TypeScript

import { useCallback } from "react";
import useRouter from "@/hooks/useAppRouter";
import { tvAccountSelectModalAtom } from "@/utils/atoms/tvAccountSelectModal";
import type {
SavedServer,
SavedServerAccount,
} from "@/utils/secureCredentials";
import { store } from "@/utils/store";
interface ShowAccountSelectModalParams {
server: SavedServer;
onAccountAction: (account: SavedServerAccount) => void;
onAddAccount: () => void;
onDeleteServer: () => void;
}
export const useTVAccountSelectModal = () => {
const router = useRouter();
const showAccountSelectModal = useCallback(
(params: ShowAccountSelectModalParams) => {
store.set(tvAccountSelectModalAtom, {
server: params.server,
onAccountAction: params.onAccountAction,
onAddAccount: params.onAddAccount,
onDeleteServer: params.onDeleteServer,
});
router.push("/tv-account-select-modal");
},
[router],
);
return { showAccountSelectModal };
};