import Link from "next/link"; import { connect } from "react-redux"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { Field, reduxForm, change } from "redux-form"; import { RenderPickList, RenderTextfield, RenderRadioList, RenderMultiline, RenderRichMultiline, RenderCondtionalRadioList, FileUploadField, } from "./representationElements"; import { getFormCollectionByID, getThumbnailIconByExtension, bytesToSize, } from "../../utils"; import { useDropzone } from "react-dropzone"; const RepAgent = (props) => { let { t } = useTranslation(); const router = useRouter(); const { locale } = router; const { formObj, appellantApplicantRepresentationArr, setRepresentationCapacity, setRepresentationSubmit, currentView, setRepFileName, } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); setRepFileName(formObj.representationForm.values); const files = acceptedFiles.map((file) => (
  • {file.path} - {file.size} bytes
  • )); const required = (value) => (value ? undefined : "Required"); return ( <>
    {typeof formObj.representationForm.values .representationType == "undefined" && props.representationType != "Select..." ? ( <>

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

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

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

    {t( "myrepresentations:comments-set-out-label" )} :

    {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 .filesList.length > 0 ? (
    {props.currentView.caseReference.repDetails.filesList.map( (blob, i) => (
    {blob.name} {blob.name} ( {bytesToSize(blob.size)} )
    ) )}
    ) : ( "" )}
    {" "}
    )} {typeof formObj.representationForm.values.representationType != "undefined" && (
    { setRepresentationCapacity(); props.updateField( "representationForm", "representationCapacity", "" ); }} className="govuk-link" > {t("common:back-link")}
    )} ); }; const mapDispatchToProps = (dispatch) => ({ updateField: (form, field, newValue) => dispatch(change(form, field, newValue)), }); export default connect( null, mapDispatchToProps )( reduxForm({ form: "representationForm", enableReinitialize: true, destroyOnUnmount: false, })(RepAgent) );