import _ from "lodash";
import useTranslation from "next-translate/useTranslation";
import { useRouter } from "next/router";
import BuildField from "./buildfield";
import {
parseRowOuterHTML,
selectRowDataFieldContent,
selectRowDataFieldName,
selectRowDateEnd,
selectRowDateStart,
selectRowDocumentTypeCode,
selectRowFieldType,
selectRowHint,
selectRowLabelDescriptions,
selectRowMaxFieldLength,
selectRowMaxSubField,
selectRowParentField,
selectRowParentFieldShowOnValue,
selectRowRequiredDocumentLabel,
selectRowRequiredDocumentValue,
selectRowValidation
} from "../../lib/newappeal/formDerivation";
export default function BuildRow(props) {
let { t } = useTranslation();
const legacyProps = props.props;
const legacyPageProps = legacyProps.props;
const router = useRouter();
const { locale } = router;
const {
rowXML,
whichSection,
sectionCount,
onSubmit,
mandatoryFieldsData,
setUploadCount,
uploadCount,
setFileCount,
completedUploadFilesCount,
setCompletedUploadFilesCount
} = props;
return (
{Object.keys(rowXML).map((key, index) => {
var doc = parseRowOuterHTML(rowXML[key].outerHTML);
if (_.isEmpty(rowXML[key].innerHTML)) {
("");
} else {
var rows = selectRowLabelDescriptions(doc);
var fieldtype = selectRowFieldType(doc);
var validation = selectRowValidation(doc);
var maxFieldLength = selectRowMaxFieldLength(doc);
var maxSubField = selectRowMaxSubField(doc);
var datafieldname = selectRowDataFieldName(doc);
var datafieldcontent = selectRowDataFieldContent(doc);
var parentField = selectRowParentField(doc);
var parentFieldShowOnValue =
selectRowParentFieldShowOnValue(doc);
var requiredDocumentValue =
selectRowRequiredDocumentValue(doc);
var requiredDocumentLabel =
selectRowRequiredDocumentLabel(doc);
var documentTypeCode = selectRowDocumentTypeCode(doc);
var hint = selectRowHint(doc);
var dateStart = selectRowDateStart(doc);
var dateEnd = selectRowDateEnd(doc);
hint = !_.isEmpty(hint) && hint[0].value;
validation = !_.isEmpty(validation)
? validation[0].value
: [];
maxFieldLength =
!_.isEmpty(maxFieldLength) && maxFieldLength[0].value;
maxSubField =
!_.isEmpty(maxSubField) && maxSubField[0].value;
parentField =
!_.isEmpty(parentField) && parentField[0].value;
parentFieldShowOnValue =
!_.isEmpty(parentFieldShowOnValue) &&
parentFieldShowOnValue[0].value;
datafieldcontent =
!_.isEmpty(datafieldcontent) &&
datafieldcontent[0].value;
requiredDocumentValue =
!_.isEmpty(requiredDocumentValue) &&
requiredDocumentValue[0].value;
requiredDocumentLabel =
!_.isEmpty(requiredDocumentLabel) &&
requiredDocumentLabel[0].value;
documentTypeCode =
!_.isEmpty(documentTypeCode) &&
documentTypeCode[0].value;
dateStart = !_.isEmpty(dateStart) && dateStart[0].value;
dateEnd = !_.isEmpty(dateEnd) && dateEnd[0].value;
//const isRequiredField = jsonpath({path:
// "$..value[?(@ && @.LogicalName=='" +
// datafieldname[0].value +
// "')]",
// mandatoryFieldsData
// );
//console.log("build row datafieldname[0]", datafieldname[0]);
if (datafieldname[0].value == "pinswg_fileUpload") {
return (
);
} else {
//console.log(
// datafieldname[0].value,
// isRequiredField[0].RequiredLevel.Value
// );
// if (typeof isRequiredField[0] != "undefined") {
// if (
// isRequiredField[0].RequiredLevel.Value != "None"
// ) {
//console.log(datafieldname[0].value, validation);
return (
);
// } else {
// return null;
// }
// } else {
// return null;
// }
}
}
})}
);
}