import { JSONPath as jsonpath } from "jsonpath-plus";
import useTranslation from "next-translate/useTranslation";
import { useRouter } from "next/router";
import { useDropzone } from "react-dropzone";
import { connect } from "react-redux";
import { Field, formValueSelector, reduxForm } from "redux-form";
import { getFormCollectionByID } from "../../../../components/utils";
import {
FileUploadField,
RenderDatePicker,
RenderLPACondtionalRadioList,
RenderMultiline,
RenderPickList,
RenderRadioList,
RenderRichMultiline,
RenderTextfield,
} from "../representationElements";
import {
setRepresentationCapacity,
setRepresentationSubmit,
setFilesForRepresentations,
} from "../../../../store/currentView/action";
let Enforcement_Questionnaire = (props) => {
let { t } = useTranslation();
const router = useRouter();
const { locale } = router;
const {
formObj,
appellantApplicantRepresentationArr,
setRepresentationCapacity,
setRepresentationSubmit,
currentView,
procedureTypeValue,
onBehalfOfLPA,
showQuestionnaireSection,
setFilesForRepresentations,
} = props;
const { acceptedFiles, getRootProps, getInputProps } = useDropzone();
const files = acceptedFiles.map((file) => (
{file.path} - {file.size} bytes
));
const required = (value) => (value ? undefined : "Required");
let setCaseDetailsObj = router.query.hasOwnProperty("state")
? router.query.state == "edit"
? props.props.myRepresentations.myRepresentations
: currentView.caseReference.currentType == "watchedCases"
? props.props.watchedCases.watchedCasesDetails
: props.props.searchResultsObj.searchDetailsObj
: currentView.caseReference.currentType == "watchedCases"
? props.props.watchedCases.watchedCasesDetails
: props.props.searchResultsObj.searchDetailsObj;
var detailsObj = {};
detailsObj = jsonpath({
path:
'$..[?(@ && @.pinswg_name=="' +
currentView.caseReference.currentReference +
'")]',
json: setCaseDetailsObj,
eval: true,
});
let setCaseResultssObj = router.query.hasOwnProperty("state")
? router.query.state == "edit"
? props.props.myRepresentations.myRepresentations
: currentView.caseReference.currentType == "watchedCases"
? props.props.watchedCases.watchedCases
: props.props.searchResultsObj.searchResultsObj
: currentView.caseReference.currentType == "watchedCases"
? props.props.watchedCases.watchedCases
: props.props.searchResultsObj.searchResultsObj;
detailsObj = detailsObj[0];
var resultsObj = {};
resultsObj = jsonpath({
path:
'$..[?(@ && @.ticketnumber=="' +
currentView.caseReference.currentReference +
'")]',
json: setCaseResultssObj,
eval: true,
});
resultsObj = resultsObj[0];
return (
<>
{showQuestionnaireSection == 1 && (
)}{" "}
{showQuestionnaireSection == 2 && (
)}{" "}
{showQuestionnaireSection == 3 && (
)}{" "}
{showQuestionnaireSection == 4 && (
)}{" "}
{showQuestionnaireSection == 5 && (
)}{" "}
{showQuestionnaireSection == 6 && (
)}{" "}
{showQuestionnaireSection == 7 && (
)}{" "}
{showQuestionnaireSection == 8 && (
)}
{showQuestionnaireSection == 9 && (
)}
>
);
};
//export default Enforcement_Questionnaire;
const selector = formValueSelector("representationForm"); // <-- same as form name
Enforcement_Questionnaire = connect((state) => {
const representationTypeValue = selector(state, "representationType");
const procedureTypeValue = selector(state, "procedureType");
return {
procedureTypeValue,
representationTypeValue,
};
})(Enforcement_Questionnaire);
const mapDispatchToProps = (dispatch) => {
return {
updateField: (form, field, newValue) =>
dispatch(change(form, field, newValue)),
setFilesForRepresentations: (fileList) => {
dispatch(setFilesForRepresentations(fileList));
},
};
};
const mapStateToProps = (state, props) => {
return {
search: state.search,
searchResultsObj: state.searchResultsObj,
formData: state.formData,
appealType: state.appealType,
currentView: state.currentView,
myRepresentations: state.myRepresentations,
initialValues: state.currentView.caseReference.repDetails,
};
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(
reduxForm({
form: "representationForm",
enableReinitialize: false,
destroyOnUnmount: false,
})(Enforcement_Questionnaire)
);