import React, { useEffect } from "react"; import styled from "styled-components"; import { Toaster, Text, TextType } from "design-system"; import { debounce } from "lodash"; import { TextInput, notEmptyValidator } from "design-system"; import { useDispatch, useSelector } from "react-redux"; import { Classes } from "@blueprintjs/core"; import { getCurrentUser } from "selectors/usersSelectors"; import { forgotPasswordSubmitHandler } from "pages/UserAuth/helpers"; import { Variant } from "components/ads/common"; import { FORGOT_PASSWORD_SUCCESS_TEXT, createMessage, } from "@appsmith/constants/messages"; import { logoutUser, updateUserDetails } from "actions/userActions"; import { AppState } from "@appsmith/reducers"; import UserProfileImagePicker from "./UserProfileImagePicker"; import { Wrapper, FieldWrapper, LabelWrapper, Loader, TextLoader, } from "./StyledComponents"; import { getCurrentUser as refreshCurrentUser } from "actions/authActions"; import { getAppsmithConfigs } from "@appsmith/configs"; import { ANONYMOUS_USERNAME } from "constants/userConstants"; const { disableLoginForm } = getAppsmithConfigs(); const ForgotPassword = styled.a` margin-top: 12px; border-bottom: 1px solid transparent; &:hover { cursor: pointer; text-decoration: none; } display: inline-block; `; function General() { const user = useSelector(getCurrentUser); const dispatch = useDispatch(); const forgotPassword = async () => { try { await forgotPasswordSubmitHandler({ email: user?.email }, dispatch); Toaster.show({ text: createMessage(FORGOT_PASSWORD_SUCCESS_TEXT, user?.email), variant: Variant.success, }); dispatch(logoutUser()); } catch (error) { Toaster.show({ text: (error as { _error: string })._error, variant: Variant.success, }); } }; const timeout = 1000; const onNameChange = debounce((newName: string) => { dispatch( updateUserDetails({ name: newName, }), ); }, timeout); const isFetchingUser = useSelector( (state: AppState) => state.ui.users.loadingStates.fetchingUser, ); useEffect(() => { dispatch(refreshCurrentUser()); }, []); if (user?.email === ANONYMOUS_USERNAME) return null; return ( Display Picture Display name {isFetchingUser && } {!isFetchingUser && (
)}
Email
{isFetchingUser && } {!isFetchingUser && {user?.email}} {!disableLoginForm && ( Reset Password )}
{/* Website null} defaultValue={""} cypressSelector="t--profile-website" /> */}
); } export default General;