From 0a7387be6c3782b8cf160729f2b17f1665555335 Mon Sep 17 00:00:00 2001 From: jenny-s51 Date: Tue, 22 Jun 2021 11:19:13 -0400 Subject: [PATCH] afix username/password fields --- src/realm-settings/EmailTab.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/realm-settings/EmailTab.tsx b/src/realm-settings/EmailTab.tsx index 7e54aa535e..0bc5f2485c 100644 --- a/src/realm-settings/EmailTab.tsx +++ b/src/realm-settings/EmailTab.tsx @@ -1,6 +1,6 @@ import React, { useContext, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import { Controller, useForm } from "react-hook-form"; +import { Controller, useForm, useWatch } from "react-hook-form"; import { ActionGroup, AlertVariant, @@ -42,7 +42,6 @@ export const RealmSettingsEmailTab = ({ const { addAlert } = useAlerts(); const { whoAmI } = useContext(WhoAmIContext); - const [isAuthenticationEnabled, setAuthenticationEnabled] = useState("true"); const [realm, setRealm] = useState(initialRealm); const [userEmailModalOpen, setUserEmailModalOpen] = useState(false); const [currentUser, setCurrentUser] = useState(); @@ -61,6 +60,12 @@ export const RealmSettingsEmailTab = ({ const watchFromValue = watch("smtpServer.from", ""); const watchHostValue = watch("smtpServer.host", ""); + const authenticationEnabled = useWatch({ + control, + name: "smtpServer.authentication", + defaultValue: realm?.smtpServer!.authentication, + }); + useEffect(() => { reset(); }, [realm]); @@ -329,7 +334,7 @@ export const RealmSettingsEmailTab = ({ ( { onChange("" + value); - setAuthenticationEnabled(String(value)); }} /> )} /> - {isAuthenticationEnabled === "true" && ( + {authenticationEnabled === "true" && ( <>