import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import md5 from 'md5'; import { toastSuccess, toastError } from '../../util/apiNotification'; import { createSubscribedElement } from '../UnstatedUtils'; import AppContainer from '../../services/AppContainer'; import PersonalContainer from '../../services/PersonalContainer'; class ProfileImageSettings extends React.Component { constructor(appContainer) { super(); this.onClickSubmit = this.onClickSubmit.bind(this); } async onClickSubmit() { const { t, personalContainer } = this.props; try { await personalContainer.updateProfileImage(); toastSuccess(t('toaster.update_successed', { target: t('Set Profile Image') })); } catch (err) { toastError(err); } } generateGravatarSrc() { const email = this.props.personalContainer.state.email || ''; const hash = md5(email.trim().toLowerCase()); return `https://gravatar.com/avatar/${hash}`; } render() { const { t, personalContainer } = this.props; return (

{ personalContainer.changeIsGravatarEnabled(true) }} />

{ personalContainer.changeIsGravatarEnabled(false) }} />

{/* TDOO GW-1198 uproad profile image */}
); } } const ProfileImageSettingsWrapper = (props) => { return createSubscribedElement(ProfileImageSettings, props, [AppContainer, PersonalContainer]); }; ProfileImageSettings.propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, personalContainer: PropTypes.instanceOf(PersonalContainer).isRequired, }; export default withTranslation()(ProfileImageSettingsWrapper);