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, setFilesForRepresentations, } 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, setFilesForRepresentations, } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); console.log(JSON.stringify(formObj) == "{}" ? "empty" : "value"); if (JSON.stringify(formObj) != "{}") { 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; } ) : [] : []; filterFilesList = filterFilesList.filter( (value, index, self) => index === self.findIndex((t) => t.name === value.name) ); 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:publish-policy-label" )}{" "} {t( "myrepresentations:publish-policy-link-label" )} {" "} {t( "myrepresentations:publish-policy-label-two" )}

) : (

{t( "myrepresentations:publish-policy-label" )}{" "} {t( "myrepresentations:publish-policy-link-label" )} {" "} {t( "myrepresentations:publish-policy-label-two" )}

)}
0 // ? props.currentView // .caseReference // .repDetails.filesList // : [] // : [] } setFilesForRepresentations={ setFilesForRepresentations } containerID={ props.props.props.accountDetails .containerID } filenamePrefix={props.formObj} props={props.props.props} setCurrentReference={ props.setCurrentReference } />
{" "}
)} {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) => { return { updateField: (form, field, newValue) => dispatch(change(form, field, newValue)), setFilesForRepresentations: (fileList) => { dispatch(setFilesForRepresentations(fileList)); }, }; }; export default connect( null, mapDispatchToProps )( reduxForm({ form: "representationForm", enableReinitialize: true, destroyOnUnmount: false, })(RepAppellant) );