Merged PR 1668: Contact details for owners and tenants

Related work items: #16580, #16583
This commit is contained in:
Robert Bond
2025-06-11 17:31:34 +00:00
12 changed files with 662 additions and 992 deletions
+60 -12
View File
@@ -748,7 +748,7 @@ const RenderDatePicker = ({
: value : value
: null : null
} //{parseISO(value) || null} } //{parseISO(value) || null}
className="govuk-input govuk-input--width-10" className="govuk-input govuk-input--width-12"
minDate={minDate} minDate={minDate}
maxDate={maxDate} maxDate={maxDate}
autoComplete="off" autoComplete="off"
@@ -2179,7 +2179,8 @@ const RenderFileUpload = (field) => {
).then((data) => { ).then((data) => {
console.log(data); console.log(data);
let buildAppealFilesArray = []; let buildAppealFilesArray = [];
let values = field.form.appealForm.values; //let values = field.form.appealForm.values;
let values = field.props.form.appealForm.values;
let filesUploadObj = renamedAcceptedFiles; let filesUploadObj = renamedAcceptedFiles;
for (let key in filesUploadObj) { for (let key in filesUploadObj) {
@@ -2434,6 +2435,18 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => {
const required = (value) => const required = (value) =>
value ? undefined : t("newappeal:is-required-label"); value ? undefined : t("newappeal:is-required-label");
const email = (value) => {
let errors;
const emailRegex =
/(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/gi;
if (!emailRegex.test(value)) {
errors = t("newappeal:invalid-email-address-errormsg");
}
return errors;
};
//fields.push({}); //fields.push({});
fields.length == 0 && fields.push({}); fields.length == 0 && fields.push({});
return ( return (
@@ -2445,18 +2458,47 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => {
</h4> </h4>
<div className="fieldArrayContainer"> <div className="fieldArrayContainer">
<div className="govuk-grid-column-full">
<div
className="gouk-grid-row"
style={{
display: "flex",
marginBottom: "20px",
}}
>
<Field <Field
id={`${member}.${fields.name}`} id={`${member}.${fields.name}_firstname`}
name={`${member}.${fields.name}`} name={`${member}.${fields.name}_firstname`}
type="text" type="text"
component={RenderTextfield} component={RenderTextfield}
validate={[checkValue]} validate={[checkValue]}
label={ label={"First name"}
subTitle == "owners" className="govuk-input govuk-input--width-12"
? "Owner name" showErrorBottom={true}
: "Tenant name" />
} <Field
className="govuk-input govuk-input--width-10" id={`${member}.${fields.name}_lastname`}
name={`${member}.${fields.name}_lastname`}
type="text"
component={RenderTextfield}
validate={[checkValue]}
label={"Last name"}
className="govuk-input govuk-input--width-12"
showErrorBottom={true}
/>
</div>
<div
className="gouk-grid-row"
style={{ display: "flex" }}
>
<Field
id={`${member}.${fields.name}_email`}
name={`${member}.${fields.name}_email`}
type="text"
component={RenderTextfield}
validate={[email]}
label={"Email"}
className="govuk-input govuk-input--width-12"
showErrorBottom={true} showErrorBottom={true}
/> />
<Field <Field
@@ -2467,10 +2509,15 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => {
dateStart={"-6m"} dateStart={"-6m"}
dateEnd={"0"} dateEnd={"0"}
validate={[required]} validate={[required]}
className="govuk-input govuk-input--width-10" className="govuk-input govuk-input--width-12"
showErrorBottom={true} showErrorBottom={true}
/> />
</div>
</div>
<div
className="gouk-grid-row"
style={{ display: "flex" }}
>
<button <button
type="button" type="button"
title="Remove" title="Remove"
@@ -2481,6 +2528,7 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => {
</button> </button>
</div> </div>
</div> </div>
</div>
))} ))}
<br /> <br />
+8 -18
View File
@@ -24,25 +24,15 @@ let AdvancedSearch = (props) => {
//console.log("props here:", props.props); //console.log("props here:", props.props);
const appealOptionsObj = _.isEmpty(props) const appealOptionsObj =
? [{}] props?.appealType?.appealTypeOptions?.value?.length > 0
: _.isEmpty(props.appealType) ? props.appealType.appealTypeOptions.value
? [{}] : [{}];
: _.isEmpty(props.appealType.appealTypeOptions)
? [{}]
: _.isEmpty(props.appealType.appealTypeOptions.value)
? [{}]
: props.appealType.appealTypeOptions.value;
let lpaOptionsObj = _.isEmpty(props) const lpaOptionsObj =
? [{}] props?.LPAData?.LPAData?.value?.length > 0
: _.isEmpty(props.LPAData) ? props.LPAData.LPAData.value
? [{}] : [{}];
: _.isEmpty(props.LPAData.LPAData)
? [{}]
: _.isEmpty(props.LPAData.LPAData)
? [{}]
: props.LPAData.LPAData.value;
const RenderTextfield = ({ const RenderTextfield = ({
id, id,
+12 -5
View File
@@ -317,11 +317,11 @@ let BuildCheckRow = (props) => {
datafieldname[0].value datafieldname[0].value
].map((tenant, index) => { ].map((tenant, index) => {
console.log( console.log(
typeof tenant.pinswg_owners typeof tenant.pinswg_owners_firstname
); );
return typeof tenant.pinswg_owners != return typeof tenant.pinswg_owners_firstname !=
"undefined" || "undefined" ||
typeof tenant.pinswg_agriculturaltenantname != typeof tenant.pinswg_agriculturaltenantname_firstname !=
"undefined" ? ( "undefined" ? (
<div <div
key={index} key={index}
@@ -330,8 +330,15 @@ let BuildCheckRow = (props) => {
}} }}
> >
<div className="govuk-!-width-one-half"> <div className="govuk-!-width-one-half">
{tenant.pinswg_agriculturaltenantname || {tenant?.pinswg_agriculturaltenantname_firstname &&
tenant.pinswg_owners} tenant.pinswg_agriculturaltenantname_firstname +
" " +
tenant.pinswg_agriculturaltenantname_lastname}
{tenant?.pinswg_owners_firstname &&
tenant.pinswg_owners_firstname +
" " +
tenant.pinswg_owners_lastname}
</div> </div>
<div className="govuk-!-width-one-half"> <div className="govuk-!-width-one-half">
Served:{" "} Served:{" "}
+184 -203
View File
@@ -17,246 +17,227 @@ import {
} from "../elements"; } from "../elements";
export default function BuildField(props) { export default function BuildField(props) {
let { t } = useTranslation(); const { t } = useTranslation();
const { locale } = useRouter();
const router = useRouter(); // Destructure frequently used props for clarity
const { locale } = router; const {
const { fieldType, label, datafieldname, mandatoryFieldData } = props; fieldType,
const parser = new DOMParser(); label,
datafieldname,
picklistData,
validation,
hint,
maxFieldLength,
dateStart,
dateEnd,
documentTypeCode,
uploadCount,
setUploadCount,
setFileCount,
parentField,
parentFieldShowOnValue,
requiredDocumentValue,
requiredDocumentLabel,
setDocumentsList,
documentList,
maxSubField,
datafieldcontent,
} = props;
const whichFieldType = (classid) => { // Extract deeply nested props for convenience (avoid props.props.props all over)
//console.log(props.datafieldname, classid); // Defensive checks in case nested props don't exist
const appealType = props?.props?.props?.appealType || {};
const form = props?.props?.props?.form || {};
const formProps = props?.props?.props?.props?.form || {};
const setFilesForAppeal = props?.props?.props?.setFilesForAppeal;
const accountDetails = props?.props?.props?.props?.accountDetails || {};
const ticketnumber = appealType.caseReference?.ticketnumber || "";
const fileList = appealType.fileList || {};
const containerID = accountDetails.containerID || "";
switch (classid) { // Mapping fieldType to components
case "{270BD3DB-D9AF-4782-9025-509E298DEC0A}": const fieldTypeMap = {
return ( "{270BD3DB-D9AF-4782-9025-509E298DEC0A}": (
<ReadOnlyfield <ReadOnlyfield
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
value={ value={ticketnumber}
props.props.props.appealType.caseReference
.ticketnumber
}
props={props} props={props}
ticketnumber={ ticketnumber={ticketnumber}
props.props.props.appealType.caseReference
.ticketnumber
}
/> />
); ),
break; "{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}": (
case "{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}":
return (
<PickList <PickList
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
datafieldname={props.datafieldname} datafieldname={datafieldname}
picklistData={props.picklistData} picklistData={picklistData}
validation={props.validation} validation={validation}
hint={props.hint} hint={hint}
/> />
); ),
break; "{67FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}": (
case "{67FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}":
return (
<YesNofield <YesNofield
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
requiredDocumentValue={props.requiredDocumentValue} requiredDocumentValue={requiredDocumentValue}
requiredDocumentLabel={props.requiredDocumentLabel} requiredDocumentLabel={requiredDocumentLabel}
validation={props.validation} validation={validation}
setDocumentsList={props.setDocumentsList} setDocumentsList={setDocumentsList}
documentList={props.documentList} documentList={documentList}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
/> />
); ),
break; "{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}": (
case "{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}":
return (
<Radiofield <Radiofield
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
datafieldname={props.datafieldname} datafieldname={datafieldname}
options={props.datafieldcontent} options={datafieldcontent}
inline={false} inline={false}
hint={props.hint} hint={hint}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
validation={props.validation} validation={validation}
setDocumentsList={props.setDocumentsList} setDocumentsList={setDocumentsList}
documentList={props.documentList} documentList={documentList}
requiredDocumentValue={props.requiredDocumentValue} requiredDocumentValue={requiredDocumentValue}
requiredDocumentLabel={props.requiredDocumentLabel} requiredDocumentLabel={requiredDocumentLabel}
/> />
); ),
break; "{4273EDBD-AC1D-40d3-9FB2-095C621B552D}": (
case "{4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
const required = (value) =>
value ? undefined : t("newappeal:is-required-label");
return (
<Textfield <Textfield
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
props={props} props={props}
ticketnumber={ ticketnumber={ticketnumber}
props.props.props.appealType.caseReference form={form}
.ticketnumber formProps={formProps}
} parentField={parentField}
form={props.props.props.form} parentFieldShowOnValue={parentFieldShowOnValue}
formProps={props.props.props.props.form} validation={validation}
parentField={props.parentField} hint={hint}
parentFieldShowOnValue={props.parentFieldShowOnValue} maxFieldLength={maxFieldLength}
validation={props.validation}
hint={props.hint}
maxFieldLength={props.maxFieldLength}
/> />
); ),
break; "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}": (
case "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}":
return (
<DateFieldPicker <DateFieldPicker
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
validation={props.validation} validation={validation}
dateStart={props.dateStart} dateStart={dateStart}
dateEnd={props.dateEnd} dateEnd={dateEnd}
hint={props.hint} hint={hint}
/> />
); ),
break; "{E0DECE4B-6FC8-4a8f-A065-082708572369}": (
case "{E0DECE4B-6FC8-4a8f-A065-082708572369}":
return (
<MultiLinefield <MultiLinefield
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
validation={props.validation} validation={validation}
maxFieldLength={props.maxFieldLength} maxFieldLength={maxFieldLength}
hint={props.hint} hint={hint}
/> />
); ),
break; "{E0DECE4B-6666-4a8f-A065-082708572369}": (
case "{E0DECE4B-6666-4a8f-A065-082708572369}":
return (
<RichMultiLinefield <RichMultiLinefield
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
validation={props.validation} validation={validation}
maxFieldLength={props.maxFieldLength} maxFieldLength={maxFieldLength}
hint={props.hint} hint={hint}
/> />
); ),
break; "{C6D124CA-7EDA-4a60-AEA9-7FB8D318B68F}": (
case "{C6D124CA-7EDA-4a60-AEA9-7FB8D318B68F}":
return (
<NumericField <NumericField
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
validation={props.validation} validation={validation}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
maxFieldLength={props.maxFieldLength} maxFieldLength={maxFieldLength}
/> />
); ),
break; "{C3EFE0C3-0EC6-42be-8349-CBD9079DFD8E}": (
case "{C3EFE0C3-0EC6-42be-8349-CBD9079DFD8E}":
return (
<DecimalField <DecimalField
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
validation={props.validation} validation={validation}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
maxFieldLength={props.maxFieldLength} maxFieldLength={maxFieldLength}
/> />
); ),
break; "{16D63FD6-119B-4353-BDCA-18358721C3FE}": (
case "{16D63FD6-119B-4353-BDCA-18358721C3FE}":
return (
<div className="govuk-!-margin-bottom-9"> <div className="govuk-!-margin-bottom-9">
<FileUploadField <FileUploadField
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
ticketnumber={ ticketnumber={ticketnumber}
props.props.props.props.appealType.caseReference documentTypeCode={documentTypeCode}
.ticketnumber hint={hint}
} fileList={fileList}
documentTypeCode={props.documentTypeCode} setFilesForAppeal={setFilesForAppeal}
hint={props.hint} containerID={containerID}
fileList={ uploadCount={uploadCount}
props.props.props.props.appealType.fileList setFileCount={setFileCount}
} setUploadCount={setUploadCount}
setFilesForAppeal={ props={props?.props?.props}
props.props.props.setFilesForAppeal
}
containerID={
props.props.props.props.accountDetails
.containerID
}
uploadCount={props.uploadCount}
setFileCount={props.props.setFileCount}
setUploadCount={props.setUploadCount}
props={props.props.props.props}
/> />
</div> </div>
); ),
break; "{0273EDBD-AC1D-40d3-9FB2-095C621B552D}": (
case "{0273EDBD-AC1D-40d3-9FB2-095C621B552D}":
return (
<FieldArrayForm <FieldArrayForm
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
maxSubField={props.maxSubField} maxSubField={maxSubField}
/> />
); ),
case "{9EF39988-22BB-4f0b-BBBE-64B5A3748AEE}": "{9EF39988-22BB-4f0b-BBBE-64B5A3748AEE}": (
return (
<CheckBoxfield <CheckBoxfield
name={props.datafieldname} name={datafieldname}
label={props.label} label={label}
props={props} props={props}
form={props.props.props.form} form={form}
formProps={props.props.props.props.form} formProps={formProps}
parentField={props.parentField} parentField={parentField}
parentFieldShowOnValue={props.parentFieldShowOnValue} parentFieldShowOnValue={parentFieldShowOnValue}
validation={props.validation} validation={validation}
/> />
); ),
break;
default:
return (
<Textfield name={props.datafieldname} label={props.label} />
);
}
}; };
return ( return (
<div className="govuk-grid-row">{whichFieldType(props.fieldType)}</div> <div className="govuk-grid-row">
{fieldTypeMap[fieldType] || (
<Textfield name={datafieldname} label={label} />
)}
</div>
); );
} }
+85 -235
View File
@@ -4,12 +4,7 @@ import { connect } from "react-redux";
import { setCurrentSection } from "../../store/appealType/action"; import { setCurrentSection } from "../../store/appealType/action";
import { FieldsTranslations } from "../elements"; import { FieldsTranslations } from "../elements";
const BuildProgress = (props) => { const BuildProgress = ({
let { t } = useTranslation();
const router = useRouter();
const { locale } = router;
const {
progObj, progObj,
titleList, titleList,
currentSection, currentSection,
@@ -18,17 +13,56 @@ const BuildProgress = (props) => {
mandatoryFieldsData, mandatoryFieldsData,
gotoSection, gotoSection,
setCurrentSection, setCurrentSection,
} = props; props: outerProps,
const parser = new DOMParser(); }) => {
const { t } = useTranslation();
const router = useRouter();
const { locale } = router;
//const progObj = getProgressObj( // Helper to safely access nested form values
// formObjXML, const getFormValue = (field) =>
// titleList, outerProps?.props?.form?.appealForm?.values?.[field];
// mandatoryFieldsData,
// props
// );
//console.log(progObj); const renderDocumentList = () => {
const formValues = outerProps?.props?.form?.appealForm?.values || {};
return (
<>
<li>{t("newappeal:application-form")}</li>
{formValues.pinswg_developmentdescriptionchanged === "true" && (
<li>Description of development change confirmation</li>
)}
{formValues.pinswg_caseworkreason === "846040005" && (
<li>{t("newappeal:registration-of-application-letter")}</li>
)}
{formValues.pinswg_caseworkreason === "846040000" && (
<li>Decision notice</li>
)}
{formValues.pinswg_attachsoc === "true" && (
<li>{t("newappeal:statement-of-case")}</li>
)}
{formValues.pinswg_attachcostapplication === "true" && (
<li>{t("newappeal:cost-application")}</li>
)}
{formValues.pinswg_s106unilateralsubmitted === "true" && (
<li>Planning obligation (S106/Unilateral)</li>
)}
{/* Additional document list items from documentListObj if needed */}
{/* {Object.entries(documentListObj).map(([key, value]) => (
<li key={key}>{value}</li>
))} */}
<li>{t("newappeal:site-location-plan")}</li>
</>
);
};
return ( return (
<> <>
@@ -40,12 +74,13 @@ const BuildProgress = (props) => {
<h2 className="govuk-heading-s govuk-!-font-weight-bold gov-font-dark-grey progress-heading"> <h2 className="govuk-heading-s govuk-!-font-weight-bold gov-font-dark-grey progress-heading">
{t("newappeal:new-appeal-progress-nav-label")}:{" "} {t("newappeal:new-appeal-progress-nav-label")}:{" "}
<span className="progress-case-reference"> <span className="progress-case-reference">
{props.props.appealType.caseReference.ticketnumber} {
outerProps?.props?.appealType?.caseReference
?.ticketnumber
}
</span> </span>
</h2> </h2>
{/* <hr className="govuk-section-break govuk-section-break--m govuk-section-break--visible" /> */}
<div <div
id="step-by-step-navigation" id="step-by-step-navigation"
data-module="gemstepnav" data-module="gemstepnav"
@@ -57,21 +92,24 @@ const BuildProgress = (props) => {
data-hide-all-text="Hide all" data-hide-all-text="Hide all"
> >
<ol className="app-step-nav__steps"> <ol className="app-step-nav__steps">
{Object.keys(progObj).map((key, index) => ( {Object.keys(progObj).map((key, index) => {
<li const step = progObj[index];
key={key} const stepId = FieldsTranslations(step.title)
className={
"app-step-nav__step js-step app-step-nav__step--active" +
(progObj[index].allFieldsComplete
? " sectionComplete"
: " sectionIncomplete")
}
aria-current="step"
data-show=""
id={FieldsTranslations(progObj[index].title)
.toString() .toString()
.replace(/\s+/g, "-") .replace(/\s+/g, "-")
.toLowerCase()} .toLowerCase();
return (
<li
key={key}
className={`app-step-nav__step js-step app-step-nav__step--active ${
step.allFieldsComplete
? "sectionComplete"
: "sectionIncomplete"
}`}
aria-current="step"
data-show=""
id={stepId}
> >
<div <div
className="app-step-nav__header js-toggle-panel" className="app-step-nav__header js-toggle-panel"
@@ -98,26 +136,20 @@ const BuildProgress = (props) => {
<span className="js-step-title"> <span className="js-step-title">
<a <a
href="#" href="#"
onClick={() => { onClick={(e) => {
e.preventDefault();
gotoSection( gotoSection(
parseInt(key) + 1 parseInt(key, 10) +
1
); );
}} }}
className="app-step-nav__button app-step-nav__button--title js-step-title-button" className="app-step-nav__button app-step-nav__button--title js-step-title-button"
aria-expanded="false" aria-expanded="false"
aria-controls={ aria-controls={`step-panel-${stepId}`}
"step-panel-" +
FieldsTranslations(
progObj[index].title
)
.toString()
.replace(/\s+/g, "-")
.toLowerCase()
}
> >
<span className="js-step-title-text govuk-!-font-size-16"> <span className="js-step-title-text govuk-!-font-size-16">
{FieldsTranslations( {FieldsTranslations(
progObj[index].title step.title
)}{" "} )}{" "}
</span> </span>
</a> </a>
@@ -125,222 +157,40 @@ const BuildProgress = (props) => {
</h3> </h3>
</div> </div>
</li> </li>
))} );
{/* <li })}
className={
"app-step-nav__step js-step app-step-nav__step--active"
}
>
<div
className="app-step-nav__header js-toggle-panel "
data-position={10}
>
<h3 className="app-step-nav__title ">
<span className="app-step-nav__circle app-step-nav__circle--number">
<span className="app-step-nav__circle-inner">
<span className="app-step-nav__circle-background">
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
Step
</span>{" "}
{progObj.length + 1}
<span
className="app-step-nav__circle-step-colon govuk-visually-hidden"
aria-hidden="true"
>
:
</span>
</span>
</span>
</span>
<span className="js-step-title">
<a
href="#"
onClick={() => {
gotoSection(progObj.length + 1);
}}
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
aria-expanded="false"
aria-controls={
"step-panel-confirmation"
}
>
<span className="js-step-title-text govuk-!-font-size-16">
Confirmation
</span>
</a>
</span>
</h3>
</div>
</li> */}
</ol> </ol>
</div> </div>
</nav> </nav>
<div> <section>
<h3 className="govuk-heading-s govuk-!-font-weight-bold gov-font-dark-grey"> <h3 className="govuk-heading-s govuk-!-font-weight-bold gov-font-dark-grey">
{t("newappeal:new-appeal-documentlist-nav")}: {t("newappeal:new-appeal-documentlist-nav")}:
</h3> </h3>
<hr className="govuk-section-break govuk-section-break--m govuk-section-break--visible" /> <hr className="govuk-section-break govuk-section-break--m govuk-section-break--visible" />
<ol className="govuk-list document-list"> <ol className="govuk-list document-list">
<ul className="govuk-list ">
<li className="at-nav__page"> <li className="at-nav__page">
<ol className="govuk-list govuk-list--bullet"> <ol className="govuk-list govuk-list--bullet">
<li>{t("newappeal:application-form")}</li> {renderDocumentList()}
{props.props.props.form.hasOwnProperty(
"appealForm"
) &&
props.props.props.form[
"appealForm"
].hasOwnProperty("values") &&
props.props.props.form[
"appealForm"
].values.hasOwnProperty(
"pinswg_developmentdescriptionchanged"
)
? props.props.props.form["appealForm"]
.values
.pinswg_developmentdescriptionchanged ==
"true" && (
<li>
Description of development change
confirmation
</li>
)
: ""}
{props.props.props.form.hasOwnProperty(
"appealForm"
) &&
props.props.props.form[
"appealForm"
].hasOwnProperty("values") &&
props.props.props.form[
"appealForm"
].values.hasOwnProperty("pinswg_caseworkreason")
? props.props.props.form["appealForm"]
.values.pinswg_caseworkreason ==
"846040005" && (
<li>
{t(
"newappeal:registration-of-application-letter"
)}
</li>
)
: ""}
{props.props.props.form.hasOwnProperty(
"appealForm"
) &&
props.props.props.form[
"appealForm"
].hasOwnProperty("values") &&
props.props.props.form[
"appealForm"
].values.hasOwnProperty("pinswg_caseworkreason")
? props.props.props.form["appealForm"]
.values.pinswg_caseworkreason ==
"846040000" && (
<li>Decision notice</li>
)
: ""}
{props.props.props.form.hasOwnProperty(
"appealForm"
) &&
props.props.props.form[
"appealForm"
].hasOwnProperty("values") &&
props.props.props.form[
"appealForm"
].values.hasOwnProperty("pinswg_attachsoc")
? props.props.props.form["appealForm"]
.values.pinswg_attachsoc ==
"true" && (
<li>
{t("newappeal:statement-of-case")}
</li>
)
: ""}
{props.props.props.form.hasOwnProperty(
"appealForm"
) &&
props.props.props.form[
"appealForm"
].hasOwnProperty("values") &&
props.props.props.form[
"appealForm"
].values.hasOwnProperty(
"pinswg_attachcostapplication"
)
? props.props.props.form["appealForm"]
.values
.pinswg_attachcostapplication ==
"true" && (
<li>
{t("newappeal:cost-application")}
</li>
)
: ""}
{props.props.props.form.hasOwnProperty(
"appealForm"
) &&
props.props.props.form[
"appealForm"
].hasOwnProperty("values") &&
props.props.props.form[
"appealForm"
].values.hasOwnProperty(
"pinswg_s106unilateralsubmitted"
)
? props.props.props.form["appealForm"]
.values
.pinswg_s106unilateralsubmitted ==
"true" && (
<li>
Planning obligation
(S106/Unilateral)
</li>
)
: ""}
{/* {Object.keys(documentListObj).length > 0 &&
Object.entries(documentListObj).map(
([key, value]) => {
return <li key={key}>{value}</li>;
}
)} */}
<li>{t("newappeal:site-location-plan")}</li>
</ol> </ol>
</li> </li>
</ul>
</ol> </ol>
</div> </section>
</> </>
); );
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => ({
return {
search: state.search, search: state.search,
searchResultsObj: state.searchResultsObj, searchResultsObj: state.searchResultsObj,
formData: state.formData, formData: state.formData,
appealType: state.appealType, appealType: state.appealType,
initialValues: state.appealType.caseReference.caseDetails, initialValues: state.appealType.caseReference.caseDetails,
//form: state.form, //form: state.form,
}; });
};
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => ({
return { gotoSection: (thisSection) => dispatch(setCurrentSection(thisSection)),
gotoSection: (thisSection) => { });
dispatch(setCurrentSection(thisSection));
},
};
};
export default connect(mapStateToProps, mapDispatchToProps)(BuildProgress); export default connect(mapStateToProps, mapDispatchToProps)(BuildProgress);
+8 -18
View File
@@ -376,25 +376,15 @@ let CreateCase = (props) => {
const { LPAData, onSubmit, handleSubmit, formData } = props; const { LPAData, onSubmit, handleSubmit, formData } = props;
const appealOptionsObj = _.isEmpty(props) const appealOptionsObj =
? [{}] props?.appealType?.appealTypeOptions?.value?.length > 0
: _.isEmpty(props.appealType) ? props.appealType.appealTypeOptions.value
? [{}] : [{}];
: _.isEmpty(props.appealType.appealTypeOptions)
? [{}]
: _.isEmpty(props.appealType.appealTypeOptions.value)
? [{}]
: props.appealType.appealTypeOptions.value;
let lpaOptionsObj = _.isEmpty(props) const lpaOptionsObj =
? [{}] props?.LPAData?.LPAData?.value?.length > 0
: _.isEmpty(props.LPAData) ? props.LPAData.LPAData.value
? [{}] : [{}];
: _.isEmpty(props.LPAData.LPAData)
? [{}]
: _.isEmpty(props.LPAData.LPAData)
? [{}]
: props.LPAData.LPAData.value;
const required = (value) => (value ? undefined : "Required"); const required = (value) => (value ? undefined : "Required");
+16 -2
View File
@@ -526,8 +526,22 @@ export const AppealRow_pdf = (props) => {
"20", "20",
}} }}
> >
{tenant.pinswg_agriculturaltenantname || {tenant?.pinswg_agriculturaltenantname_firstname &&
tenant.pinswg_owners} tenant.pinswg_agriculturaltenantname_firstname +
" " +
tenant.pinswg_agriculturaltenantname_lastname}
{tenant?.pinswg_owners_firstname &&
tenant.pinswg_owners_firstname +
" " +
tenant.pinswg_owners_lastname}
{
" "
}
{tenant?.pinswg_owners_email &&
tenant.pinswg_owners_email}
{tenant?.pinswg_agriculturaltenantname_email &&
tenant.pinswg_agriculturaltenantname_email}
</Text> </Text>
<Text <Text
+12 -27
View File
@@ -166,35 +166,20 @@ let AdvancedSearch = (props) => {
submitting, submitting,
} = props; } = props;
const appealOptionsObj = _.isEmpty(props) const appealOptionsObj =
? [{}] props?.appealType?.appealTypeOptions?.value?.length > 0
: _.isEmpty(props.appealType) ? props.appealType.appealTypeOptions.value
? [{}] : [{}];
: _.isEmpty(props.appealType.appealTypeOptions)
? [{}]
: _.isEmpty(props.appealType.appealTypeOptions.value)
? [{}]
: props.appealType.appealTypeOptions.value;
const projecttypeOptionsObj = _.isEmpty(props) const projecttypeOptionsObj =
? [{}] props?.appealType?.projectTypeOptions?.value?.length > 0
: _.isEmpty(props.appealType) ? props.appealType.projectTypeOptions.value
? [{}] : [{}];
: _.isEmpty(props.appealType.projectTypeOptions)
? [{}]
: _.isEmpty(props.appealType.projectTypeOptions.value)
? [{}]
: props.appealType.projectTypeOptions.value;
let lpaOptionsObj = _.isEmpty(props) const lpaOptionsObj =
? [{}] props?.LPAData?.LPAData?.value?.length > 0
: _.isEmpty(props.LPAData) ? props.LPAData.LPAData.value
? [{}] : [{}];
: _.isEmpty(props.LPAData.LPAData)
? [{}]
: _.isEmpty(props.LPAData.LPAData)
? [{}]
: props.LPAData.LPAData.value;
const RenderLPAList = ({ const RenderLPAList = ({
name, name,
+2 -1
View File
@@ -119,5 +119,6 @@
"previously-added-files": "Ffeiliau wedi'u llwytho i fyny", "previously-added-files": "Ffeiliau wedi'u llwytho i fyny",
"new-appeal-finalising-heading": "Cwblhau cyflwyniad eich apêl", "new-appeal-finalising-heading": "Cwblhau cyflwyniad eich apêl",
"new-appeal-finalising-label": "Wrthi'n uwchlwytho ffeiliau ar hyn o bryd a chwblhau eich cyflwyniad apêl", "new-appeal-finalising-label": "Wrthi'n uwchlwytho ffeiliau ar hyn o bryd a chwblhau eich cyflwyniad apêl",
"new-appeal-wait-label": "Arhoswch os gwelwch yn dda" "new-appeal-wait-label": "Arhoswch os gwelwch yn dda",
"invalid-email-address-errormsg": "Cyfeiriad e-bost annilys"
} }
+2 -1
View File
@@ -119,5 +119,6 @@
"previously-added-files": "Uploaded files", "previously-added-files": "Uploaded files",
"new-appeal-finalising-heading": "Finalising your appeal submission", "new-appeal-finalising-heading": "Finalising your appeal submission",
"new-appeal-finalising-label": "Currently uploading files and finalising your appeal submission", "new-appeal-finalising-label": "Currently uploading files and finalising your appeal submission",
"new-appeal-wait-label": "Please wait" "new-appeal-wait-label": "Please wait",
"invalid-email-address-errormsg": "Invalid email address"
} }
+1 -1
View File
@@ -41,7 +41,7 @@ class MyDocument extends Document {
//const generatedNonce = nanoid(); //const generatedNonce = nanoid();
const generatedNonce = this.props.generatedNonce; const generatedNonce = this.props.generatedNonce;
console.log("this is the nonce:", generatedNonce); //console.log("this is the nonce:", generatedNonce);
let csp = ``; let csp = ``;
csp += `base-uri 'self';`; csp += `base-uri 'self';`;
+113 -310
View File
@@ -1,4 +1,3 @@
import _ from "lodash";
import { getSession, useSession } from "next-auth/react"; import { getSession, useSession } from "next-auth/react";
import useTranslation from "next-translate/useTranslation"; import useTranslation from "next-translate/useTranslation";
import Head from "next/head"; import Head from "next/head";
@@ -6,7 +5,6 @@ import { useRouter } from "next/router";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { import {
createContainerProxy, createContainerProxy,
getAwaitingSubmission,
getAwaitingSubmissionFromBlob, getAwaitingSubmissionFromBlob,
getCase, getCase,
getIP, getIP,
@@ -30,15 +28,10 @@ import {
setLoggedInUserId, setLoggedInUserId,
} from "../../store/accountDetails/action"; } from "../../store/accountDetails/action";
import { import {
setAwaitingSubmission,
setAwaitingSubmissionDetails, setAwaitingSubmissionDetails,
setAwaitingSubmissionFromBlob, setAwaitingSubmissionFromBlob,
} from "../../store/awaitingSubmission/action"; } from "../../store/awaitingSubmission/action";
import { import { setShowReps, setLocale } from "../../store/currentView/action";
setShowReps,
setLocale,
setFilesForRepresentation,
} from "../../store/currentView/action";
import { setMyCases, setMyCasesDetails } from "../../store/myCases/action"; import { setMyCases, setMyCasesDetails } from "../../store/myCases/action";
import { import {
setMyRepresentations, setMyRepresentations,
@@ -56,7 +49,6 @@ import pLimit from "p-limit";
const Home = (props) => { const Home = (props) => {
const { const {
footerLinks, footerLinks,
pages,
myCases, myCases,
myRepresentations, myRepresentations,
watchedCases, watchedCases,
@@ -67,13 +59,11 @@ const Home = (props) => {
currentView, currentView,
mySubmittedReps, mySubmittedReps,
} = props; } = props;
let { t, lang } = useTranslation();
// const mySubmittedReps = myRepresentations.mySubmittedReps;
const { t } = useTranslation();
const router = useRouter(); const router = useRouter();
const { locale } = router; const { locale, query } = router;
const { appealtypes } = router.query; const { appealtypes } = query;
const { data: session } = useSession(); const { data: session } = useSession();
@@ -91,9 +81,8 @@ const Home = (props) => {
<meta <meta
key="og:locale" key="og:locale"
property="og:locale" property="og:locale"
content={router.locale} content={locale}
/> />
{/* If they have a Twitter Handle, include the meta details below */}
<meta <meta
key="og:site_name" key="og:site_name"
property="og:site_name" property="og:site_name"
@@ -171,113 +160,76 @@ const Home = (props) => {
export const getServerSideProps = wrapper.getServerSideProps( export const getServerSideProps = wrapper.getServerSideProps(
(store) => async (ctx) => { (store) => async (ctx) => {
const { query, req, res } = ctx; const { query, req, locale } = ctx;
getIP(req); getIP(req);
console.log("The query", query);
const { cookies } = req; const cookies = req.cookies || {};
const thisSession = await getSession(ctx);
let loggedInUserCookie = cookies.pinsUser;
let thisSession = await getSession(ctx);
let loggedInUser = {};
if (!thisSession) { if (!thisSession) {
console.log("not has sesssion.......");
return { return {
redirect: { redirect: {
destination: "/auth/signin", destination: "/auth/signin",
permanent: false, permanent: false,
}, },
}; };
} else { }
console.log(" has sesssion.......");
[loggedInUser] = await Promise.all([
await getPortalLogin(thisSession.user.email),
]);
//grabs first contact on this list const loggedInUserResponse = await getPortalLogin(
thisSession.user.email
//jump out page for duplicates....
console.log(
"Number of contacts with this email:",
loggedInUser.value.length
); );
if (loggedInUser.value.length > 1) { const contacts = loggedInUserResponse?.value || [];
if (contacts.length > 1) {
return { return {
redirect: { redirect: {
destination: destination:
ctx.locale == "cy" locale === "cy"
? "/cy/manylionpellach" ? "/cy/manylionpellach"
: "/furtherdetails", : "/furtherdetails",
permanent: false, permanent: false,
}, },
}; };
} }
loggedInUser = loggedInUser.value[0].contactid;
//console.log("nextAuth Session:", thisSession);
}
//Create Storage container for logged in user
await createContainerProxy(thisSession.user.id);
const loggedInUser = contacts[0]?.contactid;
await createContainerProxy(thisSession.user.id);
const accountDetails = await getPersonalAccount(loggedInUser); const accountDetails = await getPersonalAccount(loggedInUser);
//console.log("----------", accountDetails); const lpaId =
const lpaid =
accountDetails[ accountDetails[
"pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue" "pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue"
]; ];
const isLPA = accountDetails.pinswg_typeofinvolvement === 846040012;
// Fetch cases, reps, watched cases, awaiting submission concurrently
const [ const [
myCases, myCases,
myRepresentations, myRepresentations,
watchedCases, watchedCases,
//awaitingSubmission,
awaitingSubmissionFromBlob, awaitingSubmissionFromBlob,
] = await Promise.all([ ] = await Promise.all([
accountDetails.pinswg_typeofinvolvement == 846040012 isLPA ? getMyLPACases(lpaId) : getMyCases(loggedInUser),
? await getMyLPACases(lpaid) getRepsFromBlob(thisSession.user.id),
: await getMyCases(loggedInUser), getWatchedCases(loggedInUser),
getAwaitingSubmissionFromBlob(thisSession.user.id),
await getRepsFromBlob(thisSession.user.id),
await getWatchedCases(loggedInUser),
//await getAwaitingSubmission(loggedInUser),
await getAwaitingSubmissionFromBlob(thisSession.user.id),
]); ]);
//console.log( // Set locale to store
// "/////////////////////////\n ", store.dispatch(setLocale(locale));
// awaitingSubmissionFromBlob.value,
// awaitingSubmissionFromBlob.case
// );
console.log(
"preferred language:",
accountDetails.pinswg_preferredlanguage
);
console.log(
"locale :",
accountDetails.pinswg_preferredlanguage == "846040000" ? "cy" : "en"
);
console.log("req locale :", ctx.locale);
console.log("cookie locale :", cookies.pedw_locale);
store.dispatch(setLocale(ctx.locale));
// Determine preferred locale (cookie overrides)
let preferredLocale = let preferredLocale =
accountDetails.pinswg_preferredlanguage == "846040000" accountDetails.pinswg_preferredlanguage === "846040000"
? "cy" ? "cy"
: "en"; : "en";
if (cookies.pedw_locale) {
preferredLocale = cookies.pedw_locale;
}
// added to redirect if not the users preferred language if (preferredLocale !== locale) {
cookies.hasOwnProperty("pedw_locale") &&
(preferredLocale = cookies.pedw_locale);
if (preferredLocale != ctx.locale) {
return { return {
redirect: { redirect: {
destination: `/${preferredLocale}`, destination: `/${preferredLocale}`,
@@ -286,82 +238,113 @@ export const getServerSideProps = wrapper.getServerSideProps(
}; };
} }
const showLoginCheck = process.env.SHOWLOGIN || false; const showLoginCheck = Boolean(process.env.SHOWLOGIN);
const showMapCheck = process.env.SHOWMAPS || false; const showReps = Boolean(process.env.SHOWREPRESENTATIONS);
const showReps = process.env.SHOWREPRESENTATIONS || false;
store.dispatch(setShowReps(showReps, showLoginCheck)); store.dispatch(setShowReps(showReps, showLoginCheck));
let showWatchedCases = (submittedArr) => { // Filter watched cases where reps not submitted
const required = submittedArr.value.filter((el) => { const filteredWatchedCases = {
return el.pinswg_representationsubmitted == null; "@odata.count": watchedCases.value.filter(
}); (c) => c.pinswg_representationsubmitted == null
).length,
let newObj = {}; value: watchedCases.value.filter(
return Object.assign(newObj, { (c) => c.pinswg_representationsubmitted == null
"@odata.count": required.length, ),
"value": required,
});
}; };
let filteredWatchedCases = showWatchedCases(watchedCases); // Get submitted reps from watched cases
const mySubmittedReps = watchedCases.value.filter((el) => {
let showSubmittedReps = (submittedArr) => { return el.pinswg_representationsubmitted != null;
submittedArr = submittedArr.value;
const required = submittedArr.filter((el) => {
let IsSubmittedRep = _.has(el, "pinswg_representationsubmitted")
? el.pinswg_representationsubmitted != null &&
el.pinswg_representationsubmitted
: "";
return IsSubmittedRep;
}); });
return required;
};
const mySubmittedReps = showSubmittedReps(watchedCases); if (accountDetails.errorCode) {
if (_.has(accountDetails, "errorCode") != false) {
return { return {
redirect: { redirect: {
destination: "/myportal/error", destination: "/myportal/error",
permanent: false, permanent: false,
}, },
}; };
} else { }
// Helper function for fetching details with concurrency limit
const getDetails = async (resultsObj, detailsType) => {
const limitRequests = pLimit(5);
const arr = [];
resultsObj =
detailsType === "mySubmittedReps"
? resultsObj
: resultsObj.value;
const tasks = resultsObj.map((item) =>
limitRequests(async () => {
try {
let caseID = "";
switch (detailsType) {
case "myCases":
caseID = item.pinswg_title;
break;
case "myWatchedCases":
case "mySubmittedReps":
caseID =
item[
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
];
break;
case "awaitingSubmission":
caseID = item.ticketnumber;
break;
case "myRepresentations":
caseID = item.casereference;
break;
default:
caseID = item.pinswg_title;
}
if (!item.pinswg_appealcasetype) return;
const collectionName = getFormCollectionByID(
item.pinswg_appealcasetype
).LogicalCollectionName;
const details = await getPortalModuleDetails(
collectionName,
caseID
);
arr.push(details);
} catch (err) {
console.error("Error fetching details:", err);
}
})
);
await Promise.all(tasks);
return arr;
};
const [ const [
myCasesDetails, myCasesDetails,
watchedCasesDetails, watchedCasesDetails,
mySubmittedRepsDetails, mySubmittedRepsDetails,
myRepresentationsDetails, myRepresentationsDetails,
] = await Promise.all([ ] = await Promise.all([
await getDetails(myCases, "myCases"), getDetails(myCases, "myCases"),
await getDetails(filteredWatchedCases, "myWatchedCases"), getDetails(filteredWatchedCases, "myWatchedCases"),
await getDetails(mySubmittedReps, "mySubmittedReps"), getDetails(mySubmittedReps, "mySubmittedReps"),
await getDetails(myRepresentations, "myRepresentations"), getDetails(myRepresentations, "myRepresentations"),
]); ]);
// console.log(
// "=================================\nmySubmittedRepsDetails:",
// mySubmittedRepsDetails
// );
store.dispatch(setAccountDetails(accountDetails)); store.dispatch(setAccountDetails(accountDetails));
store.dispatch(setLoggedInUserId(loggedInUser)); store.dispatch(setLoggedInUserId(loggedInUser));
store.dispatch(setMyCases(myCases)); store.dispatch(setMyCases(myCases));
store.dispatch(setMyCasesDetails(myCasesDetails)); store.dispatch(setMyCasesDetails(myCasesDetails));
store.dispatch(setMyRepresentations(myRepresentations)); store.dispatch(setMyRepresentations(myRepresentations));
store.dispatch( store.dispatch(setMyRepresentationsDetails(myRepresentationsDetails));
setMyRepresentationsDetails(myRepresentationsDetails)
);
store.dispatch(setWatchedCases(filteredWatchedCases)); store.dispatch(setWatchedCases(filteredWatchedCases));
store.dispatch(setWatchedCasesDetails(watchedCasesDetails)); store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
store.dispatch(setMySubmittedReps(mySubmittedReps)); store.dispatch(setMySubmittedReps(mySubmittedReps));
store.dispatch(setMySubmittedRepsDetails(mySubmittedRepsDetails)); store.dispatch(setMySubmittedRepsDetails(mySubmittedRepsDetails));
//store.dispatch(setAwaitingSubmission(awaitingSubmission));
store.dispatch( store.dispatch(
setAwaitingSubmissionFromBlob(awaitingSubmissionFromBlob) setAwaitingSubmissionFromBlob(awaitingSubmissionFromBlob)
); );
store.dispatch( store.dispatch(
setAwaitingSubmissionDetails(awaitingSubmissionFromBlob) setAwaitingSubmissionDetails(awaitingSubmissionFromBlob)
); );
@@ -369,194 +352,15 @@ export const getServerSideProps = wrapper.getServerSideProps(
return { return {
props: { props: {
showFileUpload: process.env.SHOWFILEUPLOAD, showFileUpload: Boolean(process.env.SHOWFILEUPLOAD),
containerID: thisSession.user.id, containerID: thisSession.user.id,
showLoginCheck: process.env.SHOWLOGIN, showLoginCheck,
}, },
}; };
} }
}
); );
// const getDetails = async (resultsObj, detailsType) => { const mapStateToProps = (state) => ({
// let detailsArr = [];
// const limitRequests = pLimit(1); // Limit to 5 concurrent requests
// resultsObj =
// detailsType == "mySubmittedReps" ? resultsObj : resultsObj.value;
// if (detailsType == "myRepresentations") {
// limitRequests(async () => {
// resultsObj.map((searchDetail, index) => {
// detailsArr.push(
// getCase(searchDetail["incidentID"])
// .then(async (data) => {
// let caseID = "";
// switch (detailsType) {
// case "myCases":
// caseID = data.pinswg_title;
// break;
// case "myWatchedCases":
// case "mySubmittedReps":
// caseID =
// data[
// "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
// ];
// break;
// case "awaitingSubmission":
// case "myRepresentations":
// try {
// caseID = data.ticketnumber;
// } catch {
// console.log("missing:", data);
// }
// break;
// default:
// caseID = data.pinswg_title;
// }
// return await getPortalModuleDetails(
// getFormCollectionByID(
// data.pinswg_appealcasetype
// ).LogicalCollectionName,
// caseID
// ).catch((error) => {
// console.log(
// "=============================\ngetPortalModuleDetails error",
// error
// );
// });
// })
// .catch((error) => {
// console.log(
// "=============================\ngetCase error",
// error
// );
// })
// );
// });
// });
// }
// //debugger;
// await Promise.all(
// resultsObj.map(async (searchDetail, index) => {
// limitRequests(async () => {
// try {
// let caseID = "";
// switch (detailsType) {
// case "myCases":
// caseID = searchDetail.pinswg_title;
// break;
// case "myWatchedCases":
// case "mySubmittedReps":
// caseID =
// searchDetail[
// "_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
// ];
// break;
// case "awaitingSubmission":
// caseID = searchDetail.ticketnumber;
// break;
// case "myRepresentations":
// caseID = searchDetail.casereference;
// break;
// default:
// caseID = searchDetail.pinswg_title;
// }
// console.log(detailsType, " case id : ", caseID);
// searchDetail.pinswg_appealcasetype != null &&
// detailsArr.push(
// getPortalModuleDetails(
// getFormCollectionByID(
// searchDetail.pinswg_appealcasetype
// ).LogicalCollectionName,
// caseID
// )
// );
// } catch (error) {
// console.log("Error processing case:", error);
// }
// });
// })
// );
// let detArr = Promise.all(detailsArr);
// // console.log(detArr);
// return detArr;
// };
const getDetails = async (resultsObj, detailsType) => {
let detailsArr = [];
const limitRequests = pLimit(5); // Allow up to 5 concurrent requests
// Adjust resultsObj based on detailsType
resultsObj =
detailsType === "mySubmittedReps" ? resultsObj : resultsObj.value;
const getDetailsForCase = async (searchDetail) => {
try {
let caseID = "";
// Determine the case ID based on the detailsType
switch (detailsType) {
case "myCases":
caseID = searchDetail.pinswg_title;
break;
case "myWatchedCases":
case "mySubmittedReps":
caseID =
searchDetail[
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
];
break;
case "awaitingSubmission":
caseID = searchDetail.ticketnumber;
break;
case "myRepresentations":
caseID = searchDetail.casereference;
break;
default:
caseID = searchDetail.pinswg_title;
}
console.log(detailsType, " case id: ", caseID);
// If the appeal case type is valid, fetch the portal module details
if (searchDetail.pinswg_appealcasetype != null) {
const formCollectionName = getFormCollectionByID(
searchDetail.pinswg_appealcasetype
).LogicalCollectionName;
const details = await getPortalModuleDetails(
formCollectionName,
caseID
);
detailsArr.push(details);
}
} catch (error) {
console.log("Error processing case:", error);
}
};
// Use limitRequests to manage concurrency
const promises = resultsObj.map((searchDetail) => {
return limitRequests(() => getDetailsForCase(searchDetail));
});
// Wait for all the requests to complete
await Promise.all(promises);
return detailsArr;
};
const mapStateToProps = (state) => {
//console.log(state);
return {
accountDetails: state.accountDetails, accountDetails: state.accountDetails,
currentView: state.currentView, currentView: state.currentView,
search: state.search, search: state.search,
@@ -569,7 +373,6 @@ const mapStateToProps = (state) => {
myRepresentations: state.myRepresentations, myRepresentations: state.myRepresentations,
mySubmittedReps: state.myRepresentations.mySubmittedReps, mySubmittedReps: state.myRepresentations.mySubmittedReps,
awaitingSubmission: state.awaitingSubmission, awaitingSubmission: state.awaitingSubmission,
}; });
};
export default connect(mapStateToProps)(Home); export default connect(mapStateToProps)(Home);