import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { connect } from "react-redux"; import { Field, change, reduxForm } from "redux-form"; import { useState } from "react"; import { bytesToSize, getThumbnailIconByExtension } from "../../utils"; import { FileUploadField, RenderPickList, RenderRichMultiline, } from "./representationElements"; import { useDropzone } from "react-dropzone"; // import { // setRepresentationCapacity, // setRepresentationSubmit, // } from "../../../store/currentView/action"; const RepAppellant = (props) => { let { t } = useTranslation(); const router = useRouter(); const { locale } = router; const { formObj, appellantApplicantRepresentationArr, setRepresentationCapacity, setRepresentationSubmit, currentView, setRepFileName, updateRepresentation, setSavingStatus, savingStatus, } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); setRepFileName(formObj.representationForm.values); let filterFilesList = props.currentView.caseReference.hasOwnProperty( "repDetails" ) ? props.currentView.caseReference.repDetails.hasOwnProperty("filesList") ? props.currentView.caseReference.repDetails.filesList.filter( function (el) { return el != null; } ) : [] : []; return ( <>
{typeof formObj.representationForm.values .representationType == "undefined" && props.representationType != "Select..." ? ( <>

{t( "myrepresentations:representation-from-an-appellant-heading" )}

) : ( )}
{(typeof props.representationType != "undefined" || typeof formObj.representationForm.values.representationType != "undefined") && (

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

{t("myrepresentations:comments-set-out-label")}:
{formObj.representationForm.values.appealType == "846040004" ? (

{t( "myrepresentations:questionnaire-publish-policy-label" )}{" "} https://gov.wales/planning-and-environment-decisions-wales-publishing-policy-html

) : (

{t( "myrepresentations:publish-policy-label" )}{" "} https://gov.wales/planning-and-environment-decisions-wales-publishing-policy-html

)}
{props.currentView.caseReference.hasOwnProperty( "repDetails" ) ? ( props.currentView.caseReference.repDetails.hasOwnProperty( "filesList" ) && props.currentView.caseReference.repDetails .filesList.length > 0 ? (
{filterFilesList.map((blob, i) => (
{blob.name} {blob.name} ( {bytesToSize(blob.size)})
))}
) : ( "" ) ) : ( "" )}
{" "}
)} {typeof formObj.representationForm.values.representationType != "undefined" && (
{/* {router.query.state != "edit" && ( { setRepresentationCapacity(); props.updateField( "representationForm", "representationType", "" ); }} className="govuk-link" > {t("common:back-link")} )} */} {savingStatus ? ( {router.locale == "cy" ? "Nôl data" : "Saving data"} { ) : ( )}
)} ); }; //const mapStateToProps = (state, props) => {}; const mapDispatchToProps = (dispatch) => ({ updateField: (form, field, newValue) => dispatch(change(form, field, newValue)), }); export default connect( null, mapDispatchToProps )( reduxForm({ form: "representationForm", enableReinitialize: true, destroyOnUnmount: false, })(RepAppellant) );