From b668f323fe7b6107f0e2a3414158eb05bb20f62a Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 4 Dec 2024 19:30:18 +0000 Subject: [PATCH] fix for new appeal and reps updates --- actions/azurestorage.js | 41 +- actions/index.js | 10 +- components/case/representation/index.js | 10 +- .../representation/representationAgent.js | 488 +++++++++--------- .../representation/representationAppellant.js | 432 ++++++++-------- .../representationCompleteSubmit.js | 10 +- .../representationInterestedPartyPerson.js | 476 +++++++++-------- components/elements/index.js | 21 +- components/newappeal/aboutyou.js | 72 +-- components/newappeal/buildcheckrow.js | 145 +++++- components/newappeal/buildchecksection.js | 5 +- components/pdftemplates/appealRow_pdf.js | 47 +- components/utils/index.js | 44 ++ locales/cy/newappeal.json | 1 + locales/en/newappeal.json | 3 +- 15 files changed, 951 insertions(+), 854 deletions(-) diff --git a/actions/azurestorage.js b/actions/azurestorage.js index 739f0214..a9b5a512 100644 --- a/actions/azurestorage.js +++ b/actions/azurestorage.js @@ -1,8 +1,8 @@ import { DefaultAzureCredential } from "@azure/identity"; import _ from "lodash"; import { hashAPIPath, consoleLogger } from "."; +import { getDocumentTypeFromFilename } from "../components/utils"; -import { da } from "date-fns/locale"; const { ContainerClient, BlockBlobClient, @@ -178,45 +178,6 @@ export const getContainers = async () => { } }; -const getDocumentTypeFromFilename = (filename) => { - var doctypeCode = "000000"; - - if (filename.indexOf("_-_Statement_of_Case") > 0) doctypeCode = "000000"; - else if (filename.indexOf("_-_Application_Form") > 0) - doctypeCode = "000001"; - else if (filename.indexOf("_-_Site_Ownership_Certificate") > 0) - doctypeCode = "000002"; - else if (filename.indexOf("_-_Decision_Notice") > 0) doctypeCode = "000003"; - else if (filename.indexOf("_-_Site_Location_Plan") > 0) - doctypeCode = "000004"; - else if (filename.indexOf("_-_Plans_Drawing_Documents") > 0) - doctypeCode = "000005"; - else if (filename.indexOf("_-_Additional_Plans_Drawings_Documents") > 0) - doctypeCode = "000006"; - else if (filename.indexOf("_-_Design_and_Access_Statement") > 0) - doctypeCode = "000007"; - else if (filename.indexOf("_-_NSB_LPA_Additional_Documents") > 0) - doctypeCode = "000008"; - else if (filename.indexOf("_-_LPA_Correspondence") > 0) - doctypeCode = "000009"; - else if (filename.indexOf("_-_LPA_Original_Permission") > 0) - doctypeCode = "000010"; - else if (filename.indexOf("_-_LPA's_Registration_Letter") > 0) - doctypeCode = "000011"; - else if (filename.indexOf(+"_-_Environmental_Statement") > 0) - doctypeCode = "000012"; - else if (filename.indexOf("_-_Cost_of_Application") > 0) - doctypeCode = "000013"; - else if (filename.indexOf("_-_Other_Relevant_Material") > 0) - doctypeCode = "000014"; - else if ( - filename.indexOf("_-_S106_Agreement_or_Unilateral_Undertaking") > 0 - ) - doctypeCode = "000015"; - - return doctypeCode; -}; - export const getBlobs = async (containerName, casefolderID) => { const containerToken = await createContainerSas(containerName); const sasUrl = `${STORAGE_PATH}/${containerName}?${containerToken}`; diff --git a/actions/index.js b/actions/index.js index cc18fae1..bdca89ae 100644 --- a/actions/index.js +++ b/actions/index.js @@ -1847,18 +1847,12 @@ export const createContainerProxy = (containerName) => { }); }; -export const sendCaseCompleteMessage = async ( - containerID, - caseReference, - typeofinvolvement -) => { +export const sendCaseCompleteMessage = async (containerID, caseReference) => { var queryUrl = "/api/file/createappealcompletemessage_api?container=" + containerID + "&tempcaseref=" + - caseReference + - "&inv=" + - typeofinvolvement; + caseReference; var config = { method: "get", diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 3156e2ff..558c35fd 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -91,6 +91,7 @@ let MakeRepresentation = (props) => { }; let questionnaireCount = updateQuestionnaireCount(); + const setRepFileName = (values) => { //console.log("---------------\n", values); if ( @@ -408,8 +409,13 @@ let MakeRepresentation = (props) => { ); } else { switch ( - currentView.representationCapacity || - currentView.caseReference.repDetails.representationCapacity + ( + currentView.representationCapacity || + (currentView.caseReference.hasOwnProperty("repDetails") && + currentView.caseReference.repDetails + .representationCapacity) || + "false" + ).toLowerCase() ) { case false: { } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); - setRepFileName(formObj.representationForm.values); + 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; - } + let filterFilesList = props.currentView.caseReference.hasOwnProperty( + "repDetails" + ) + ? props.currentView.caseReference.repDetails.hasOwnProperty( + "filesList" ) - : [] - : []; + ? props.currentView.caseReference.repDetails.filesList.filter( + function (el) { + return el != null; + } + ) + : [] + : []; - const files = acceptedFiles.map((file) => ( -
  • - {file.path} - {file.size} bytes -
  • - )); - const required = (value) => (value ? undefined : "Required"); + 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")} -

    -
    -
    + return ( + <> +
    +
    + {typeof formObj.representationForm.values + .representationType == "undefined" && + props.representationType != "Select..." ? ( + <> +

    {t( - "myrepresentations:comments-set-out-label" + "myrepresentations:representation-from-an-agent-heading" )} - : -

    -
    - -

    - {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 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.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" && ( + )} +
    +
    {" "} +
    + + )} + {typeof formObj.representationForm.values.representationType != + "undefined" && ( +
    +
    + + {/* {router.query.state != "edit" && ( { setRepresentationCapacity(); @@ -250,49 +267,52 @@ const RepAgent = (props) => { {t("common:back-link")} )} */} - {savingStatus ? ( - - {router.locale == "cy" - ? "Nôl data" - : "Saving data"} - { - - ) : ( - - )} + console.log("on save:", valuesObj); + updateRepresentation( + valuesObj, + false, + true + ); + }} + > + {t("common:save-exit-button")} + + )} +
    - - )} - - ); + )} + + ); + } }; const mapDispatchToProps = (dispatch) => ({ diff --git a/components/case/representation/representationAppellant.js b/components/case/representation/representationAppellant.js index 4a91796e..63cbc391 100644 --- a/components/case/representation/representationAppellant.js +++ b/components/case/representation/representationAppellant.js @@ -35,183 +35,202 @@ const RepAppellant = (props) => { } = props; const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); - setRepFileName(formObj.representationForm.values); + console.log(JSON.stringify(formObj) == "{}" ? "empty" : "value"); - let filterFilesList = props.currentView.caseReference.hasOwnProperty( - "repDetails" - ) - ? props.currentView.caseReference.repDetails.hasOwnProperty("filesList") - ? props.currentView.caseReference.repDetails.filesList.filter( - function (el) { - return el != null; - } + 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; + } + ) + : [] + : []; - 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") && ( + filterFilesList = filterFilesList.filter( + (value, index, self) => + index === self.findIndex((t) => t.name === value.name) + ); + + return ( + <>
    -

    - {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 - -

    - )} -
    -
    - +

    + {t( + "myrepresentations:representation-from-an-appellant-heading" )} - ticketnumber={props.props.caseReference} - hint={"sdsd"} - fileList={[]} - setFilesForRepresentation={[]} - containerID={ - props.props.props.accountDetails - .containerID +

    + + -
    - {props.currentView.caseReference.hasOwnProperty( - "repDetails" - ) ? ( - props.currentView.caseReference.repDetails.hasOwnProperty( - "filesList" - ) && - props.currentView.caseReference.repDetails - .filesList.length > 0 ? ( -
    - {filterFilesList.map((blob, i) => ( -
    - {blob.name} + + ) : ( + + )} +
    +
    + {(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)}) - -
    - ))} -
    + + {blob.name} ( + {bytesToSize(blob.size)} + ) + +
    + ))} +
    + ) : ( + "" + ) ) : ( "" - ) - ) : ( - "" - )} -
    -
    {" "} -
    - )} - {typeof formObj.representationForm.values.representationType != - "undefined" && ( -
    -
    - - {/* {router.query.state != "edit" && ( + )} + +
    {" "} +
    + )} + {typeof formObj.representationForm.values.representationType != + "undefined" && ( +
    +
    + + {/* {router.query.state != "edit" && ( { setRepresentationCapacity(); @@ -227,49 +246,52 @@ const RepAppellant = (props) => { )} */} - {savingStatus ? ( - - {router.locale == "cy" - ? "Nôl data" - : "Saving data"} - { - - ) : ( - - )} + console.log("on save:", valuesObj); + updateRepresentation( + valuesObj, + false, + true + ); + }} + > + {t("common:save-exit-button")} + + )} +
    - - )} - - ); + )} + + ); + } }; //const mapStateToProps = (state, props) => {}; diff --git a/components/case/representation/representationCompleteSubmit.js b/components/case/representation/representationCompleteSubmit.js index 0c95e90c..daba364f 100644 --- a/components/case/representation/representationCompleteSubmit.js +++ b/components/case/representation/representationCompleteSubmit.js @@ -157,11 +157,11 @@ const RepCompleteSubmit = (props) => { formObj.representationForm.values.filesList ); - buildAppealFilesArray = formObj.representationForm.values.hasOwnProperty( - "filesList" - ) - ? formObj.representationForm.values.filesList - : []; + // buildAppealFilesArray = formObj.representationForm.values.hasOwnProperty( + // "filesList" + // ) + // ? formObj.representationForm.values.filesList + // : []; console.log(buildAppealFilesArray); diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js index fe3688e2..113f2c83 100644 --- a/components/case/representation/representationInterestedPartyPerson.js +++ b/components/case/representation/representationInterestedPartyPerson.js @@ -33,205 +33,222 @@ const RepInterestedPartyPerson = (props) => { const { acceptedFiles, getRootProps, getInputProps } = useDropzone(); - setRepFileName(formObj.representationForm.values); + 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; - } + let filterFilesList = props.currentView.caseReference.hasOwnProperty( + "repDetails" + ) + ? props.currentView.caseReference.repDetails.hasOwnProperty( + "filesList" ) - : [] - : []; + ? props.currentView.caseReference.repDetails.filesList.filter( + function (el) { + return el != null; + } + ) + : [] + : []; - const files = acceptedFiles.map((file) => ( -
  • - {file.path} - {file.size} bytes -
  • - )); - return ( - <> -
    -
    - {typeof formObj.representationForm.values - .representationType == "undefined" && - props.representationType != "Select..." ? ( - <> -

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

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

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

    -
    -
    + const files = acceptedFiles.map((file) => ( +
  • + {file.path} - {file.size} bytes +
  • + )); + return ( + <> +
    +
    + {typeof formObj.representationForm.values + .representationType == "undefined" && + props.representationType != "Select..." ? ( + <> +

    {t( - "myrepresentations:comments-set-out-label" + "myrepresentations:representation-from-an-interested-person-heading" )} - : -

    -
    - -
    + -
    - + {t("myrepresentations:kind-of-rep-label")} + + + + + ) : ( + + )} +
    +
    + {(typeof props.representationType != "undefined" || + typeof formObj.representationForm.values + .representationType != "undefined") && ( + <> +
    +
    + +
    +
    + +
    +
    +

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

    +
    +
    + {t( + "myrepresentations:comments-set-out-label" )} - ticketnumber={props.props.caseReference} - hint={"sdsd"} - fileList={[]} - setFilesForRepresentation={[]} - containerID={ - props.props.props.accountDetails - .containerID - } - filenamePrefix={props.formObj} - /> -
    - {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)} - ) - -
    - ))} -
    +
    + +
    + {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" && ( -
    -
    - - {/* + )} + +
    {" "} +
    + + )} + {typeof formObj.representationForm.values.representationType != + "undefined" && ( +
    +
    + + {/* { setRepresentationCapacity(); @@ -250,49 +267,52 @@ const RepInterestedPartyPerson = (props) => { > {t("case:summary-back-button-label")} */} - {savingStatus ? ( - - {router.locale == "cy" - ? "Nôl data" - : "Saving data"} - { - - ) : ( - - )} + console.log("on save:", valuesObj); + updateRepresentation( + valuesObj, + false, + true + ); + }} + > + {t("common:save-exit-button")} + + )} +
    - - )} - - ); + )} + + ); + } }; //const mapStateToProps = (state, props) => {}; diff --git a/components/elements/index.js b/components/elements/index.js index 404f615c..800d187d 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -1675,9 +1675,11 @@ export const FieldsTranslations = (label) => { let labelTrans = router.locale == "cy" - ? jsonpath('$..[?(@.value=="' + label + '")].value_cy', formObj) + ? jsonpath('$..[?(@.value=="' + label + '")].value_cy', formObj)[0] : label; + //labelTrans = labelTrans.length > 1 ? labelTrans[0] : labelTrans; + return labelTrans; }; @@ -1749,7 +1751,7 @@ const rejectStyle = { }; const RenderFileUpload = (field) => { - const files = field.input.value; + let files = field.input.value; let { t } = useTranslation(); const style = useMemo( @@ -1912,6 +1914,10 @@ const RenderFileUpload = (field) => { field.input.onChange(newFilesArr); }; + function removeEmptyObjects(arr) { + return arr.filter((obj) => Object.keys(obj).length > 0); + } + return ( <> { {field.meta.touched && field.meta.error && ( {field.meta.error} )} + {} {files && Array.isArray(files) && ( <> - {files.length > 0 &&

    New files

    } - + {/* {(files = removeEmptyObjects(files))} */} +
    {files.map( (file, i) => typeof file.name != "undefined" && ( @@ -2096,7 +2103,7 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => { {fields.map((member, index) => (

    - {subTitle == "owners" ? "Owners" : "Tenant"} # + {subTitle == "owners" ? "Owner" : "Tenant"} # {index + 1}

    @@ -2109,7 +2116,7 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => { validate={[checkValue]} label={ subTitle == "owners" - ? "Owners name" + ? "Owner name" : "Tenant name" } className="govuk-input govuk-input--width-10" @@ -2145,7 +2152,7 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => { onClick={() => fields.push({})} > {subTitle == "owners" - ? "Add Owners" + ? "Add Owner" : t("newappeal:new-appeal-add-tenant-label")} )} diff --git a/components/newappeal/aboutyou.js b/components/newappeal/aboutyou.js index 17ffb8f0..ca635875 100644 --- a/components/newappeal/aboutyou.js +++ b/components/newappeal/aboutyou.js @@ -178,22 +178,7 @@ const RenderRadio = ({ ...custom }) => { let { t } = useTranslation(); - const required = (value) => { - // Check for the required field - if (!value) { - errors = "This field is required"; - } - - // Check for emojis using a regular expression - const emojiRegex = - /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{2300}-\u{23FF}\u{2B50}\u{1F004}-\u{1F0CF}\u{1F0A0}-\u{1F0A5}\u{1F170}-\u{1F251}]/gu; - - if (emojiRegex.test(value)) { - errors = "Emojis are not allowed"; - } - - return errors; - }; + const required = (value) => (value ? undefined : "Required"); return ( <>
    { - let errors = {}; - - // Check for the required field - if (!value) { - errors = "This field is required"; - } - - // Check for emojis using a regular expression - const emojiRegex = - /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{2300}-\u{23FF}\u{2B50}\u{1F004}-\u{1F0CF}\u{1F0A0}-\u{1F0A5}\u{1F170}-\u{1F251}]/gu; - - if (emojiRegex.test(value)) { - errors = "Emojis are not allowed"; - } - - return errors; - }; + const required = (value) => (value ? undefined : "Required"); //console.log(props.options); const fieldOptions = props.options @@ -417,24 +385,7 @@ const RenderCheckBox = ({ ...custom }) => { let { t } = useTranslation(); - const required = (value) => { - let errors = {}; - - // Check for the required field - if (!value) { - errors = "This field is required"; - } - - // Check for emojis using a regular expression - const emojiRegex = - /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{2300}-\u{23FF}\u{2B50}\u{1F004}-\u{1F0CF}\u{1F0A0}-\u{1F0A5}\u{1F170}-\u{1F251}]/gu; - - if (emojiRegex.test(value)) { - errors = "Emojis are not allowed"; - } - - return errors; - }; + const required = (value) => (value ? undefined : "Required"); return ( <> @@ -504,13 +455,10 @@ let AboutYou = (props) => { const contactPref = router.locale == "cy" ? ["Ebost", "Post"] : ["Email", "Post"]; - const required = (value) => { - let errors = {}; + const required = (value) => (value ? undefined : "Is required"); - // Check for the required field - if (!value) { - errors = "This field is required"; - } + const emojicheck = (value) => { + let errors; // Check for emojis using a regular expression const emojiRegex = @@ -592,7 +540,7 @@ let AboutYou = (props) => { component={RenderTextfield} type="text" className="govuk-input govuk-input--width-20" - validate={[required]} + validate={[required, emojicheck]} label={t("newappeal:about-you-on-behalf-label")} maxFieldLength="200" /> @@ -630,7 +578,7 @@ let AboutYou = (props) => { component={RenderTextfield} type="text" className="govuk-input govuk-input--width-20" - validate={[required]} + validate={[required, emojicheck]} label={t( "newappeal:about-you-appellant-contact-details-firstname-label" )} @@ -642,7 +590,7 @@ let AboutYou = (props) => { component={RenderTextfield} type="text" className="govuk-input govuk-input--width-20" - validate={[required]} + validate={[required, emojicheck]} label={t( "newappeal:about-you-appellant-contact-details-lastname-label" )} @@ -654,7 +602,7 @@ let AboutYou = (props) => { component={RenderMultiline} type="textarea" className="govuk-textarea govuk-input--width-20" - validate={[required]} + validate={[required, emojicheck]} label={t( "newappeal:about-you-appellant-contact-details-address-label" )} diff --git a/components/newappeal/buildcheckrow.js b/components/newappeal/buildcheckrow.js index 2fc7f83d..a4f406d1 100644 --- a/components/newappeal/buildcheckrow.js +++ b/components/newappeal/buildcheckrow.js @@ -3,7 +3,13 @@ import useTranslation from "next-translate/useTranslation"; import { useRouter } from "next/router"; import { connect } from "react-redux"; import xpath from "xpath"; -import { getPickListLabel, getRadioLabel } from "../../components/utils"; +import { + getPickListLabel, + getRadioLabel, + bytesToSize, + getDocumentTypeFromFilename, + getThumbnailIconByExtension, +} from "../../components/utils"; import fieldLookup from "../../data/crmfieldlookuptranslations.json"; import { @@ -66,6 +72,14 @@ let BuildCheckRow = (props) => { return labelTrans; }; + function isObjectAndNotEmpty(value) { + return ( + value !== null && + typeof value === "object" && + Object.keys(value).length > 0 + ); + } + return ( <> {Object.keys(rowXML).map((key, index) => { @@ -86,6 +100,11 @@ let BuildCheckRow = (props) => { mandatoryFieldsData ); + var documentTypeCode = xpath.select( + "//@ishareDocumentCode", + doc + ); + // if (datafieldname[0].value.indexOf("fileUpload") > 0) { // isRequiredField.push({ // "LogicalName": datafieldname[0].value, @@ -113,10 +132,6 @@ let BuildCheckRow = (props) => { datafieldname[0].value ] != "undefined" ) { - // if (typeof isRequiredField[0] != "undefined") { - // if ( - // isRequiredField[0].RequiredLevel.Value != "None" - // ) { return (
    @@ -174,10 +189,112 @@ let BuildCheckRow = (props) => { ) ) : fieldtype[0].value == "{16D63FD6-119B-4353-BDCA-18358721C3FE}" ? ( - console.log( - props.props.form["appealForm"] - .values[datafieldname[0].value] - ) + <> + {props.filesArray.map((blob, i) => ( +
    + {getDocumentTypeFromFilename( + blob.name + ) === + documentTypeCode[0] + .value && ( +
    + {blob.name} + + {blob.name} -{" "} + {bytesToSize( + blob.size + )}{" "} + +
    + )} +
    + ))} + +
    + + {props.props.form[ + "appealForm" + ].values[ + datafieldname[0].value + ].map( + (blob, i) => + isObjectAndNotEmpty( + blob + ) && ( +
    + {getDocumentTypeFromFilename( + blob.name + ) === + documentTypeCode[0] + .value && ( +
    + { + + { + blob.name + }{" "} + -{" "} + {bytesToSize( + blob.size + )}{" "} + +
    + )} +
    + ) + )} + ) : fieldtype[0].value == "{0273EDBD-AC1D-40d3-9FB2-095C621B552D}" ? ( props.props.form["appealForm"].values[ @@ -211,7 +328,7 @@ let BuildCheckRow = (props) => {
    - {rows[0].value != "Case reference" && ( + {rows[0].value != "Temporary reference" && ( {
    ); - // } else { - // return null; - // } - // } else { - // return null; - // } - // } else { - // return null; } } })} diff --git a/components/newappeal/buildchecksection.js b/components/newappeal/buildchecksection.js index 5faa17dc..343a2bf7 100644 --- a/components/newappeal/buildchecksection.js +++ b/components/newappeal/buildchecksection.js @@ -178,11 +178,12 @@ let BuildCheckSection = (props) => { props={props} key={key} mandatoryFieldsData={mandatoryFieldsData} + filesArray={buildAppealFilesArray} />
    ))} -
    + {/*
    {buildAppealFilesArray.length > 0 ? buildAppealFilesArray.map((blob, i) => { return ( @@ -233,7 +234,7 @@ let BuildCheckSection = (props) => { ); }) : ""} -
    +
    */}
    {finaliseAppealProcess ? (
    diff --git a/components/pdftemplates/appealRow_pdf.js b/components/pdftemplates/appealRow_pdf.js index ea2d4ca5..a4efd46c 100644 --- a/components/pdftemplates/appealRow_pdf.js +++ b/components/pdftemplates/appealRow_pdf.js @@ -1,7 +1,11 @@ import { JSONPath as jsonpath } from "jsonpath-plus"; import useTranslation from "next-translate/useTranslation"; import xpath from "xpath"; -import { bytesToSize, getPickListLabel } from "../../components/utils"; +import { + bytesToSize, + getPickListLabel, + getDocumentTypeFromFilename, +} from "../../components/utils"; import fieldLookup from "../../data/crmfieldlookuptranslations.json"; import { StyleSheet, Text, View } from "@react-pdf/renderer"; @@ -150,47 +154,6 @@ export const AppealRow_pdf = (props) => { return labelTrans; }; - const getDocumentTypeFromFilename = (filename) => { - var doctypeCode = "000000"; - - if (filename.indexOf("_-_Statement_of_Case") > 0) - doctypeCode = "000000"; - else if (filename.indexOf("_-_Application_Form") > 0) - doctypeCode = "000001"; - else if (filename.indexOf("_-_Site_Ownership_Certificate") > 0) - doctypeCode = "000002"; - else if (filename.indexOf("_-_Decision_Notice") > 0) - doctypeCode = "000003"; - else if (filename.indexOf("_-_Site_Location_Plan") > 0) - doctypeCode = "000004"; - else if (filename.indexOf("_-_Plans_Drawing_Documents") > 0) - doctypeCode = "000005"; - else if (filename.indexOf("_-_Additional_Plans_Drawings_Documents") > 0) - doctypeCode = "000006"; - else if (filename.indexOf("_-_Design_and_Access_Statement") > 0) - doctypeCode = "000007"; - else if (filename.indexOf("_-_NSB_LPA_Additional_Documents") > 0) - doctypeCode = "000008"; - else if (filename.indexOf("_-_LPA_Correspondence") > 0) - doctypeCode = "000009"; - else if (filename.indexOf("_-_LPA_Original_Permission") > 0) - doctypeCode = "000010"; - else if (filename.indexOf("_-_LPA's_Registration_Letter") > 0) - doctypeCode = "000010"; - else if (filename.indexOf(+"_-_Environmental_Statement") > 0) - doctypeCode = "000012"; - else if (filename.indexOf("_-_Cost_of_Application") > 0) - doctypeCode = "000013"; - else if (filename.indexOf("_-_Other_Relevant_Material") > 0) - doctypeCode = "000014"; - else if ( - filename.indexOf("_-_S106_Agreement_or_Unilateral_Undertaking") > 0 - ) - doctypeCode = "000015"; - - return doctypeCode; - }; - return ( <> {Object.keys(rowXML).map((key, index) => { diff --git a/components/utils/index.js b/components/utils/index.js index d0ed99b0..7fe78f93 100644 --- a/components/utils/index.js +++ b/components/utils/index.js @@ -503,3 +503,47 @@ export const getDetailsProxy = (resultsObj, detailsType) => { }); return Promise.all(detailsArr); }; + +export const getDocumentTypeFromFilename = (filename) => { + var doctypeCode = "000000"; + console.log(filename); + + if (typeof filename != "undefined") { + if (filename.indexOf("_-_Statement_of_Case") > 0) + doctypeCode = "000000"; + else if (filename.indexOf("_-_Application_Form") > 0) + doctypeCode = "000001"; + else if (filename.indexOf("_-_Site_Ownership_Certificate") > 0) + doctypeCode = "000002"; + else if (filename.indexOf("_-_Decision_Notice") > 0) + doctypeCode = "000003"; + else if (filename.indexOf("_-_Site_Location_Plan") > 0) + doctypeCode = "000004"; + else if (filename.indexOf("_-_Plans_Drawing_Documents") > 0) + doctypeCode = "000005"; + else if (filename.indexOf("_-_Additional_Plans_Drawings_Documents") > 0) + doctypeCode = "000006"; + else if (filename.indexOf("_-_Design_and_Access_Statement") > 0) + doctypeCode = "000007"; + else if (filename.indexOf("_-_NSB_LPA_Additional_Documents") > 0) + doctypeCode = "000008"; + else if (filename.indexOf("_-_LPA_Correspondence") > 0) + doctypeCode = "000009"; + else if (filename.indexOf("_-_LPA_Original_Permission") > 0) + doctypeCode = "000010"; + else if (filename.indexOf("_-_LPA's_Registration_Letter") > 0) + doctypeCode = "000010"; + else if (filename.indexOf(+"_-_Environmental_Statement") > 0) + doctypeCode = "000012"; + else if (filename.indexOf("_-_Cost_of_Application") > 0) + doctypeCode = "000013"; + else if (filename.indexOf("_-_Other_Relevant_Material") > 0) + doctypeCode = "000014"; + else if ( + filename.indexOf("_-_S106_Agreement_or_Unilateral_Undertaking") > 0 + ) + doctypeCode = "000015"; + } + + return doctypeCode; +}; diff --git a/locales/cy/newappeal.json b/locales/cy/newappeal.json index 77534468..dd99e3ac 100644 --- a/locales/cy/newappeal.json +++ b/locales/cy/newappeal.json @@ -16,6 +16,7 @@ "appeal-confirmation-label": "Cadarnhaf fy mod yn gwneud apêl yn erbyn penderfyniad i wrthod caniatâd cynllunio neu fethiant i benderfynu ar gais cynllunio o fewn 8 wythnos.", "select-to-confirm-label": "Cadarnhewch i barhau", "is-required-label": "Yn ofynnol", + "emojis-not-allowed-label": "Ni chaniateir emojis", "invalid-postcode-label": "Cod post annilys", "hascas-confirmation-label": "Cadarnhewch fod angen apêl HAS/CAS", "hascas-confirmation-hint": "Mae'r llwybr apelio hwn yn berthnasol dim ond os yw'ch cais yn ymwneud â gwrthod caniatâd cynllunio, neu wrthod cais i amrywio neu ddileu amod sydd ynghlwm wrth ganiatâd blaenorol. Bydd pob cais arall yn cael ei gyflwyno trwy Apêl Gynllunio Adran 78", diff --git a/locales/en/newappeal.json b/locales/en/newappeal.json index 59b6724a..3283c465 100644 --- a/locales/en/newappeal.json +++ b/locales/en/newappeal.json @@ -15,6 +15,7 @@ "appeal-confirmation-label": "I confirm that I am making an appeal against a refusal of planning permission or failure to determine a planning application within 8 weeks.", "select-to-confirm-label": "Confirm to continue", "is-required-label": "Is required", + "emojis-not-allowed-label": "Emojis are not allowed", "invalid-postcode-label": "Invalid postcode", "hascas-confirmation-label": "Confirm HAS/CAS appeal is required", "hascas-confirmation-hint": "This appeal route is only applicable if your application relates the refusal of planning permission, or the refusal of an application to vary or remove a condition attached to a previous permision. All other applications will be submitted via a Section 78 Planning Appeal", @@ -80,7 +81,7 @@ "s78-appeals-only-bullet-one": "a refusal of planning permission", "s78-appeals-only-bullet-two": "failure to determine a planning application within 8 weeks", "s78-appeals-only-label-a": "All other appeals must be submitted by email or post.", - "new-appeal-inspector-onsite-paragraph": "NOTE: The inspector will visit the site unaccompanied by either party unless the relevant part of the site cannot be seen from a road or other public land, or is it essential for the Inspector to enter the site to check measurements or relevant facts.", + "new-appeal-inspector-onsite-paragraph": "NOTE: The inspector will visit the site unaccompanied by either party unless the relevant part of the site cannot be seen from a road or other public land, or it is essential for the Inspector to enter the site to check measurements or relevant facts.", "new-appeal-submission-of-case-hint": "This is your only opportunity to make your case in connection with the reason for the appeal. Therefore please provide your FULL statement of case. To do this, you need to go through the reasons for the decision (if provided), and explain why you disagree. Only the reasons within the LPA's decision and the reasons put forward by you at application stage should be included in your Statement of Case. You should not introduce any new reasons for the appeal. Please refer to our Procedural Guide for further information.", "new-appeal-what-procedure-hint": "Appeals dealt with under Part 4 of The Town and Country Planning (Referred Applications and Appeals Procedure) (Wales) Regulations 2017 can be considered on the basis of written representation, a hearing, an inquiry or combined proceedings. In accordance with the Town and Country Planning (Determination of Procedure) (Wales) Order 2017, the Planning and Environment Decisions Wales will make a determination as to the most appropriate procedure and will review it throughout the process.", "new-appeal-cost-application-hint": "You must submit a statement below that clearly explains why you think unreasonable behaviour has occurred and how this has caused unnecessary or wasted expense.",