import Link from "next/link"; import _ from "lodash"; import React, { useState, useEffect } from "react"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { Field, reduxForm, formValueSelector, getFormSubmitErrors, } from "redux-form"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; import { updatePassword } from "../../actions"; const RenderTextfield = ({ id, className, rows, datafieldname, name, label, input, type, errorMsg, meta: { touched, error }, ...custom }) => { return ( <>
{touched && error && ( Error:{" "} {touched && ((error && ( {errorMsg ? errorMsg : error} )) || (warning && {warning}))} )}
); }; const ChangePassword = (props) => { const { footerLinks, pages, handleSubmit, value, setPasswordUpdated, passwordUpdated, } = props; let { t, lang } = useTranslation(); const router = useRouter(); const { locale } = router; let errorsobj = {}; const onHandleSubmit = (values) => { let contactid = props.props.accountDetails.loggedinUserId; let updateBody = props.props.form.changepasswordForm.values.newpassword; console.log(contactid, updateBody); updatePassword(contactid, updateBody); setPasswordUpdated(true); }; const required = (value) => (value ? undefined : "Is required"); const passwordsMustMatch = (value, allValues) => value !== allValues.newpassword ? "Passwords do not match" : undefined; const minLength = (min) => (value) => value && value.length < min ? `Must be at least ${min} characters` : undefined; const [hasErrors, setHasErrors] = useState(""); return <> {passwordUpdated != true ? (
Cancel
) : ( <>

Go to My Portal

)} ; }; const mapStateToProps = (state) => { return { search: state.search, searchResultsObj: state.searchResultsObj, formData: state.formData, appealType: state.appealType, accountDetails: state.accountDetails, //form: state.form, }; }; const mapDispatchToProps = (dispatch) => { return { setCurrentSection: (currentSection) => { dispatch(setCurrentSection(currentSection)); }, }; }; const selector = formValueSelector("changepasswordForm"); // <-- same as form name export default connect( mapStateToProps, mapDispatchToProps )( reduxForm({ form: "changepasswordForm", destroyOnUnmount: false, })(ChangePassword) );