import Link from "next/link"; import _, { has } from "lodash"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { useState, useEffect } from "react"; import xpath from "xpath"; import BuildRow from "./buildrow"; import { reduxForm, formValueSelector, getFormSubmitErrors } from "redux-form"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; import { setCaseReference, setCurrentSection, } from "../../store/appealType/action"; import { query } from "jsonpath"; let BuildSection = (props) => { // useEffect(() => { // window.scrollTo(0, 0); // }); let { t } = useTranslation(); const router = useRouter(); const { locale } = router; const { formXML, sectionCount, onSubmit, handleSubmit, formTitle, setCurrentSection, refno, gotoSection, mandatoryFieldsData, } = props; const currentSection = props.appealType.currentSection; const parser = new DOMParser(); var doc = parser.parseFromString(props.formXML, "text/xml"); // var titles = xpath.select( // "//form/tabs/tab[" + currentSection + " ]/labels/label/@description", // doc // ); var rowXML = xpath.select( // "/form/tabs/tab[" + // currentSection + // "]/columns//sections/section/rows/row", "/form/tabs/tab/columns//sections/section/rows/row", doc ); var titleList = xpath.select( "//form/tabs/tab[*]/labels/label/@description", doc ); const handleParam = (setValue) => (e) => setValue(e.target.value); const onHandleSubmit = (values) => { setCurrentSection(currentSection + 1); }; const [hasErrors, setHasErrors] = useState(""); const getErrors = () => { let errorsobj = props.props.form["appealForm"]; setHasErrors(errorsobj.hasOwnProperty("syncErrors")); window.scrollTo(0, 0); }; let errorsobj = {}; const ShowErrorHeader = (props) => { errorsobj = props.props.appealForm.syncErrors; errorsobj = _.keys(errorsobj); const getErrorLabel = (whichField) => { var doc = parser.parseFromString(props.formXML, "text/xml"); var errorFieldLabel = xpath.select( "//*[control/@id='" + whichField + "']//@description", doc ); return errorFieldLabel[0].value; }; const ShowErrors = () => { let errorList = []; for (let i = 0; i < errorsobj.length; ++i) { //get label from error key - search rowxml for id = errorobj errorList.push(