import React from 'react'; import PropTypes from 'prop-types'; import { translate } from 'react-i18next'; import { Button, Label, Input, FormGroup, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; export class SettingsPopup extends React.Component { static propTypes = { hidePopup: PropTypes.func.isRequired, setErrorMsg: PropTypes.func.isRequired, changePassword: PropTypes.func.isRequired, errorMsg: PropTypes.string, t: PropTypes.func.isRequired }; constructor() { super(); this.state = { oldPassword: '', newPassword: '', confirmPassword: '' }; } hidePopup = () => { this.props.hidePopup(); this.props.setErrorMsg(null); }; onSubmit = () => { const { t } = this.props; const { oldPassword, newPassword, confirmPassword } = this.state; // need more validations if (!oldPassword || !newPassword || !confirmPassword) { return this.props.setErrorMsg(t('userSettings.enterRequiredFields')); } if (newPassword !== confirmPassword) { return this.props.setErrorMsg(t('userSettings.passwordsNotMatched')); } if (oldPassword && newPassword) { this.props.changePassword(newPassword, oldPassword); } }; handleChange = (e) => { const { name, value } = e.target; this.setState({ [name]: value }); }; render() { const { t, errorMsg } = this.props; return ( {t('userSettings.changePassword')}

{errorMsg}

); } } export default translate(['tabsContent', 'common'], { wait: true })( SettingsPopup );