Merge branch '16314-test-user-db'
[arvados.git] / src / views / my-account-panel / my-account-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { RootState } from '~/store/store';
6 import { compose } from 'redux';
7 import { reduxForm, isPristine, isValid } from 'redux-form';
8 import { connect } from 'react-redux';
9 import { saveEditedUser } from '~/store/my-account/my-account-panel-actions';
10 import { MyAccountPanelRoot, MyAccountPanelRootDataProps } from '~/views/my-account-panel/my-account-panel-root';
11 import { MY_ACCOUNT_FORM } from "~/store/my-account/my-account-panel-actions";
12
13 const mapStateToProps = (state: RootState): MyAccountPanelRootDataProps => ({
14     isPristine: isPristine(MY_ACCOUNT_FORM)(state),
15     isValid: isValid(MY_ACCOUNT_FORM)(state),
16     initialValues: state.auth.user,
17     localCluster: state.auth.localCluster
18 });
19
20 export const MyAccountPanel = compose(
21     connect(mapStateToProps),
22     reduxForm({
23         form: MY_ACCOUNT_FORM,
24         onSubmit: (data, dispatch) => {
25             dispatch(saveEditedUser(data));
26         }
27     }))(MyAccountPanelRoot);