import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { useState } from "react"; import { useDropzone } from "react-dropzone"; import { connect } from "react-redux"; import RepComplete from "./representationComplete"; import RepLPAQuestionnaireCheck_enforcement from "./representationQuestionnairesCheck/representationLPAQuestionnaireCheck_enforcement"; import RepLPAQuestionnaireCheck_s78 from "./representationQuestionnairesCheck/representationLPAQuestionnaireCheck_s78"; import { bytesToSize, getThumbnailIconByExtension } from "../../utils"; const RepCompleteSubmit = (props) => { let { t } = useTranslation(); const [confirmSections, setConfirmSections] = useState(false); const router = useRouter(); const { locale } = router; const { formObj, appellantApplicantRepresentationArr, setRepresentationCapacity, setRepresentationSubmit, currentView, setSubmitBack, setRepresentationSubmitConfirmation, setRepresentationMessageSent, setRepresentationReset, } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); const files = acceptedFiles.map((file) => (
  • {file.path} - {file.size} bytes
  • )); const repFormData = formObj.representationForm.values; //const repDate = new Date(); // let day = repDate.getDate(); // let month = repDate.getMonth() + 1; // let year = repDate.getFullYear(); // let repType = ""; // switch (repFormData.representationCapacity) { // case t("myrepresentations:capacity-options-arr-appellant"): // repType = "APP"; // break; // case t("myrepresentations:capacity-options-arr-agent"): // repType = "AGENT"; // break; // case t("myrepresentations:capacity-options-arr-interested"): // repType = "IP"; // break; // case "Land Owner": // repType = "LO"; // break; // case "lpa": // repType = "LPA"; // break; // default: // // code block // } // Object.assign(repFormData, { // "repfile_name": repFormData.hasOwnProperty("repfile_name") // ? repFormData.repfile_name // : year + // "-" + // month + // "-" + // day + // "-" + // repDate.getHours() + // repDate.getMinutes() + // repDate.getSeconds() + // "_" + // repType + // "_" + // props.props.props.accountDetails.accountDetails.lastname + // "_" + // props.props.props.accountDetails.accountDetails.firstname, // "pinswg_name": props.props.currentView.caseReference.currentReference, // "containerID": props.props.props.accountDetails.containerID, // "appealType": props.props.currentView.caseReference.appealType, // "incidentID": props.props.currentView.caseReference.incidentid, // "caseRef": props.props.currentView.caseReference.currentReference, // }); console.log("///////// repFormData:", repFormData); const whichQuestionnaireCheck = () => { { switch (currentView.caseReference.appealType) { case 846040000: case 846040001: case 846040006: case 846040025: case 846040004: case 846040018: case 846040003: case 846040009: case 846040008: case 846040017: return ( ); break; case 846040005: case 846040006: case 846040007: return ( ); break; default: return <>; break; } } }; let buildAppealFilesArray = []; // let filesUploadObj = // formObj.representationForm.values.representationDocuments; // for (let key in filesUploadObj) { // typeof filesUploadObj[key].name != "undefined" && // buildAppealFilesArray.push({ // "name": filesUploadObj[key].name, // "size": filesUploadObj[key].size, // }); // } // console.log( // buildAppealFilesArray, // formObj.representationForm.values.filesList // ); buildAppealFilesArray = formObj.representationForm.values.hasOwnProperty( "filesList" ) ? formObj.representationForm.values.filesList : []; console.log(buildAppealFilesArray); // const arrUniq = [ // ...new Map(buildAppealFilesArray.map((v) => [v.name, v])).values(), // ]; // buildAppealFilesArray = buildAppealFilesArray.filter(function (el) { // return el != null; // }); // const arrUniq = buildAppealFilesArray.filter( // (obj1, i, arr) => arr.findIndex((obj2) => obj2.name === obj1.name) === i // ); // console.log(arrUniq); // Object.assign(formObj.representationForm.values, { // "filesList": arrUniq, // }); let filterFiles = []; return ( <> {currentView.representationSubmitConfirmation == true ? ( ) : (

    {" "} {t( "myrepresentations:rep-check-submit-heading" )}

    {t( "myrepresentations:rep-check-your-rep-heading" )}

    {t( "case:representation-representation-type" )}
    {router.locale == "cy" ? repFormData.representationType == "Questionnaire" ? "Holiadur" : repFormData.representationType == "Statement" ? "Datganiad" : repFormData.representationType == "Final comments" ? "Sylwadau terfynol" : repFormData.representationType : repFormData.representationType}
    { setSubmitBack(); }} > {t("common:change-link-label")} {" "} {/* {FieldsTranslations( rows[0].value )} */}
    {_.has( repFormData, "representationOnBehalfOf" ) && ( <>
    {t( "case:representation-onbehalfof" )}
    { repFormData.representationOnBehalfOf }
    { setSubmitBack(); }} > {t( "common:change-link-label" )} {" "} {/* {FieldsTranslations( rows[0].value )} */}
    {repFormData.representationOnBehalfOf == "Yes" && (
    {t( "case:representation-onbehalfof-details" )}
    { repFormData.representationOnBehalfOf_details }
    { setSubmitBack(); }} > {t( "common:change-link-label" )} {" "} {/* {FieldsTranslations( rows[0].value )} */}
    )} )}
    {t("case:representation-files")}
    {buildAppealFilesArray.length > 0 ? buildAppealFilesArray.map( (blob, i) => (
    {blob.name} {blob.name} ( {bytesToSize( blob.size )} )
    ) ) : ""}
    { setSubmitBack(); }} > {t("common:change-link-label")} {" "} {/* {FieldsTranslations( rows[0].value )} */}
    {whichQuestionnaireCheck()}

    {t( "myrepresentations:rep-check-tandc-para-one" )}

    {t( "myrepresentations:rep-check-tandc-para-two" )}

    {t( "myrepresentations:rep-check-tandc-para-three" )}

    { setConfirmSections( !confirmSections ); }} />
    {/* */}
    {/* { setRepresentationSubmit(false); }} className="govuk-button" > {t("common:continue-button")} */} setSubmitBack()} className="govuk-link" > {t("case:summary-back-button-label")}
    )} ); }; const mapStateToProps = (state) => { return { search: state.search, searchResultsObj: state.searchResultsObj, formData: state.formData, appealType: state.appealType, currentView: state.currentView, myRepresentations: state.myRepresentations, initialValues: state.currentView.caseReference.repDetails, accountDetails: state.accountDetails, //form: state.form, }; }; const mapDispatchToProps = (dispatch) => { return {}; }; export default connect(mapStateToProps, mapDispatchToProps)(RepCompleteSubmit);