mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-30 23:18:12 +00:00
35 lines
1012 B
TypeScript
35 lines
1012 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;
|
|
onAccountSelect: (account: SavedServerAccount) => void;
|
|
onAddAccount: () => void;
|
|
onDeleteAccount: (account: SavedServerAccount) => void;
|
|
}
|
|
|
|
export const useTVAccountSelectModal = () => {
|
|
const router = useRouter();
|
|
|
|
const showAccountSelectModal = useCallback(
|
|
(params: ShowAccountSelectModalParams) => {
|
|
store.set(tvAccountSelectModalAtom, {
|
|
server: params.server,
|
|
onAccountSelect: params.onAccountSelect,
|
|
onAddAccount: params.onAddAccount,
|
|
onDeleteAccount: params.onDeleteAccount,
|
|
});
|
|
router.push("/tv-account-select-modal");
|
|
},
|
|
[router],
|
|
);
|
|
|
|
return { showAccountSelectModal };
|
|
};
|