{"size": 1747, "ext": "js", "max_stars_repo_path": "containers/entrance/ResetPasswordPage/index.js", "max_stars_repo_name": "thegoodparty/tgp-webapp", "max_stars_repo_stars_event_min_datetime": "2020-10-15T05:27:45.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-04T00:50:24.000Z", "max_issues_repo_path": "containers/entrance/ResetPasswordPage/index.js", "max_issues_repo_name": "thegoodparty/tgp-webapp", "max_issues_repo_issues_event_min_datetime": "2020-04-07T05:58:41.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-11T05:08:29.000Z", "max_forks_repo_path": "containers/entrance/ResetPasswordPage/index.js", "max_forks_repo_name": "thegoodparty/tgp-webapp", "max_forks_repo_forks_event_min_datetime": "2021-02-20T05:21:04.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-09T20:50:04.000Z"}
{"max_stars_count": 2, "max_issues_count": 10, "max_forks_count": 2, "avg_line_length": 24.9571428571, "max_line_length": 77, "alphanum_fraction": 0.7132226674}
/**
 *
 * ResetPasswordPage
 *
 */

import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { createStructuredSelector } from 'reselect';
import { useInjectSaga } from 'utils/injectSaga';
import { makeSelectLocation } from 'containers/App/selectors';
import queryHelper from 'helpers/queryHelper';

import ResetPasswordWrapper from 'components/entrance/ResetPasswordWrapper';
import TgpHelmet from 'components/shared/TgpHelmet';
import actions from './actions';
import saga from './saga';

export function ResetPasswordPage({ locationState, resetPasswordCallback }) {
  useInjectSaga({ key: 'user', saga });

  const { search } = locationState;
  const email = queryHelper(search, 'email');
  const phone = queryHelper(search, 'phone');
  const token = queryHelper(search, 'token');

  const childProps = {
    email,
    phone,
    token,
    resetPasswordCallback,
  };
  return (
    <div>
      <TgpHelmet
        title="Reset your password | Good Party"
        description="Reset your password for your Good Party account"
      />
      <ResetPasswordWrapper {...childProps} />
    </div>
  );
}

ResetPasswordPage.propTypes = {
  locationState: PropTypes.object,
  resetPasswordCallback: PropTypes.func,
};

function mapDispatchToProps(dispatch) {
  return {
    dispatch,
    resetPasswordCallback: (email, phone, password, token) => {
      dispatch(actions.resetPasswordAction(email, phone, password, token));
    },
  };
}

const mapStateToProps = createStructuredSelector({
  locationState: makeSelectLocation(),
});

const withConnect = connect(
  mapStateToProps,
  mapDispatchToProps,
);

export default compose(withConnect)(ResetPasswordPage);
