From ac28346aceb3797570e036d03e6b21739073e763 Mon Sep 17 00:00:00 2001 From: MontejoJorge Date: Wed, 30 Apr 2025 20:06:12 +0200 Subject: [PATCH] use SimpleAlert component --- .../routes/session/forgotPassword/index.tsx | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/apps/stable/routes/session/forgotPassword/index.tsx b/src/apps/stable/routes/session/forgotPassword/index.tsx index 0fe81e7c0..2e3045e24 100644 --- a/src/apps/stable/routes/session/forgotPassword/index.tsx +++ b/src/apps/stable/routes/session/forgotPassword/index.tsx @@ -5,14 +5,17 @@ import globalize from 'lib/globalize'; import Button from 'elements/emby-button/Button'; import Input from 'elements/emby-input/Input'; import { useMutation } from '@tanstack/react-query'; -import Dashboard from 'utils/dashboard'; import { getUserApi } from '@jellyfin/sdk/lib/utils/api/user-api'; import { ForgotPasswordAction } from '@jellyfin/sdk/lib/generated-client/models/forgot-password-action'; import ServerConnections from 'components/ServerConnections'; +import SimpleAlert from 'components/SimpleAlert'; export const ForgotPasswordPage = () => { const navigate = useNavigate(); const [username, setUsername] = useState(''); + const [isAlertOpen, setIsAlertOpen] = useState(false); + const [alertMessage, setAlertMessage] = useState(''); + const [alertCallback, setAlertCallback] = useState<(() => void) | undefined>(undefined); const forgotPasswordMutation = useMutation({ mutationFn: async (enteredUsername: string) => { @@ -41,22 +44,17 @@ export const ForgotPasswordPage = () => { break; case ForgotPasswordAction.PinCode: msg = globalize.translate('MessageForgotPasswordFileCreated'); - msg += '

'; - msg += globalize.translate('MessageForgotPasswordPinReset'); - msg += '

'; + msg += ': '; msg += result.PinFile; - msg += '
'; callback = () => navigate('/forgotpasswordpin'); break; default: return; } - Dashboard.alert({ - message: msg, - title: globalize.translate('ButtonForgotPassword'), - callback: callback - }); + setAlertMessage(msg); + setAlertCallback(() => callback); + setIsAlertOpen(true); } }); @@ -73,11 +71,23 @@ export const ForgotPasswordPage = () => { setUsername(e.target.value); }, []); + const handleAlertClose = useCallback(() => { + setIsAlertOpen(false); + if (alertCallback) { + alertCallback(); + } + }, [alertCallback]); + return ( +