import _ from "lodash"; import React, { useState } 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 { Textfield, DateField, DateFieldPicker, YesNofield, PickList, MultiLinefield, NumericField, ReadOnlyfield, DecimalField, } from "../elements"; 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 } = props; let { t, lang } = useTranslation(); const router = useRouter(); const { locale } = router; let errorsobj = {}; const onHandleSubmit = (values) => { console.log(values); }; const required = (value) => (value ? undefined : "Is required"); const matchInput = (input, allInputs) => { return input === allInputs.password ? undefined : "Passwords do not match"; }; const email = (value) => value && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value) ? "Invalid email address" : undefined; const phoneNumber = (value) => value && !/^(?:(?:\(?(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?(?:\(?0\)?[\s-]?)?)|(?:\(?0))(?:(?:\d{5}\)?[\s-]?\d{4,5})|(?:\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3}))|(?:\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4})|(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}))(?:[\s-]?(?:x|ext\.?|\#)\d{3,4})?$/i.test( value ) ? "Invalid phone number" : undefined; const [hasErrors, setHasErrors] = useState(""); return ( <> {/* {hasErrors == true ? ( ) : ( "" )} */}
); }; const mapStateToProps = (state) => { return { search: state.search, searchResultsObj: state.searchResultsObj, formData: state.formData, appealType: state.appealType, //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) );