diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 5df1aaf2..3508ff40 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -1,13 +1,12 @@ import { JSONPath as jsonpath } from "jsonpath-plus"; -import _ from "lodash"; import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import { useDropzone } from "react-dropzone"; import { connect } from "react-redux"; import { formValueSelector, reduxForm } from "redux-form"; -import { signIn, useSession } from "next-auth/react"; +import { useSession } from "next-auth/react"; import { generateRepPDF, sendEmail, uploadRepFiles } from "../../../actions"; import { formatDates, updateLinks } from "../../../components/utils"; import { @@ -17,14 +16,14 @@ import { setRepresentationSubmit, setRepresentationSubmitConfirmation, } from "../../../store/currentView/action"; +import ConsultationAgent from "./consultationAgent"; +import ConsultationAppellant from "./consultationAppellant"; +import ConsultationInterestedPartyPerson from "./consultationInterestedPartyPerson"; import RepAgent from "./representationAgent"; import RepAppellant from "./representationAppellant"; -import ConsultationAppellant from "./consultationAppellant"; -import ConsultationAgent from "./consultationAgent"; import RepCapacitySelection from "./representationCapacitySelection"; import RepCompleteSubmit from "./representationCompleteSubmit"; import RepInterestedPartyPerson from "./representationInterestedPartyPerson"; -import ConsultationInterestedPartyPerson from "./consultationInterestedPartyPerson"; import RepLPA from "./representationLPA"; import RepLPACapacitySelection from "./representationLPACapacitySelection"; @@ -76,28 +75,21 @@ let MakeRepresentation = (props) => { const caseReferenceObj = props.props.currentView.caseReference; const updateQuestionnaireCount = () => { - { - switch (appealType) { - case 846040000: - case 846040001: - case 846040025: - case 846040004: - case 846040018: - case 846040003: - case 846040009: - case 846040008: - return 7; - break; - case 846040005: - case 846040006: - case 846040007: - return 9; - break; - default: - return 7; - break; - } - } + const countMap = { + 846040000: 7, + 846040001: 7, + 846040025: 7, + 846040004: 7, + 846040018: 7, + 846040003: 7, + 846040009: 7, + 846040008: 7, + 846040005: 9, + 846040006: 9, + 846040007: 9, + }; + + return countMap[appealType] || 7; }; let questionnaireCount = updateQuestionnaireCount(); @@ -109,147 +101,91 @@ let MakeRepresentation = (props) => { ? true : false; - // const isNRW = accountDetails.emailaddress1.includes( - // "@cyfoethnaturiolcymru.gov.uk" - // ) - // ? true - // : false; - const isNRW = currentView.caseReference?.isNRW; const setRepFileName = (values) => { - //console.log("---------------\n", values); if ( - values.hasOwnProperty("representationCapacity") && - values.hasOwnProperty("representationType") + !values.hasOwnProperty("representationCapacity") || + !values.hasOwnProperty("representationType") ) { - let repType = ""; - let repCap = ""; - - const repDate = new Date(); - - let day = ("0" + repDate.getDate()).slice(-2); - let month = ("0" + (repDate.getMonth() + 1)).slice(-2); - let year = repDate.getFullYear(); - - switch (values.representationCapacity) { - case t("myrepresentations:capacity-options-arr-appellant"): - repCap = "APP"; - break; - case t("myrepresentations:capacity-options-arr-agent"): - repCap = "APP"; //set as App even tho agent as is from an appeallant by proxy - break; - case t("myrepresentations:capacity-options-arr-interested"): - repCap = "IP"; - break; - case "Land Owner": - repCap = "LO"; - break; - case "lpa": - case "LPA": - repCap = "LPA"; - case "NRW": - repCap = "NRW"; - break; - - default: - // code block - } - switch (values.representationType) { - case "Statement": - repType = "Statement"; - break; - case "Statement of common ground": - repType = "SCG"; - break; - case "Written statement": - repType = "WS"; - break; - case "Written statement of evidence": - repType = "WSE"; - break; - case "Questionnaire": - repType = "Questionnaire"; - break; - case "Final comments": - repType = "Comments"; - break; - case "Consultation Response": - repType = "Consultation_Response"; - break; - case "Local Impact Report": - repType = "Local_Impact_Report"; - break; - case "Marine Impact Report": - repType = "Marine_Impact_Report"; - break; - - case "Other": - repType = "OTHER"; - break; - - default: - // code block - } - Object.assign(values, { - "repfile_name": values.hasOwnProperty("repfile_name") - ? values.repfile_name - : year + - "-" + - month + - "-" + - day + - "-" + - ("0" + repDate.getHours()).slice(-2) + - ":" + - ("0" + repDate.getMinutes()).slice(-2) + - ":" + - ("0" + repDate.getSeconds()).slice(-2) + - "_-_" + - repCap + - "_-_" + - repType + - "_-_" + - (isLPA - ? values.onBehalfOfLPA.replace( - /[\s~`!@#$%^&*(){}\[\];:"'<,.>?\/\\|_+=-]/g, - "" - ) - : values.lastname.replace( - /[\s~`!@#$%^&*(){}\[\];:"'<,.>?\/\\|_+=-]/g, - "" - ) + - "_" + - values.firstname.replace( - /[\s~`!@#$%^&*(){}\[\];:"'<,.>?\/\\|_+=-]/g, - "" - )), - }); + return values; } + const repCapMap = { + [t("myrepresentations:capacity-options-arr-appellant")]: "APP", + [t("myrepresentations:capacity-options-arr-agent")]: "APP", // agent treated as appellant proxy + [t("myrepresentations:capacity-options-arr-interested")]: "IP", + "Land Owner": "LO", + lpa: "LPA", + LPA: "LPA", + NRW: "NRW", + }; + + const repTypeMap = { + Statement: "Statement", + "Statement of common ground": "SCG", + "Written statement": "WS", + "Written statement of evidence": "WSE", + Questionnaire: "Questionnaire", + "Final comments": "Comments", + "Consultation Response": "Consultation_Response", + "Local Impact Report": "Local_Impact_Report", + "Marine Impact Report": "Marine_Impact_Report", + Other: "OTHER", + }; + + const now = new Date(); + const pad = (num) => String(num).padStart(2, "0"); + + const dateStr = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad( + now.getDate() + )}-${pad(now.getHours())}:${pad(now.getMinutes())}:${pad( + now.getSeconds() + )}`; + + const repCap = repCapMap[values.representationCapacity] || ""; + const repType = repTypeMap[values.representationType] || ""; + + const sanitize = (str) => + str.replace(/[\s~`!@#$%^&*(){}\[\];:"'<,.>?\/\\|_+=-]/g, ""); + + const namePart = isLPA + ? sanitize(values.onBehalfOfLPA || "") + : `${sanitize(values.lastname || "")}_${sanitize( + values.firstname || "" + )}`; + + values.repfile_name = + values.repfile_name || + `${dateStr}_-_${repCap}_-_${repType}_-_${namePart}`; + return values; }; isLPA && setRepresentationCapacity("LPA"); - currentType == "searchResultsObj" - ? (casesObj = jsonpath({ - path: '$..[?(@ && @.title=="' + caseReference + '")]', - json: setCaseQueryObj, - eval: true, - })) - : currentType == "watchedCases" - ? (casesObj = jsonpath({ - path: '$..[?(@ && @.ticketnumber=="' + caseReference + '")]', - json: watchedCases, - eval: true, - })) - : (casesObj = jsonpath({ - path: '$..[?(@ && @.reference=="' + caseReference + '")]', - json: setCaseQueryObj, - eval: true, - })); + const getCasePath = () => { + switch (currentType) { + case "searchResultsObj": + return { + path: `$..[?(@ && @.title=="${caseReference}")]`, + json: setCaseQueryObj, + }; + case "watchedCases": + return { + path: `$..[?(@ && @.ticketnumber=="${caseReference}")]`, + json: watchedCases, + }; + default: + return { + path: `$..[?(@ && @.reference=="${caseReference}")]`, + json: setCaseQueryObj, + }; + } + }; + const { path, json } = getCasePath(); + casesObj = jsonpath({ path, json, eval: true }); casesObj = Object.assign({}, ...casesObj); var detailsObj = {}; @@ -259,559 +195,399 @@ let MakeRepresentation = (props) => { t("myrepresentations:capacity-options-arr-agent"), ]; - appealType != 846040017 - ? capacityOptionsArr.push( - t("myrepresentations:capacity-options-arr-interested") - ) - : caseReferenceObj.specialistProcess != 846040000 && - capacityOptionsArr.push( - t("myrepresentations:capacity-options-arr-interested") - ); + const shouldIncludeInterested = + appealType !== 846040017 || + caseReferenceObj.specialistProcess !== 846040000; - let setCaseDetailsObj = router.query.hasOwnProperty("state") - ? router.query.state == "edit" - ? props.props.myRepresentations.myRepresentations - : props.props.searchResultsObj.searchDetailsObj - : props.currentType == "watchedCases" - ? props.props.watchedCases.watchedCasesDetails - : props.props.searchResultsObj.searchDetailsObj; + if (shouldIncludeInterested) { + capacityOptionsArr.push( + t("myrepresentations:capacity-options-arr-interested") + ); + } - let setCaseResultsObj = router.query.hasOwnProperty("state") - ? router.query.state == "edit" - ? props.props.myRepresentations.myRepresentations - : props.props.searchResultsObj.searchResultsObj - : props.currentType == "watchedCases" - ? props.props.watchedCases.watchedCasesDetails - : props.props.searchResultsObj.searchResultsObj; + const isEditState = router.query.state === "edit"; + const hasState = router.query.hasOwnProperty("state"); - var detailsObj = {}; + const getCaseDetailsObj = () => { + if (hasState) { + return isEditState + ? props.props.myRepresentations.myRepresentations + : props.props.searchResultsObj.searchDetailsObj; + } + return props.currentType === "watchedCases" + ? props.props.watchedCases.watchedCasesDetails + : props.props.searchResultsObj.searchDetailsObj; + }; - var resultsObj = {}; + const getCaseResultsObj = () => { + if (hasState) { + return isEditState + ? props.props.myRepresentations.myRepresentations + : props.props.searchResultsObj.searchResultsObj; + } + return props.currentType === "watchedCases" + ? props.props.watchedCases.watchedCasesDetails + : props.props.searchResultsObj.searchResultsObj; + }; - resultsObj = jsonpath({ - path: - '$..[?(@ && @.ticketnumber=="' + - currentView.caseReference.currentReference + - '")]', + const setCaseDetailsObj = getCaseDetailsObj(); + const setCaseResultsObj = getCaseResultsObj(); + + let resultsObj = jsonpath({ + path: `$..[?(@ && @.ticketnumber=="${currentView.caseReference.currentReference}")]`, json: setCaseResultsObj, eval: true, - }); + })[0]; - resultsObj = resultsObj[0]; + // let detailsObj; - detailsObj = router.query.hasOwnProperty("state") - ? router.query.state == "edit" - ? jsonpath({ - path: - '$..[?(@ && @.repfile_name =="' + - router.query.created + - '")]', - json: setCaseDetailsObj, - eval: true, - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_name =="' + - currentView.caseReference.currentReference + - '")]', - json: setCaseDetailsObj, - eval: true, - }) - : jsonpath({ - path: - '$..[?(@ && @.pinswg_name =="' + - currentView.caseReference.currentReference + - '")]', - json: setCaseDetailsObj, - eval: true, - }); - - detailsObj = detailsObj[0]; + if (hasState && isEditState) { + detailsObj = jsonpath({ + path: `$..[?(@ && @.repfile_name=="${router.query.created}")]`, + json: setCaseDetailsObj, + eval: true, + })[0]; + } else { + detailsObj = jsonpath({ + path: `$..[?(@ && @.pinswg_name=="${currentView.caseReference.currentReference}")]`, + json: setCaseDetailsObj, + eval: true, + })[0]; + } const buildRepsArr = (detailsObj) => { - let buildArr = []; + const buildArr = []; + const todaysDate = new Date(); - // console.log(appealType, ""); + const isDNS = appealType === 846040011; + const isSIPS = appealType === 846040002; - let todaysDate = new Date(); + // Determine key dates based on appeal type + const startDate = new Date( + isDNS + ? detailsObj.pinswg_applicationacceptedasvalid + : detailsObj.pinswg_startdate || detailsObj.pinswg_startdates + ); - const isDNS = appealType == 846040011; + const questionnaireDate = new Date( + isDNS + ? detailsObj.pinswg_endofrepresentationperiod + : detailsObj.pinswg_questionnaireduedate + ); + questionnaireDate.setHours(23, 59, 59, 999); - const isSIPS = appealType == 846040002; + const finalCommentsDate = new Date( + isDNS + ? detailsObj.pinswg_endofrepresentationperiod + : detailsObj.pinswg_finalcommentsduedate + ); + finalCommentsDate.setHours(23, 59, 59, 999); - let startDate; - let questionnaireDate; - let finalCommentsDate; - let statementDueDate; + const statementDueDate = new Date( + isDNS + ? detailsObj.pinswg_endofrepresentationperiod + : detailsObj.pinswg_statementduedate || + detailsObj.pinswg_statementsduedate + ); + statementDueDate.setHours(23, 59, 59, 999); - isDNS - ? ((startDate = new Date( - detailsObj.pinswg_applicationacceptedasvalid - )), - (questionnaireDate = new Date( - new Date( - detailsObj.pinswg_endofrepresentationperiod - ).setHours(23, 59, 59, 999) - )), - (finalCommentsDate = new Date( - new Date( - detailsObj.pinswg_endofrepresentationperiod - ).setHours(23, 59, 59, 999) - )), - (statementDueDate = new Date( - new Date( - detailsObj.pinswg_endofrepresentationperiod - ).setHours(23, 59, 59, 999) - ))) - : ((startDate = new Date( - detailsObj.pinswg_startdate || detailsObj.pinswg_startdates - )), - (questionnaireDate = new Date( - new Date(detailsObj.pinswg_questionnaireduedate).setHours( - 23, - 59, - 59, - 999 - ) - )), - (finalCommentsDate = new Date( - new Date(detailsObj.pinswg_finalcommentsduedate).setHours( - 23, - 59, - 59, - 999 - ) - )), - (statementDueDate = new Date( - new Date( - detailsObj.pinswg_statementduedate || - detailsObj.pinswg_statementsduedate - ).setHours(23, 59, 59, 999) - ))); + // Shared condition + const isWithin = (start, end) => + todaysDate >= start && todaysDate <= end; + const notAppeal = (...types) => !types.includes(appealType); - isLPA && - appealType != 846040019 && - appealType != 846040011 && - appealType != 846040015 && - appealType != 846040016 && - todaysDate >= startDate && - todaysDate <= finalCommentsDate && + // Questionnaire + if ( + isLPA && + notAppeal(846040019, 846040011, 846040015, 846040016) && + isWithin(startDate, finalCommentsDate) + ) { buildArr.push("Questionnaire"); + } - isLPA && + // DNS LPA Documents + if ( + isLPA && isDNS && - appealType != 846040019 && - todaysDate >= startDate && - todaysDate <= finalCommentsDate && - buildArr.push("Local Impact Report"); + appealType !== 846040019 && + isWithin(startDate, finalCommentsDate) + ) { + buildArr.push("Local Impact Report", "Statement"); + } - isLPA && - isDNS && - appealType != 846040019 && - todaysDate >= startDate && - todaysDate <= finalCommentsDate && + // Non-DNS Statement + if ( + !isDNS && + appealType !== 846040004 && + isWithin(startDate, statementDueDate) + ) { buildArr.push("Statement"); + } - !isDNS && - appealType != 846040004 && - todaysDate >= startDate && - todaysDate <= statementDueDate && + // DNS Non-LPA Statement + if (isDNS && !isLPA && isWithin(startDate, statementDueDate)) { buildArr.push("Statement"); + } - isDNS && - !isLPA && - todaysDate >= startDate && - todaysDate <= statementDueDate && - buildArr.push("Statement"); + // Final Comments + const isSpecialistNonHearing = + currentView.caseReference.specialistProcess !== 846040001; - (appealType != 846040004 || - (appealType == 846040015 && - currentView.caseReference.specialistProcess != 846040001)) && - todaysDate >= statementDueDate && - todaysDate <= finalCommentsDate && + if ( + (appealType !== 846040004 || + (appealType === 846040015 && isSpecialistNonHearing)) && + isWithin(statementDueDate, finalCommentsDate) + ) { buildArr.push("Final comments"); + } - appealType == 846040004 && - currentView.caseReference.specialistProcess != 846040001 && - todaysDate >= statementDueDate && - todaysDate <= finalCommentsDate && + if ( + appealType === 846040004 && + isSpecialistNonHearing && + isWithin(statementDueDate, finalCommentsDate) + ) { buildArr.push("Final comments"); + } - //is LPA Advert part 3 no statement - isLPA && - appealType == 846040018 && - currentView.caseReference.specialistProcess == 846040000 && - buildArr.pop("Statements"); + // Remove "Statement" for LPA Advert Part 3 (no statement) + if ( + isLPA && + appealType === 846040018 && + currentView.caseReference.specialistProcess === 846040000 + ) { + const index = buildArr.indexOf("Statement"); + if (index !== -1) buildArr.splice(index, 1); + } - //console.log("is this a sip......", isSIPS, !isLPA); + // SIPS-related documents + if (isSIPS) { + const capacity = repCapacityType(); + if (capacity === "appellant") { + buildArr.push("Consultation Response"); + } else { + buildArr.push("Consultation Response", "Local Impact Report"); + } - isSIPS && buildArr.push("Consultation Response"); - isSIPS && buildArr.push("Local Impact Report"); - isSIPS && isNRW && buildArr.push("Marine Impact Report"); + if (isNRW) { + buildArr.push("Marine Impact Report"); + } + } return buildArr; }; const repCapacityType = () => { - return _.isEmpty(formObj["representationForm"]) - ? false - : _.isEmpty(formObj["representationForm"].values) - ? false - : _.isEmpty( - formObj["representationForm"].values.representationCapacity - ) - ? false - : formObj["representationForm"].values.representationCapacity - .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") - .toLowerCase(); + const repForm = formObj["representationForm"]; + if ( + !repForm || + !repForm.values || + !repForm.values.representationCapacity + ) { + return false; + } + + return repForm.values.representationCapacity + .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") + .toLowerCase(); }; const whichControl = () => { - let SipsOrRep; + const commonProps = { + formObj, + setRepresentationCapacity, + setRepresentationSubmit, + onHandleSubmit, + currentView, + setSubmitBack, + props, + setRepFileName, + updateRepresentation, + setSavingStatus, + savingStatus, + setCurrentReference, + }; + + const getNormalizedCapacity = () => { + const rawCapacity = + currentView.representationCapacity || + currentView.caseReference?.repDetails?.representationCapacity || + "false"; + return rawCapacity.toLowerCase(); + }; + if ( isLPA && - _.isEmpty(currentView.representationCapacity) - // || - // (isLPA && - // currentView.caseReference.hasOwnProperty("repDetails") && - // !currentView.caseReference.repDetails.representationCapacity) + (!currentView.representationCapacity || + currentView.representationCapacity === "") ) { return ( - //setRepresentationCapacity("LPA"), ); - } else { - switch ( - ( - currentView.representationCapacity || - (currentView.caseReference.hasOwnProperty("repDetails") && - currentView.caseReference.repDetails - .representationCapacity) || - "false" - ).toLowerCase() - ) { - case false: + } + + const capacity = getNormalizedCapacity(); + + switch (capacity) { + case "appellant": + case "apelydd": + case "apelydd": + case t( + "myrepresentations:capacity-options-arr-appellant" + ).toLowerCase(): { + const Component = + appealType === 846040002 + ? ConsultationAppellant + : RepAppellant; + return ( + + ); + } + + case "lpa": + case "lpa": { + return ( + + ); + } + + case "agent": + case "asiant": + case "asiant": + case t( + "myrepresentations:capacity-options-arr-agent" + ).toLowerCase(): { + const Component = + appealType === 846040002 ? ConsultationAgent : RepAgent; + return ( + + ); + } + + case "interestedparty": + case t( + "myrepresentations:capacity-options-arr-interested" + ).toLowerCase(): { + const Component = + appealType === 846040002 + ? ConsultationInterestedPartyPerson + : RepInterestedPartyPerson; + return ( + + ); + } + + case "landowner": { + return ( + + ); + } + + default: + return ( ; - break; - case "appellant": - case "apelydd": - case "Apelydd": - case t( - "myrepresentations:capacity-options-arr-appellant" - ).toLocaleLowerCase(): - //setRepresentationCapacity("appellant"); - - SipsOrRep = - appealType == 846040002 - ? ConsultationAppellant - : RepAppellant; - return ( - - ); - break; - case "lpa": - case "LPA": - //setRepresentationCapacity("appellant"); - //setRepresentationCapacity("LPA"); - // useEffect(() => { - // setRepresentationCapacity("LPA"); - // }, []); - - console.log(appealType); - return ( - - ); - break; - case "agent": - case "Asiant": - case "asiant": - case t( - "myrepresentations:capacity-options-arr-agent" - ).toLowerCase(): - //setRepresentationCapacity("agent"); - - SipsOrRep = - appealType == 846040002 ? ConsultationAgent : RepAgent; - - return ( - - ); - break; - case "interestedparty": - case t( - "myrepresentations:capacity-options-arr-interested" - ).toLowerCase(): - // setRepresentationCapacity("interestedpartyperson"); - - SipsOrRep = - appealType == 846040002 - ? ConsultationInterestedPartyPerson - : RepInterestedPartyPerson; - - return ( - - ); - break; - case "landowner": - //setRepresentationCapacity("landowner"); - return ( - - ); - break; - default: - return ( - - ); - } + /> + ); } }; const whichProgress = () => { - { - switch (appealType) { - case 846040000: - case 846040001: - case 846040025: - case 846040004: - case 846040018: - case 846040003: - case 846040009: - case 846040008: - case 846040017: - return ( - - ); - break; + const commonProps = { + props, + containerID: props.props.accountDetails.containerID, + currentView, + showQuestionnaireSection, + setShowQuestionnaireSection, + questionnaireCount, + }; - case 846040005: - case 846040006: - case 846040007: - return ( - - ); - break; - default: - return <>; - break; - } + const s78AppealTypes = [ + 846040000, 846040001, 846040025, 846040004, 846040018, 846040003, + 846040009, 846040008, 846040017, + ]; + + const enforcementAppealTypes = [846040005, 846040006, 846040007]; + + if (s78AppealTypes.includes(appealType)) { + return ; } + + if (enforcementAppealTypes.includes(appealType)) { + return ; + } + + return <>; }; const sortFileObj = (filelistObj) => { - let blobList = filelistObj; + const cleanArray = (arr) => + arr + .filter((obj) => obj !== null) + .filter((obj) => Object.keys(obj).length > 0) + .filter((obj) => obj.name !== undefined); - function removeNullObjects(arr) { - return arr.filter((obj) => obj !== null); - } - - function removeObjectsWithUndefinedKey(arr, key) { - return arr.filter((obj) => obj[key] !== undefined); - } - - function removeEmptyObjects(arr) { - return arr.filter((obj) => Object.keys(obj).length > 0); - } - - blobList = removeNullObjects(blobList); - blobList = removeEmptyObjects(blobList); - blobList = removeObjectsWithUndefinedKey(blobList, "name"); - - let buildAppealFilesArray = []; - - let filesUploadObj = field.input.value; - - for (let key in filesUploadObj) { - typeof filesUploadObj[key].name != "undefined" && - buildAppealFilesArray.push({ - "name": filesUploadObj[key].name, - "size": filesUploadObj[key].size, - }); - } - - buildAppealFilesArray = buildAppealFilesArray.concat(blobList); - - function removeDuplicates(arr) { + const deduplicate = (arr) => { const seen = new Set(); return arr.filter((obj) => { - const serializedObj = JSON.stringify(obj); - if (seen.has(serializedObj)) { - return false; // Skip this object (duplicate) - } - seen.add(serializedObj); // Add the serialized object to the "seen" set - return true; // Keep this object + const serialized = JSON.stringify(obj); + if (seen.has(serialized)) return false; + seen.add(serialized); + return true; }); - } + }; - buildAppealFilesArray = removeDuplicates(buildAppealFilesArray); + const extractFilesFromField = (filesObj) => { + return Object.values(filesObj).reduce((acc, file) => { + if (file?.name) { + acc.push({ name: file.name, size: file.size }); + } + return acc; + }, []); + }; - blobList = buildAppealFilesArray; + const cleanedBlobList = cleanArray(filelistObj); + const extractedFiles = extractFilesFromField(field.input.value); + const mergedFiles = [...extractedFiles, ...cleanedBlobList]; - return blobList; + return deduplicate(mergedFiles); }; const updateRepresentation = async ( @@ -819,57 +595,88 @@ let MakeRepresentation = (props) => { sendSavedEmail, useSaveStatus ) => { - let incidentId = props.appealType.caseReference.incidentid; - let updateBody = values || {}; - const buildFileArray = []; - let newbuildArr = []; + const { + appealType: appealTypeProp, + currentView, + accountDetails, + loggedinUserEmail, + } = props.props; + const incidentID = props.appealType.caseReference.incidentid; + const currentRef = caseReferenceObj.currentReference; + const containerID = accountDetails.containerID; setSavingStatus(useSaveStatus); - Object.assign(values, { - "containerID": props.props.accountDetails.containerID, - "appealType": appealType || caseReferenceObj.repDetails.appealType, - "incidentID": + const getSiteAddress = () => { + const { + pinswg_siteaddressline1, + pinswg_siteaddressline2, + pinswg_siteaddresstown, + pinswg_siteaddresspostcode, + } = detailsObj; + return [ + pinswg_siteaddressline1, + pinswg_siteaddressline2, + pinswg_siteaddresstown, + pinswg_siteaddresspostcode, + ] + .filter(Boolean) + .join(" "); + }; + + const getRepresentationCapacity = () => { + if ( + router.query.hasOwnProperty("state") && + router.query.state === "edit" + ) { + return currentView.representationCapacity; + } + return isLPA ? "LPA" : values.representationCapacity; + }; + + const baseBody = { + containerID, + appealType: appealType || caseReferenceObj.repDetails.appealType, + incidentID: caseReferenceObj.incidentid || caseReferenceObj.repDetails.incidentid, - "caseRef": caseReferenceObj.currentReference, - "casereference": caseReferenceObj.currentReference, - "pinswg_questionnaireduedate": - detailsObj.pinswg_questionnaireduedate, - "pinswg_statementduedate": + caseRef: currentRef, + casereference: currentRef, + pinswg_questionnaireduedate: detailsObj.pinswg_questionnaireduedate, + pinswg_statementduedate: detailsObj.pinswg_statementduedate || detailsObj.pinswg_endofrepresentationperiod, - "pinswg_statementsduedate": + pinswg_statementsduedate: detailsObj.pinswg_statementsduedate || detailsObj.pinswg_endofrepresentationperiod, - "pinswg_finalcommentsduedate": + pinswg_finalcommentsduedate: detailsObj.pinswg_finalcommentsduedate || detailsObj.pinswg_endofrepresentationperiod, - "pinswg_name": caseReferenceObj.currentReference, - "firstname": accountDetails.firstname, - "lastname": accountDetails.lastname, - "emailAddress": accountDetails.emailaddress1, - "siteAddress": - detailsObj.pinswg_siteaddressline1 + - (detailsObj.pinswg_siteaddressline2 != null - ? " " + detailsObj.pinswg_siteaddressline2 + " " - : " ") + - detailsObj.pinswg_siteaddresstown + - " " + - detailsObj.pinswg_siteaddresspostcode, - "pinswg_siteaddressline1": detailsObj.pinswg_siteaddressline1, - "pinswg_siteaddressline2": detailsObj.pinswg_siteaddressline2, - "pinswg_siteaddresstown": detailsObj.pinswg_siteaddresstown, - "pinswg_siteaddresspostcode": detailsObj.pinswg_siteaddresspostcode, - "pinswg_lpareference": resultsObj?.pinswg_lpareference, - "_pinswg_appellant_value": detailsObj["_pinswg_appellant_value"], + pinswg_name: currentRef, + firstname: accountDetails.firstname, + lastname: accountDetails.lastname, + emailAddress: accountDetails.emailaddress1, + siteAddress: getSiteAddress(), + pinswg_siteaddressline1: detailsObj.pinswg_siteaddressline1, + pinswg_siteaddressline2: detailsObj.pinswg_siteaddressline2, + pinswg_siteaddresstown: detailsObj.pinswg_siteaddresstown, + pinswg_siteaddresspostcode: detailsObj.pinswg_siteaddresspostcode, + pinswg_lpareference: resultsObj?.pinswg_lpareference, + representationCapacity: getRepresentationCapacity(), + locale: router.locale, + }; + + const formattedValues = { + ...values, + ...baseBody, + _pinswg_appellant_value: detailsObj._pinswg_appellant_value, "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue": detailsObj[ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue" ], - "_pinswg_localplanningauthority_value": - detailsObj["_pinswg_localplanningauthority_value"] || - detailsObj["_pinswg_associatedlpa_value"], + _pinswg_localplanningauthority_value: + detailsObj._pinswg_localplanningauthority_value || + detailsObj._pinswg_associatedlpa_value, "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue": detailsObj[ "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" @@ -877,175 +684,174 @@ let MakeRepresentation = (props) => { detailsObj[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ], - "representationCapacity": router.query.hasOwnProperty("state") - ? router.query.state == "edit" - ? props.props.currentView.representationCapacity - : values.representationCapacity - : isLPA - ? "LPA" - : values.representationCapacity, - "locale": router.locale, - }); - - // "pinswg_name": "2022-11-29-IP-REP_BOND_1", - - updateBody = setRepFileName(values); - - Object.assign(updateBody, { - "pinswg_name": caseReferenceObj.currentReference, - "containerID": props.props.accountDetails.containerID, - "appealType": appealType || caseReferenceObj.repDetails.appealType, - "casereference": caseReferenceObj.currentReference, - "incidentID": - caseReferenceObj.incidentid || - caseReferenceObj.repDetails.incidentid, - "caseRef": caseReferenceObj.currentReference, - }); - - updateBody = JSON.stringify(updateBody); - updateBody = updateBody.replace(/:"Yes"/gm, `:true`); - updateBody = updateBody.replace(/:"No"/gm, `:false`); - updateBody = JSON.parse(updateBody); - - Object.keys(updateBody).forEach((key) => { - if (updateBody[key] === null) { - delete updateBody[key]; - } - if (key.indexOf("_") == 0) { - delete updateBody[key]; - } - }); - - const reference = "PEDW-PARTIAL-REP"; - const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75"; - const emailAddress = props.props.accountDetails.loggedinUserEmail; - const personalisation = { - "caseReference": props.caseReference, - "emailAddress": props.props.accountDetails.loggedinUserEmail, - "returnLink": "", - "linkExpiry": 10 * 60, }; - props.currentView.representationSubmit == "true" - ? (sendSavedEmail == true && - sendEmail( - templateId, - emailAddress, - personalisation, - reference - ), - useSaveStatus && - router.replace( - router.locale != "en" - ? "/" + router.locale + "/fymhorth" - : "/myportal" - )) - : useSaveStatus - ? (Object.assign(values, { - "filesList": props.currentView.fileList, - }), - (values = updateLinks(values)), - uploadRepresentationFiles(values), - router.replace( - router.locale != "en" - ? "/" + router.locale + "/fymhorth" - : "/myportal" - )) - : Object.assign(values, { - "filesList": props.currentView.fileList, - }), - console.log("Rep Updated - ", props.caseReference), - (values = updateLinks(values)), - uploadRepresentationFiles(values); + let updateBody = setRepFileName(formattedValues); + + // Clean and sanitize the body + const sanitizedBody = Object.entries(updateBody).reduce( + (acc, [key, val]) => { + if (val !== null && val !== undefined && !key.startsWith("_")) { + acc[key] = val; + } + return acc; + }, + {} + ); + + // Normalize "Yes"/"No" to booleans + const stringified = JSON.stringify(sanitizedBody) + .replace(/:"Yes"/g, ":true") + .replace(/:"No"/g, ":false"); + updateBody = JSON.parse(stringified); + + const sendEmailIfNeeded = () => { + if (sendSavedEmail) { + const reference = "PEDW-PARTIAL-REP"; + const templateId = "021b0a7b-df00-41f1-b94e-c269bee98c75"; + const personalisation = { + caseReference: props.caseReference, + emailAddress: loggedinUserEmail, + returnLink: "", + linkExpiry: 600, // 10 minutes + }; + sendEmail( + templateId, + loggedinUserEmail, + personalisation, + reference + ); + } + }; + + const redirectToPortal = () => { + const base = + router.locale !== "en" + ? `/${router.locale}/fymhorth` + : "/myportal"; + router.replace(base); + }; + + const handleFileUpload = () => { + const filesWithLinks = updateLinks({ + ...values, + filesList: currentView.fileList, + }); + uploadRepresentationFiles(filesWithLinks); + }; + + const isSubmitted = currentView.representationSubmit === "true"; + + if (isSubmitted) { + sendEmailIfNeeded(); + if (useSaveStatus) redirectToPortal(); + } else { + handleFileUpload(); + if (useSaveStatus) { + redirectToPortal(); + } + } + + console.log("Rep Updated - ", props.caseReference); }; const onHandleSubmit = (values) => { values = setRepFileName(values); - //console.log("onHandleSubmit form values - ", JSON.stringify(values)); + // Determine case data source + const getCaseDetailsSource = () => { + if (router.query?.state === "edit") { + return props.props.myRepresentations.myRepresentations; + } + return props.currentType === "watchedCases" + ? props.props.watchedCases.watchedCasesDetails + : props.props.searchResultsObj.searchDetailsObj; + }; - const buildFileArray = []; + const setCaseDetailsObj = getCaseDetailsSource(); - //console.log("attached docs: - ", buildFileArray); - - let setCaseDetailsObj = router.query.hasOwnProperty("state") - ? router.query.state == "edit" - ? props.props.myRepresentations.myRepresentations - : props.props.searchResultsObj.searchDetailsObj - : props.currentType == "watchedCases" - ? props.props.watchedCases.watchedCasesDetails - : props.props.searchResultsObj.searchDetailsObj; - - router.query.hasOwnProperty("state") && - router.query.state == "edit" && - setRepresentationSubmit(false); - - var detailsObj = {}; - - detailsObj = jsonpath({ - path: '$..[?(@ && @.pinswg_name=="' + caseReference + '")]', + // Find correct case details + let detailsObj = jsonpath({ + path: `$..[?(@ && @.pinswg_name=="${caseReference}")]`, json: setCaseDetailsObj, eval: true, - }); + })[0]; - detailsObj = detailsObj[0]; + // Cancel submit status if editing + if (router.query?.state === "edit") { + setRepresentationSubmit(false); + } - // console.log( - // "Has data from form:", - // formObj.hasOwnProperty("representationForm") && - // formObj.representationForm.hasOwnProperty("values") - // ); + // If it's a new form and has values, enrich payload + if ( + formObj?.representationForm?.values && + !router.query.hasOwnProperty("state") + ) { + const formValues = formObj.representationForm.values; + + const buildSiteAddress = () => { + const { + pinswg_siteaddressline1, + pinswg_siteaddressline2, + pinswg_siteaddresstown, + pinswg_siteaddresspostcode, + } = detailsObj; + return [ + pinswg_siteaddressline1, + pinswg_siteaddressline2, + pinswg_siteaddresstown, + pinswg_siteaddresspostcode, + ] + .filter(Boolean) + .join(" "); + }; + + const representationCapacity = + router.query?.state === "edit" + ? props.props.currentView.representationCapacity + : isLPA + ? "LPA" + : values.representationCapacity; - formObj.hasOwnProperty("representationForm") && - !router.query.hasOwnProperty("state") && - formObj.representationForm.hasOwnProperty("values") && - (Object.assign(values, formObj.representationForm.values), Object.assign(values, { - "containerID": props.props.accountDetails.containerID, - "appealType": + ...formValues, + containerID: props.props.accountDetails.containerID, + appealType: appealType || caseReferenceObj.repDetails.appealType, - "incidentID": + incidentID: caseReferenceObj.incidentid || caseReferenceObj.repDetails.incidentid, - "caseRef": caseReferenceObj.currentReference, - "casereference": caseReferenceObj.currentReference, - "pinswg_questionnaireduedate": + caseRef: caseReferenceObj.currentReference, + casereference: caseReferenceObj.currentReference, + pinswg_questionnaireduedate: detailsObj.pinswg_questionnaireduedate, - "pinswg_endofrepresentationperiod": + pinswg_endofrepresentationperiod: detailsObj.pinswg_endofrepresentationperiod, - "pinswg_applicationacceptedasvalid": + pinswg_applicationacceptedasvalid: detailsObj.pinswg_applicationacceptedasvalid, - "pinswg_statementduedate": detailsObj.pinswg_statementduedate, - "pinswg_statementsduedate": detailsObj.pinswg_statementsduedate, - "pinswg_finalcommentsduedate": + pinswg_statementduedate: detailsObj.pinswg_statementduedate, + pinswg_statementsduedate: detailsObj.pinswg_statementsduedate, + pinswg_finalcommentsduedate: detailsObj.pinswg_finalcommentsduedate, - "pinswg_name": caseReferenceObj.currentReference, - "firstname": accountDetails.firstname, - "lastname": accountDetails.lastname, - "emailAddress": accountDetails.emailaddress1, - "siteAddress": - detailsObj.pinswg_siteaddressline1 + - (detailsObj.pinswg_siteaddressline2 != null - ? " " + detailsObj.pinswg_siteaddressline2 + " " - : " ") + - detailsObj.pinswg_siteaddresstown + - " " + + pinswg_name: caseReferenceObj.currentReference, + firstname: accountDetails.firstname, + lastname: accountDetails.lastname, + emailAddress: accountDetails.emailaddress1, + siteAddress: buildSiteAddress(), + pinswg_siteaddressline1: detailsObj.pinswg_siteaddressline1, + pinswg_siteaddressline2: detailsObj.pinswg_siteaddressline2, + pinswg_siteaddresstown: detailsObj.pinswg_siteaddresstown, + pinswg_siteaddresspostcode: detailsObj.pinswg_siteaddresspostcode, - "pinswg_siteaddressline1": detailsObj.pinswg_siteaddressline1, - "pinswg_siteaddressline2": detailsObj.pinswg_siteaddressline2, - "pinswg_siteaddresstown": detailsObj.pinswg_siteaddresstown, - "pinswg_siteaddresspostcode": - detailsObj.pinswg_siteaddresspostcode, - "pinswg_lpareference": resultsObj?.pinswg_lpareference, - "_pinswg_appellant_value": - detailsObj["_pinswg_appellant_value"], + pinswg_lpareference: resultsObj?.pinswg_lpareference, + _pinswg_appellant_value: detailsObj._pinswg_appellant_value, "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue": detailsObj[ "_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue" ], - "_pinswg_localplanningauthority_value": - detailsObj["_pinswg_localplanningauthority_value"] || - detailsObj["_pinswg_associatedlpa_value"], + _pinswg_localplanningauthority_value: + detailsObj._pinswg_localplanningauthority_value || + detailsObj._pinswg_associatedlpa_value, "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue": detailsObj[ "_pinswg_localplanningauthority_value@OData.Community.Display.V1.FormattedValue" @@ -1053,31 +859,31 @@ let MakeRepresentation = (props) => { detailsObj[ "_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue" ], - "representationCapacity": router.query.hasOwnProperty("state") - ? router.query.state == "edit" - ? props.props.currentView.representationCapacity - : values.representationCapacity - : isLPA - ? "LPA" - : values.representationCapacity, - "locale": router.locale, - })); + representationCapacity, + locale: router.locale, + }); + } - if (currentView.representationSubmit != true) { - if (_.isEmpty(currentView.representationCapacity)) { - if (isLPA) { - setRepresentationCapacity("LPA"); - } else { - setRepresentationCapacity( - values.representationCapacity - .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") - .toLowerCase() - ); - } + const shouldSubmit = !currentView.representationSubmit; + + if (shouldSubmit) { + const hasNoCapacity = + !currentView.representationCapacity || + currentView.representationCapacity === ""; + + const repType = values.representationType; + + if (hasNoCapacity) { + const capacity = isLPA + ? "LPA" + : values.representationCapacity + .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") + .toLowerCase(); + setRepresentationCapacity(capacity); } else { - if (values.representationType == "Questionnaire") { + if (repType === "Questionnaire") { if ( - questionnaireCount != 0 && + questionnaireCount !== 0 && showQuestionnaireSection < questionnaireCount ) { setShowQuestionnaireSection( @@ -1093,126 +899,162 @@ let MakeRepresentation = (props) => { setRepresentationSubmit(true); } } + window.scrollTo({ top: 0, behavior: "smooth" }); } else { - if (currentView.representationSubmit == true) { - console.log("capacity", currentView.representationCapacity); - console.log("has errors:", props.invalid); - Object.assign(values, { - "locale": router.locale, - "repComplete": currentView.caseReference.currentReference, - }); - props.invalid == false && - updateRepresentation(values, false, false); - // values.hasOwnProperty("representationDocuments") && - // (values.representationDocuments.map((Blob) => - // buildFileArray.push({ - // "name": Blob.name, - // "size": Blob.size, - // }) - // ), - // Object.assign(values, { - // "filesList": buildFileArray, - // })), - // console.log( - // "====================== rep lpa payload:\n", - // JSON.stringify(values) - // ); - setFinaliseAppealProcess(true); - generateRepPDF( - values, - props.props.accountDetails.containerID, - currentView.caseReference.currentReference - ).then((data) => { - console.log(data); - data.status == "success" && - ((values = updateLinks(values)), - uploadRepresentationFiles(values), - setRepresentationSubmit(true), - setRepresentationSubmitConfirmation(true)); - }); - } else { - console.log("not updated"); + // Already submitted + console.log("capacity", currentView.representationCapacity); + console.log("has errors:", props.invalid); + + Object.assign(values, { + locale: router.locale, + repComplete: currentView.caseReference.currentReference, + }); + + if (props.invalid === false) { + updateRepresentation(values, false, false); } + + // Final PDF & upload + setFinaliseAppealProcess(true); + generateRepPDF( + values, + props.props.accountDetails.containerID, + currentView.caseReference.currentReference + ).then((data) => { + if (data.status === "success") { + values = updateLinks(values); + uploadRepresentationFiles(values); + setRepresentationSubmit(true); + setRepresentationSubmitConfirmation(true); + } + }); } }; const cleanFilesList = (blobList) => { - let newblobList = blobList.filesList; - function removeNullObjects(arr) { - if (arr.length === 0) { - return arr; - } - return arr.filter((obj) => obj !== null); - } + const cleanedFiles = (blobList.filesList || []) + .filter((file) => file !== null) + .filter( + (file) => + file && + typeof file === "object" && + Object.keys(file).length > 0 + ) + .filter((file) => file.name !== undefined); - function removeObjectsWithUndefinedKey(arr, key) { - if (arr.length === 0) { - return arr; - } - return arr.filter((obj) => obj[key] !== undefined); - } - - function removeEmptyObjects(arr) { - if (arr.length === 0) { - return arr; - } - return arr.filter( - (obj) => - obj && - typeof obj === "object" && - Object.keys(obj).length > 0 - ); - } - - newblobList = removeNullObjects(newblobList); - newblobList = removeEmptyObjects(newblobList); - newblobList = removeObjectsWithUndefinedKey(newblobList, "name"); - - Object.assign(blobList, { - "filesList": newblobList, - }); - - return blobList; + return { + ...blobList, + filesList: cleanedFiles, + }; }; const uploadRepresentationFiles = (values) => { - values = values.hasOwnProperty("filesList") + // Clean files list if present + const cleanedValues = values.hasOwnProperty("filesList") ? cleanFilesList(values) : values; - // get filelists from values object - let fileListObj = _.filter(values, function (v, key) { - return _.includes(key, "representationDocuments"); - }); - // console.log( - // "\n////////////////////////\n upload files:", - // values.containerID, - // "\n////////////////////////\n fileListObj:", - // fileListObj, - // "\n////////////////////////\n" + // "\n////////////////////////\n upload files:", + // cleanedValues.containerID, + // "\n////////////////////////\n fileListObj:", + // fileListObj, + // "\n////////////////////////\n" // ); - var dataObj = values; + // Prepare data object for upload + const dataObj = cleanedValues; - (values = updateLinks(values)), - uploadRepFiles( - dataObj, - [{}], - values.containerID, - props.caseReference + "/" + dataObj.repfile_name - ).then((data) => { - return data; - }); + // Update links on values + const updatedValues = updateLinks(cleanedValues); + + // Perform file upload and return the promise + return uploadRepFiles( + dataObj, + [{}], + updatedValues.containerID, + `${props.caseReference}/${dataObj.repfile_name}` + ); }; const repForm = props.props.form; + const isQuestionnaire = + formObj?.representationForm?.values?.representationType === + "Questionnaire"; + + const appealIsConsultation = appealType === 846040002; + const appealIsLocalImpact = + currentView.caseReference.appealType === 846040011 || + currentView.caseReference.appealType === 846040002; + + const renderDueDate = () => { + if ( + detailsObj?.pinswg_questionnaireduedate || + detailsObj?.pinswg_endofrepresentationperiod || + detailsObj?.pinswg_consultationclose + ) { + return formatDates( + detailsObj.pinswg_questionnaireduedate || + detailsObj.pinswg_endofrepresentationperiod || + detailsObj.pinswg_consultationclose + ); + } + return "N/A"; + }; + + const renderStatementsDue = () => ( +
+ {t("myrepresentations:statements-due-label")}:{" "} + + {formatDates( + detailsObj.pinswg_statementduedate || + detailsObj.pinswg_statementsduedate || + detailsObj.pinswg_endofrepresentationperiod + )} + +
+ ); + + const renderMarineImpact = () => + appealIsConsultation && + isNRW && ( +
+ {t("myrepresentations:marine-impact-report")}:{" "} + + {formatDates(detailsObj.pinswg_consultationclose)} + +
+ ); + + const renderConsultationClose = () => + appealIsConsultation && ( +
+ {t("myrepresentations:consultation-close-label")}:{" "} + + {formatDates(detailsObj.pinswg_consultationclose)} + +
+ ); + + const renderFinalCommentsDue = () => + !( + currentView.caseReference.appealType === 846040011 || + appealIsConsultation + ) && ( +
+ {t("myrepresentations:final-comments-due-label")}:{" "} + + {formatDates(detailsObj.pinswg_finalcommentsduedate)} + +
+ ); + return (
- {currentView.representationSubmit == true ? ( + {currentView.representationSubmit ? ( { ) : ( <>

- {appealType == 846040002 + {appealIsConsultation ? t( "myrepresentations:make-a-consultation-on-label" ) @@ -1255,134 +1097,41 @@ let MakeRepresentation = (props) => {

- {" "}

{t( "myrepresentations:timetable-title" - )}{" "} + )}

- {currentView.caseReference - .appealType == 846040011 || - currentView.caseReference - .appealType == 846040002 + {appealIsLocalImpact ? t( "myrepresentations:local-impact-report" ) : t( "myrepresentations:questionnaire-due-label" )} - : + :{" "} - {" "} - {detailsObj.hasOwnProperty( - "pinswg_questionnaireduedate" - ) || - detailsObj.hasOwnProperty( - "pinswg_endofrepresentationperiod" - ) || - detailsObj.hasOwnProperty( - "pinswg_consultationclose" - ) - ? formatDates( - detailsObj.pinswg_questionnaireduedate || - detailsObj.pinswg_endofrepresentationperiod || - detailsObj.pinswg_consultationclose - ) - : "N/A"} + {renderDueDate()}
- {currentView.caseReference - .appealType != 846040002 && ( -
- {t( - "myrepresentations:statements-due-label" - )} - : - - {" "} - {formatDates( - detailsObj.pinswg_statementduedate || - detailsObj.pinswg_statementsduedate || - detailsObj.pinswg_endofrepresentationperiod - )} - -
- )} + {!appealIsConsultation && + renderStatementsDue()} - {currentView.caseReference - .appealType == 846040002 && - isNRW && ( -
- {t( - "myrepresentations:marine-impact-report" - )} - : - - {" "} - {formatDates( - detailsObj.pinswg_consultationclose - )} - -
- )} - {currentView.caseReference - .appealType == 846040002 && ( -
- {t( - "myrepresentations:consultation-close-label" - )} - : - - {" "} - {formatDates( - detailsObj.pinswg_consultationclose - )} - -
- )} - {currentView.caseReference - .appealType != 846040011 || - (currentView.caseReference - .appealType != - 846040002 && ( -
- {t( - "myrepresentations:final-comments-due-label" - )} - : - - {" "} - {formatDates( - detailsObj.pinswg_finalcommentsduedate - )} - -
- ))} + {renderMarineImpact()} + + {renderConsultationClose()} + + {renderFinalCommentsDue()}
-
- {formObj.hasOwnProperty( - "representationForm" - ) && - formObj[ - "representationForm" - ].hasOwnProperty("values") && - formObj[ - "representationForm" - ].values.hasOwnProperty( - "representationType" - ) && - formObj["representationForm"].values - .representationType == - "Questionnaire" && - whichProgress()} -
+ + {isQuestionnaire && whichProgress()}