import React, { Component } from 'react';

import { AbstractForm } from 'lib/components';
import PaymentAccounts from 'components/PaymentAccounts';

import form from 'lib/form';
import { injectIntl } from 'react-intl';
import { updateIntl } from 'lib/i18n';
import { appLocales } from '../../config.js';


class PersonalSettings extends AbstractForm {


	componentDidMount() {
		let { data, setValues } = this.props;
		let signature = data.name;
		if (data.address) {
			signature += "\n\n" + data.address;
		}
		setValues("emailSignature", signature);
	}


	render() {
		let intl = this.props.intl;
		let formProps = { disabled: this.props.disabled };

		return (
			<div className={ `form ${this.props.className}` }>
				{ this.renderField("emailSenderAddress", intl.formatMessage({ id: "unit.entity.emailSenderAddress" }), formProps) }
				{ this.renderField("invoiceEmailSubject", intl.formatMessage({ id: "unit.entity.invoiceEmailSubject" }), formProps) }
				{ this.renderTextArea("emailSignature", intl.formatMessage({ id: "unit.entity.emailSignature" }), formProps) }
				{ this.renderField("invoiceThankYouNote", intl.formatMessage({ id: "unit.entity.invoiceThankYouNote" }), formProps) }
			</div>
		);
	}

}



export default form(injectIntl(PersonalSettings));