mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-28 08:40:27 +01:00
refactor: login page
This commit is contained in:
34
hooks/useTVAccountActionModal.ts
Normal file
34
hooks/useTVAccountActionModal.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { useCallback } from "react";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
import { tvAccountActionModalAtom } from "@/utils/atoms/tvAccountActionModal";
|
||||
import type {
|
||||
SavedServer,
|
||||
SavedServerAccount,
|
||||
} from "@/utils/secureCredentials";
|
||||
import { store } from "@/utils/store";
|
||||
|
||||
interface ShowAccountActionModalParams {
|
||||
server: SavedServer;
|
||||
account: SavedServerAccount;
|
||||
onLogin: () => void;
|
||||
onDelete: () => void;
|
||||
}
|
||||
|
||||
export const useTVAccountActionModal = () => {
|
||||
const router = useRouter();
|
||||
|
||||
const showAccountActionModal = useCallback(
|
||||
(params: ShowAccountActionModalParams) => {
|
||||
store.set(tvAccountActionModalAtom, {
|
||||
server: params.server,
|
||||
account: params.account,
|
||||
onLogin: params.onLogin,
|
||||
onDelete: params.onDelete,
|
||||
});
|
||||
router.push("/tv-account-action-modal");
|
||||
},
|
||||
[router],
|
||||
);
|
||||
|
||||
return { showAccountActionModal };
|
||||
};
|
||||
Reference in New Issue
Block a user