import Link from "next/link"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { connect } from "react-redux"; import { Field, reduxForm, formValueSelector } from "redux-form"; import { RenderPickList, RenderTextfield, RenderRadioList, RenderMultiline, RenderCondtionalRadioList, RenderLPACondtionalRadioList, FileUploadField, RenderRichMultiline, RenderDatePicker, } from "./representationElements"; import { getFormCollectionByID, formatDates } from "../../utils"; import { setRepresentationCapacity, setRepresentationSubmit, } from "../../../store/currentView/action"; import { useDropzone } from "react-dropzone"; import { select } from "xpath"; import jsonpath from "jsonpath"; import { useState } from "react"; import Enforcement_Questionnaire from "./representationQuestionnaires/representationLPAQuestionnaire_enforcement"; import S78_Qquestionnaire from "./representationQuestionnaires/representationLPAQuestionnaire_s78"; import { RepresentationProgress_s78 } from "./representationProgress/representationProgress_s78"; import { RepresentationProgress_enforcement } from "./representationProgress/representationProgress_enforcement"; import transLookup from "../../../data/lookuptranslations.json"; let RepLPA = (props) => { let { t } = useTranslation(); const router = useRouter(); const { locale } = router; const { formObj, appellantApplicantRepresentationArr, setRepresentationCapacity, setRepresentationSubmit, currentView, procedureTypeValue, onBehalfOfLPA, setShowQuestionnaireSection, showQuestionnaireSection, } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); const files = acceptedFiles.map((file) => (
  • {file.path} - {file.size} bytes
  • )); const required = (value) => (value ? undefined : "Required"); const whichQuestionnaire = () => { { console.log("curr"); switch (currentView.caseReference.appealType) { case 846040000: case 846040001: case 846040006: case 846040025: case 846040004: case 846040018: case 846040003: case 846040009: case 846040008: return ( ); break; case 846040005: case 846040006: case 846040007: return ( ); break; default: return <>hello; break; } } }; const whichProgress = () => { { console.log("curr"); switch (currentView.caseReference.appealType) { case 846040000: case 846040001: case 846040006: case 846040025: case 846040004: case 846040018: case 846040003: case 846040009: case 846040008: return ( ); break; case 846040005: case 846040006: case 846040007: return ( ); break; default: return <>hello; break; } } }; let setCaseDetailsObj = router.query.hasOwnProperty("state") ? router.query.state == "edit" ? props.props.myRepresentations.myRepresentations : props.props.searchResultsObj.searchDetailsObj : props.props.searchResultsObj.searchDetailsObj; var detailsObj = {}; detailsObj = jsonpath.query( setCaseDetailsObj, '$..[?(@.pinswg_name=="' + currentView.caseReference.currentReference + '")]' ); let setCaseResultssObj = router.query.hasOwnProperty("state") ? router.query.state == "edit" ? props.props.myRepresentations.myRepresentations : props.props.searchResultsObj.searchResultsObj : props.props.searchResultsObj.searchResultsObj; detailsObj = detailsObj[0]; var resultsObj = {}; resultsObj = jsonpath.query( setCaseResultssObj, '$..[?(@.pinswg_name=="' + currentView.caseReference.currentReference + '")]' ); resultsObj = resultsObj[0]; //console.log(resultsObj, detailsObj); return ( <>

    {typeof props.representationType != "undefined" ? props.representationType == "Questionnaire" ? locale == "cy" ? "Holiadur" : props.representationType : props.representationType : locale == "cy" ? "Cynrychioliadau" : "Representation"}{" "} {locale == "cy" ? "o ACLI am a" : "from an LPA for a"}{" "} {locale == "cy" ? jsonpath.query( transLookup, '$..[?(@.attributevalue=="' + currentView.caseReference.appealType + '")].value_cy' ) : getFormCollectionByID( currentView.caseReference.appealType ).value}

    {typeof props.representationType == "undefined" && (
    )}
    {typeof props.representationType != "undefined" && (props.representationType != "Questionnaire" ? ( <>

    {t("myrepresentations:enter-comment-label")}

    {t( "myrepresentations:comments-set-out-label" )} :
    {" "}
    ) : ( whichQuestionnaire() ))}
    {" "}
    {typeof props.representationType != "undefined" && props.representationType == "Questionnaire" && ( <> {showQuestionnaireSection < 7 && ( { setShowQuestionnaireSection( showQuestionnaireSection + 1 ); }} className="govuk-button" > Next section )} {showQuestionnaireSection == 9 && ( )} {showQuestionnaireSection > 1 && ( { setShowQuestionnaireSection( showQuestionnaireSection - 1 ); }} className="govuk-link" > Back )} )}{" "} {typeof props.representationType != "undefined" && props.representationType != "Questionnaire" && ( <> {/* { setRepresentationSubmit(false); }} className="govuk-button" > {t("common:continue-button")} */} { //setRepresentationCapacity(); }} className="govuk-link" > {t("common:back-link")} )}
    ); }; const selector = formValueSelector("representationForm"); // <-- same as form name RepLPA = connect((state) => { const representationType = selector(state, "representationType"); const procedureType = selector(state, "procedureType"); return { procedureType, representationType, }; })(RepLPA); const mapStateToProps = (state, props) => { let initialValuesTemp = Object.assign( state.currentView.caseReference.hasOwnProperty("repDetails") ? state.currentView.caseReference.repDetails : state.currentView.caseReference, { "onBehalfOfLPA": props.props.props.accountDetails.accountDetails[ "pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue" ], } ); return { search: state.search, searchResultsObj: state.searchResultsObj, formData: state.formData, appealType: state.appealType, currentView: state.currentView, myRepresentations: state.myRepresentations, initialValues: initialValuesTemp, }; }; export default connect(mapStateToProps)( reduxForm({ form: "representationForm", enableReinitialize: true, destroyOnUnmount: false, })(RepLPA) );