mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-03 13:56:29 +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 };
|
||||
};
|
||||
@@ -9,9 +9,9 @@ import { store } from "@/utils/store";
|
||||
|
||||
interface ShowAccountSelectModalParams {
|
||||
server: SavedServer;
|
||||
onAccountSelect: (account: SavedServerAccount) => void;
|
||||
onAccountAction: (account: SavedServerAccount) => void;
|
||||
onAddAccount: () => void;
|
||||
onDeleteAccount: (account: SavedServerAccount) => void;
|
||||
onDeleteServer: () => void;
|
||||
}
|
||||
|
||||
export const useTVAccountSelectModal = () => {
|
||||
@@ -21,9 +21,9 @@ export const useTVAccountSelectModal = () => {
|
||||
(params: ShowAccountSelectModalParams) => {
|
||||
store.set(tvAccountSelectModalAtom, {
|
||||
server: params.server,
|
||||
onAccountSelect: params.onAccountSelect,
|
||||
onAccountAction: params.onAccountAction,
|
||||
onAddAccount: params.onAddAccount,
|
||||
onDeleteAccount: params.onDeleteAccount,
|
||||
onDeleteServer: params.onDeleteServer,
|
||||
});
|
||||
router.push("/tv-account-select-modal");
|
||||
},
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { useCallback } from "react";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
import { tvServerActionModalAtom } from "@/utils/atoms/tvServerActionModal";
|
||||
import type { SavedServer } from "@/utils/secureCredentials";
|
||||
import { store } from "@/utils/store";
|
||||
|
||||
interface ShowServerActionModalParams {
|
||||
server: SavedServer;
|
||||
onLogin: () => void;
|
||||
onDelete: () => void;
|
||||
}
|
||||
|
||||
export const useTVServerActionModal = () => {
|
||||
const router = useRouter();
|
||||
|
||||
const showServerActionModal = useCallback(
|
||||
(params: ShowServerActionModalParams) => {
|
||||
store.set(tvServerActionModalAtom, {
|
||||
server: params.server,
|
||||
onLogin: params.onLogin,
|
||||
onDelete: params.onDelete,
|
||||
});
|
||||
router.push("/tv-server-action-modal");
|
||||
},
|
||||
[router],
|
||||
);
|
||||
|
||||
return { showServerActionModal };
|
||||
};
|
||||
Reference in New Issue
Block a user