+)
+
+let UserForm = props => {
const { t, i18n } = useTranslation();
- const { error, handleSubmit, submitting, initialValues, userType, history } = props;
+ const { error, handleSubmit, submitting, initialValues, sexIsMale, passwordTypeIsLink, passwordError, userType, history } = props;
const onCancel = useCallback(() => {
history.goBack();
@@ -100,7 +131,7 @@ const UserForm = props => {
{
- initialValues
+ initialValues.id
? {
size="max"
role={userType}
editing={true}
- editLabel={"Add photo"}
+ editLabel={t('Resource:AddPhoto')}
editAction={onEditAvatar}
/>
}
@@ -122,27 +153,70 @@ const UserForm = props => {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+ {t('Resource:Comments')}
+
{error && {error}}
@@ -155,8 +229,56 @@ const UserForm = props => {
)
}
-export default reduxForm({
+UserForm = reduxForm({
validate,
form: 'userForm',
enableReinitialize: true
})(withRouter(UserForm))
+
+const selector = formValueSelector('userForm')
+
+UserForm = connect(
+ state => {
+
+ const sexIsMale = selector(state, 'sex') == 'male';
+
+ const passwordTypeIsLink = selector(state, 'passwordType') == 'link';
+
+ const passwordValue = selector(state, 'password');
+
+ const passwordError = state &&
+ state.form &&
+ state.form.userForm &&
+ state.form.userForm.fields &&
+ state.form.userForm.fields.password &&
+ state.form.userForm.fields.password.touched &&
+ !passwordValue;
+
+ const fixDate = (name) => {
+ const workFromIsDate = state &&
+ state.form &&
+ state.form.userForm &&
+ state.form.userForm.values &&
+ state.form.userForm.values[name] &&
+ state.form.userForm.values[name] instanceof Date;
+
+ if(workFromIsDate)
+ {
+ let date = state.form.userForm.values[name];
+ let str = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toJSON()
+ state.form.userForm.values[name] = str;
+ }
+ }
+
+ fixDate("workFrom");
+ fixDate("birthDate");
+
+ return {
+ sexIsMale,
+ passwordTypeIsLink,
+ passwordError
+ }
+ }
+)(UserForm)
+
+export default UserForm
diff --git a/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/Form/validate.js b/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/Form/validate.js
index 448508225c..3d4f5d7a03 100644
--- a/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/Form/validate.js
+++ b/products/ASC.People/Client/src/components/pages/ProfileAction/Section/Body/Form/validate.js
@@ -2,15 +2,19 @@ function validate (values) {
const errors = {};
if (!values.firstName) {
- errors.firstName = 'required field';
+ errors.firstName = 'first name is required field';
}
if (!values.lastName) {
- errors.lastName = 'required field';
+ errors.lastName = 'last name is required field';
}
if (!values.email) {
- errors.email = 'required field';
+ errors.email = 'email is required field';
+ }
+
+ if (!values.password) {
+ errors.password = 'password is required field';
}
return errors