From 94ef30c3d5f59097c967c914315d94ac4418c35a Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Mon, 8 May 2023 13:49:35 +0530 Subject: [PATCH] fix(ui): forgot password success feedback (#11437) --- .../auth-provider/basic-auth.provider.tsx | 3 --- .../forgot-password.component.tsx | 27 ++++++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/authentication/auth-provider/basic-auth.provider.tsx b/openmetadata-ui/src/main/resources/ui/src/components/authentication/auth-provider/basic-auth.provider.tsx index 4448039e8e4b..c1320860ecbc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/authentication/auth-provider/basic-auth.provider.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/authentication/auth-provider/basic-auth.provider.tsx @@ -166,7 +166,6 @@ const BasicAuthProvider = ({ const handleForgotPassword = async (email: string) => { try { - setLoadingIndicator(true); await generatePasswordResetLink(email); } catch (err) { if ( @@ -177,8 +176,6 @@ const BasicAuthProvider = ({ } else { showErrorToast(t('server.email-not-found')); } - } finally { - setLoadingIndicator(false); } }; diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/forgot-password/forgot-password.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/forgot-password/forgot-password.component.tsx index 1f6bbb7237b2..11c6fe6e55cb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/forgot-password/forgot-password.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/forgot-password/forgot-password.component.tsx @@ -13,7 +13,7 @@ import { Button, Card, Col, Divider, Form, Input, Row, Typography } from 'antd'; import { useBasicAuth } from 'components/authentication/auth-provider/basic-auth.provider'; -import React, { useState } from 'react'; +import React, { useCallback, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useHistory } from 'react-router-dom'; import { ROUTES } from '../../constants/constants'; @@ -24,17 +24,24 @@ const ForgotPassword = () => { const { t } = useTranslation(); const { handleForgotPassword } = useBasicAuth(); const history = useHistory(); + const [loading, setLoading] = useState(false); const [showResetLinkSentAlert, setShowResetLinkSentAlert] = useState(false); - const handleSubmit = async (data: { email: string }) => { - try { - handleForgotPassword && (await handleForgotPassword(data.email)); - setShowResetLinkSentAlert(true); - } catch (error) { - setShowResetLinkSentAlert(false); - } - }; + const handleSubmit = useCallback( + async (data: { email: string }) => { + try { + setLoading(true); + handleForgotPassword && (await handleForgotPassword(data.email)); + setShowResetLinkSentAlert(true); + } catch (error) { + setShowResetLinkSentAlert(false); + } finally { + setLoading(false); + } + }, + [setShowResetLinkSentAlert, handleForgotPassword] + ); return (
@@ -77,7 +84,7 @@ const ForgotPassword = () => { -