Send new user data to server
[arvados-workbench2.git] / src / views / my-account-panel / my-account-panel.tsx
index 508a4c7ecea3a4686b90f373fc92cf6971020df6..03caa887a1466bac4402bcf1bd8f73167d420bee 100644 (file)
@@ -3,16 +3,23 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { RootState } from '~/store/store';
-import { Dispatch } from 'redux';
+import { compose } from 'redux';
+import { reduxForm, isPristine, isValid } from 'redux-form';
 import { connect } from 'react-redux';
-import { MyAccountPanelRoot, MyAccountPanelRootDataProps, MyAccountPanelRootActionProps } from '~/views/my-account-panel/my-account-panel-root';
+import { saveEditedUser } from '~/store/my-account/my-account-panel-actions';
+import { MyAccountPanelRoot, MyAccountPanelRootDataProps, MY_ACCOUNT_FORM } from '~/views/my-account-panel/my-account-panel-root';
 
 const mapStateToProps = (state: RootState): MyAccountPanelRootDataProps => ({
-    user: state.auth.user
+    isPristine: isPristine(MY_ACCOUNT_FORM)(state),
+    isValid: isValid(MY_ACCOUNT_FORM)(state),
+    initialValues: state.auth.user
 });
 
-const mapDispatchToProps = (dispatch: Dispatch): MyAccountPanelRootActionProps => ({
-
-});
-
-export const MyAccountPanel = connect(mapStateToProps, mapDispatchToProps)(MyAccountPanelRoot);
\ No newline at end of file
+export const MyAccountPanel = compose(
+    connect(mapStateToProps),
+    reduxForm({
+    form: MY_ACCOUNT_FORM,
+    onSubmit: (data, dispatch) => {
+        dispatch(saveEditedUser(data));
+    }
+}))(MyAccountPanelRoot);
\ No newline at end of file