diff --git a/components/case/representation/index.js b/components/case/representation/index.js
index 79425fc0..2b9fadf8 100644
--- a/components/case/representation/index.js
+++ b/components/case/representation/index.js
@@ -78,6 +78,94 @@ let MakeRepresentation = (props) => {
const [showQuestionnaireSection, setShowQuestionnaireSection] = useState(1);
const [questionnaireCount, setQuestionnaireCount] = useState(0);
+ const setRepFileName = (values) => {
+ //console.log("---------------\n", values);
+ if (
+ values.hasOwnProperty("representationCapacity") &&
+ values.hasOwnProperty("representationType")
+ ) {
+ let repType = "";
+ let repCap = "";
+
+ const repDate = new Date();
+
+ let day = repDate.getDate();
+ let month = repDate.getMonth() + 1;
+ 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 = "AGENT";
+ break;
+ case t("myrepresentations:capacity-options-arr-interested"):
+ repCap = "IP";
+ break;
+ case "Land Owner":
+ repCap = "LO";
+ break;
+ case "lpa":
+ repCap = "LPA";
+ 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 "Other":
+ repType = "OTHER";
+ break;
+
+ default:
+ // code block
+ }
+ Object.assign(values, {
+ "repfile_name": values.hasOwnProperty("repfile_name")
+ ? values.repfile_name
+ : year +
+ "-" +
+ month +
+ "-" +
+ day +
+ "-" +
+ repDate.getHours() +
+ repDate.getMinutes() +
+ repDate.getSeconds() +
+ "_" +
+ repCap +
+ "_" +
+ repType +
+ "_" +
+ values.lastname +
+ "_" +
+ values.firstname,
+ });
+ }
+
+ return values;
+ };
+
const isLPA =
props.props.accountDetails.accountDetails[
"pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue"
@@ -200,6 +288,7 @@ let MakeRepresentation = (props) => {
setSubmitBack={setSubmitBack}
props={props}
caseReference={caseReference}
+ setRepFileName={setRepFileName}
/>;
break;
case "appellant":
@@ -221,6 +310,7 @@ let MakeRepresentation = (props) => {
currentView={currentView}
setSubmitBack={setSubmitBack}
props={props}
+ setRepFileName={setRepFileName}
/>
);
break;
@@ -246,6 +336,7 @@ let MakeRepresentation = (props) => {
showQuestionnaireSection={showQuestionnaireSection}
setQuestionnaireCount={setQuestionnaireCount}
questionnaireCount={questionnaireCount}
+ setRepFileName={setRepFileName}
/>
);
break;
@@ -268,6 +359,7 @@ let MakeRepresentation = (props) => {
currentView={currentView}
setSubmitBack={setSubmitBack}
props={props}
+ setRepFileName={setRepFileName}
/>
);
break;
@@ -290,6 +382,7 @@ let MakeRepresentation = (props) => {
currentView={currentView}
setSubmitBack={setSubmitBack}
props={props}
+ setRepFileName={setRepFileName}
/>
);
break;
@@ -309,6 +402,7 @@ let MakeRepresentation = (props) => {
currentView={currentView}
setSubmitBack={setSubmitBack}
props={props}
+ setRepFileName={setRepFileName}
/>
);
break;
@@ -444,50 +538,9 @@ let MakeRepresentation = (props) => {
// "pinswg_name": "2022-11-29-IP-REP_BOND_1",
- const repDate = new Date();
-
- let day = repDate.getDate();
- let month = repDate.getMonth() + 1;
- let year = repDate.getFullYear();
- let time = repDate.getTime();
-
- let repType = "";
- switch (values.representationCapacity) {
- case t("myrepresentations:capacity-options-arr-appellant"):
- repType = "APPELLANT";
- 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
- }
+ updateBody = setRepFileName(values);
Object.assign(updateBody, {
- "repfile_name": updateBody.hasOwnProperty("repfile_name")
- ? updateBody.repfile_name
- : year +
- "-" +
- month +
- "-" +
- day +
- "-" +
- time +
- "-" +
- repType +
- "-REP" +
- "_" +
- props.props.accountDetails.accountDetails.lastname,
"pinswg_name":
props.props.currentView.caseReference.currentReference,
"containerID": props.props.accountDetails.containerID,
@@ -558,7 +611,9 @@ let MakeRepresentation = (props) => {
};
const onHandleSubmit = (values) => {
- console.log("form values - ", JSON.stringify(values));
+ values = setRepFileName(values);
+
+ console.log("onHandleSubmit form values - ", JSON.stringify(values));
const buildFileArray = [];
@@ -782,8 +837,9 @@ let MakeRepresentation = (props) => {
{t(
"myrepresentations:make-a-representation-on-label"
)}{" "}
- {currentView.caseReference.currentReference}
+ {currentView.caseReference.currentReference}{" "}
+ {currentView.caseReference.caseReference}
-
{(typeof props.representationType != "undefined" ||
typeof formObj.representationForm.values.representationType !=
"undefined") && (
@@ -139,6 +141,7 @@ const RepAppellant = (props) => {
props.props.props.accountDetails
.containerID
}
+ filenamePrefix={props}
/>
{props.currentView.caseReference.hasOwnProperty(
diff --git a/components/case/representation/representationCompleteSubmit.js b/components/case/representation/representationCompleteSubmit.js
index 3c81baed..8a7efb80 100644
--- a/components/case/representation/representationCompleteSubmit.js
+++ b/components/case/representation/representationCompleteSubmit.js
@@ -37,56 +37,58 @@ const RepCompleteSubmit = (props) => {
const repFormData = formObj.representationForm.values;
- const repDate = new Date();
+ // const repDate = new Date();
- let day = repDate.getDate();
- let month = repDate.getMonth() + 1;
- let year = repDate.getFullYear();
- let time = repDate.getTime();
+ // 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 = "APPELLANT";
- 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;
+ // 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
- }
+ // default:
+ // // code block
+ // }
- Object.assign(repFormData, {
- "repfile_name": repFormData.hasOwnProperty("repfile_name")
- ? repFormData.repfile_name
- : year +
- "-" +
- month +
- "-" +
- day +
- "-" +
- time +
- "-" +
- repType +
- "-REP" +
- "_" +
- props.props.props.accountDetails.accountDetails.lastname,
- "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,
- });
+ // 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);
diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js
index 1ead62f0..35f3a49b 100644
--- a/components/case/representation/representationElements.js
+++ b/components/case/representation/representationElements.js
@@ -983,9 +983,13 @@ export const RenderFileUpload = (field) => {
onDrop={(filesToUpload, e) => {
const renamedAcceptedFiles = filesToUpload.map(
(file) =>
- new File([file], `${file.name}`, {
- type: file.type,
- })
+ new File(
+ [file],
+ `${field.filenamePrefix}_${file.name}`,
+ {
+ type: file.type,
+ }
+ )
);
field.input.onChange(renamedAcceptedFiles);
}}
@@ -1103,6 +1107,10 @@ export function FileUploadField(props) {
fileList={props.fileList}
setFilesForAppeal={props.setFilesForAppeal}
containerID={props.containerID}
+ filenamePrefix={
+ props.filenamePrefix.formObj.representationForm.values
+ .repfile_name
+ }
/>
>
);
diff --git a/components/case/representation/representationInterestedPartyPerson.js b/components/case/representation/representationInterestedPartyPerson.js
index 55cbf26a..019a40c0 100644
--- a/components/case/representation/representationInterestedPartyPerson.js
+++ b/components/case/representation/representationInterestedPartyPerson.js
@@ -22,10 +22,14 @@ const RepInterestedPartyPerson = (props) => {
interestedPersonRepresentationArr,
setRepresentationCapacity,
setRepresentationSubmit,
+ setRepFileName,
} = props;
const required = (value) => (value ? undefined : "Required");
const { acceptedFiles, getRootProps, getInputProps } = useDropzone();
+
+ setRepFileName(formObj.representationForm.values);
+
const files = acceptedFiles.map((file) => (
{file.path} - {file.size} bytes
@@ -135,6 +139,7 @@ const RepInterestedPartyPerson = (props) => {
props.props.props.accountDetails
.containerID
}
+ filenamePrefix={props}
/>
diff --git a/components/case/summary.js b/components/case/summary.js
index b6578ca3..d59bb932 100644
--- a/components/case/summary.js
+++ b/components/case/summary.js
@@ -417,39 +417,76 @@ const CaseSummary = (props) => {
detailsObj.pinswg_finalcommentsduedate
) && (
<>
-
- {t(
- "case:summary-make-representation-label"
- )}
-
+ {showRepButton(
+ props.currentView
+ .caseReference
+ .appealType
+ ) ? (
+ <>
+
+ {t(
+ "case:summary-make-representation-label"
+ )}
+
- {
- //spinnerState();
- router.back();
- }}
- className="govuk-button govuk-button--secondary"
- >
- {t(
- "case:summary-back-button-label"
- )}
-
+ {
+ //spinnerState();
+ router.back();
+ }}
+ className="govuk-button govuk-button--secondary"
+ >
+ {t(
+ "case:summary-back-button-label"
+ )}
+
+ >
+ ) : (
+ <>
+
+
+
+ The
+ representation
+ period for
+ this appeal
+ is between{" "}
+ {formatDates(
+ detailsObj.pinswg_startdate
+ )}{" "}
+ and{" "}
+ {formatDates(
+ detailsObj.pinswg_finalcommentsduedate
+ )}
+
+ You can make
+ a
+ representation
+ by emailing{" "}
+
+ pedw.casework@gov.wales
+
+
+
+
+ >
+ )}
>
)}
@@ -578,7 +615,6 @@ const CaseSummary = (props) => {
-
{_.has(detailsObj, "pinswg_startdate") &&
@@ -1017,6 +1053,21 @@ const CaseSummary = (props) => {
return date >= start && date <= end ? true : false;
}
+ function showRepButton(appealType) {
+ switch (appealType) {
+ case 846040012:
+ case 846040013:
+ case 846040014:
+ case 846040015:
+ case 846040020:
+ case 846040021:
+ case 846040023:
+ case 846040024:
+ return false;
+ default:
+ return true;
+ }
+ }
function showRepsEnded(startDate, endDate) {
let date = new Date();
date = new Date(date.toDateString());
diff --git a/components/footer.js b/components/footer.js
index 75ea5f4a..5c8e40db 100644
--- a/components/footer.js
+++ b/components/footer.js
@@ -43,7 +43,7 @@ export default function Footer(props) {
const origin =
typeof window !== "undefined" && window.location.origin
? window.location.origin
- : "";
+ : process.env.API_ROOT;
const URL = `${origin}`;
diff --git a/components/myportal/addresssearch.js b/components/myportal/addresssearch.js
index 90fba4e7..ba6fa6b9 100644
--- a/components/myportal/addresssearch.js
+++ b/components/myportal/addresssearch.js
@@ -135,7 +135,7 @@ let AddressSearch = (props) => {
searchString = "?" + searchString.slice(0, -1);
- console.log(searchString);
+ //console.log(searchString);
router.replace(
router.locale == "cy"
diff --git a/components/myportal/topthree_reps.js b/components/myportal/topthree_reps.js
index 42506d22..da2ae340 100644
--- a/components/myportal/topthree_reps.js
+++ b/components/myportal/topthree_reps.js
@@ -145,8 +145,15 @@ const TopThree = (props) => {
};
const repRaisedDate = (datePart) => {
- var dateObj = new Date(parseInt(datePart.split("-")[3]));
- return dateObj.toLocaleString();
+ var dateObj = new Date(
+ datePart.split("-")[0] +
+ "-" +
+ datePart.split("-")[1] +
+ "-" +
+ datePart.split("-")[2]
+ );
+
+ return dateObj.toLocaleDateString();
};
let topThreeOnlyArr = showTopThreeArr.slice(0, 3);
diff --git a/components/search/addresssearch.js b/components/search/addresssearch.js
index f3bb6575..58e9795c 100644
--- a/components/search/addresssearch.js
+++ b/components/search/addresssearch.js
@@ -137,7 +137,7 @@ let AddressSearch = (props) => {
searchString = "?" + searchString.slice(0, -1);
- console.log(searchString);
+ //console.log(searchString);
router.replace(
router.locale == "cy"
diff --git a/components/search/advancedsearch.js b/components/search/advancedsearch.js
index 12fb1ca4..ada09597 100644
--- a/components/search/advancedsearch.js
+++ b/components/search/advancedsearch.js
@@ -398,7 +398,7 @@ let AdvancedSearch = (props) => {
searchString = "?" + searchString.slice(0, -1);
- console.log(searchString);
+ //console.log(searchString);
router.replace(
router.locale == "cy"
diff --git a/pages/api/file/generatepdf.js b/pages/api/file/generatepdf.js
index ed1643f7..0de81681 100644
--- a/pages/api/file/generatepdf.js
+++ b/pages/api/file/generatepdf.js
@@ -161,7 +161,7 @@ export default async function handler(req, res) {
let repCapacity = "";
switch (reqBodyobj.representationCapacity) {
case "Appellant":
- repCapacity = "APPELLANT";
+ repCapacity = "APP";
break;
case "Agent":
repCapacity = "AGENT";
@@ -183,7 +183,7 @@ export default async function handler(req, res) {
let repType = "";
switch (reqBodyobj.representationType) {
case "Statement":
- repType = "STATE";
+ repType = "Statement";
break;
case "Statement of common ground":
repType = "SCG";
@@ -195,10 +195,10 @@ export default async function handler(req, res) {
repType = "WSE";
break;
case "Questionnaire":
- repType = "QUEST";
+ repType = "Questionnaire";
break;
case "Final comments":
- repType = "FC";
+ repType = "Comments";
break;
case "Other":