diff --git a/src/api/user/email/verify/index.ts b/src/api/user/email/verify/index.ts index e50b07fb..b1fd249f 100644 --- a/src/api/user/email/verify/index.ts +++ b/src/api/user/email/verify/index.ts @@ -17,7 +17,7 @@ const useVerifyUserEmail = (): IUseVerifyUserEmailService => { const response = await fetchData({ url: getApiUrl("/api/user/email/verify"), method: "GET", - query: { userId }, + query: { recipeUserId: userId }, }); const body = await response.json(); diff --git a/src/ui/components/userDetail/loginMethods/LoginMethods.tsx b/src/ui/components/userDetail/loginMethods/LoginMethods.tsx index 5f8b2d57..7bebe922 100644 --- a/src/ui/components/userDetail/loginMethods/LoginMethods.tsx +++ b/src/ui/components/userDetail/loginMethods/LoginMethods.tsx @@ -132,6 +132,7 @@ type MethodProps = { updateContext: (val: LoginMethod, ind: number) => void; index: number; showUnlink: boolean; + isVerifyEmailFeatureEnabled: boolean; }; const Methods: React.FC = ({ @@ -144,6 +145,7 @@ const Methods: React.FC = ({ updateContext, index, showUnlink, + isVerifyEmailFeatureEnabled, }) => { const { sendUserEmailVerification: sendUserEmailVerificationApi } = useVerifyUserTokenService(); const { showModal, showToast } = useContext(PopupContentContext); @@ -279,26 +281,35 @@ const Methods: React.FC = ({
Is Email Verified?: {" "}
- - {!isEditing && !loginMethod.verified && ( - - - sendUserEmailVerification(loginMethod.recipeUserId, loginMethod.tenantIds[0]) - } - /> - - )} - {isEditing && ( - - {loginMethod.verified ? "Set as Unverified" : "Set as Verified"} - + {isVerifyEmailFeatureEnabled ? ( + <> + + {!isEditing && !loginMethod.verified && ( + + + sendUserEmailVerification( + loginMethod.recipeUserId, + loginMethod.tenantIds[0] + ) + } + /> + + )} + {isEditing && ( + + {loginMethod.verified ? "Set as Unverified" : "Set as Verified"} + + )} + + ) : ( + Feature not enabled )}
@@ -367,9 +378,9 @@ const Methods: React.FC = ({ ); }; -type LoginMethodProps = { refetchAllData: () => Promise }; +type LoginMethodProps = { refetchAllData: () => Promise; isVerifyEmailFeatureEnabled: boolean }; -export const LoginMethods: React.FC = ({ refetchAllData }) => { +export const LoginMethods: React.FC = ({ refetchAllData, isVerifyEmailFeatureEnabled }) => { const { userDetail, setUserDetails } = useUserDetailContext(); const { updateUserInformation } = useUserService(); const methods = userDetail.details.loginMethods; @@ -438,6 +449,7 @@ export const LoginMethods: React.FC = ({ refetchAllData }) => header={
Login Methods
}> {methods.map((val, ind) => ( = (props) => { const [sessionList, setSessionList] = useState(undefined); const [userMetaData, setUserMetaData] = useState(undefined); const [shouldShowLoadingOverlay, setShowLoadingOverlay] = useState(false); + const [isVerifyEmailFeatureEnabled, setIsVerifyEmailFeatureEnabled] = useState(false); const { getUser, updateUserInformation } = useUserService(); const { getUserMetaData } = useMetadataService(); const { getSessionsForUser } = useSessionsForUserService(); const { showModal } = useContext(PopupContentContext); + const { getUserEmailVerificationStatus } = useVerifyUserEmail(); const loadUserDetail = useCallback(async () => { const userDetailsResponse = await getUser(user); - setUserDetail(JSON.parse(JSON.stringify(userDetailsResponse))); + const parsedUserDetails = JSON.parse(JSON.stringify(userDetailsResponse)) as GetUserInfoResult; + try { + if (parsedUserDetails && parsedUserDetails.status === "OK") { + const res = await getUserEmailVerificationStatus(parsedUserDetails.user.loginMethods[0].recipeUserId); + if (res.status === "OK") { + setIsVerifyEmailFeatureEnabled(true); + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } catch (err: any) { + if (err.status === FEATURE_NOT_ENABLED_TEXT) { + setIsVerifyEmailFeatureEnabled(false); + } + } finally { + setUserDetail(parsedUserDetails); + } }, []); useEffect(() => { @@ -252,7 +270,10 @@ export const UserDetail: React.FC = (props) => { - +