// 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 } from '~/views/my-account-panel/my-account-panel-root';
+import { MY_ACCOUNT_FORM } from "~/store/my-account/my-account-panel-actions";
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