Merged PR 1668: Contact details for owners and tenants
Related work items: #16580, #16583
This commit is contained in:
@@ -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,40 +2458,75 @@ const RenderSubFields = ({ fields, meta: { touched, error }, ...custom }) => {
|
|||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<div className="fieldArrayContainer">
|
<div className="fieldArrayContainer">
|
||||||
<Field
|
<div className="govuk-grid-column-full">
|
||||||
id={`${member}.${fields.name}`}
|
<div
|
||||||
name={`${member}.${fields.name}`}
|
className="gouk-grid-row"
|
||||||
type="text"
|
style={{
|
||||||
component={RenderTextfield}
|
display: "flex",
|
||||||
validate={[checkValue]}
|
marginBottom: "20px",
|
||||||
label={
|
}}
|
||||||
subTitle == "owners"
|
>
|
||||||
? "Owner name"
|
<Field
|
||||||
: "Tenant name"
|
id={`${member}.${fields.name}_firstname`}
|
||||||
}
|
name={`${member}.${fields.name}_firstname`}
|
||||||
className="govuk-input govuk-input--width-10"
|
type="text"
|
||||||
showErrorBottom={true}
|
component={RenderTextfield}
|
||||||
/>
|
validate={[checkValue]}
|
||||||
<Field
|
label={"First name"}
|
||||||
name={`${member}.dateserved`}
|
className="govuk-input govuk-input--width-12"
|
||||||
type="text"
|
showErrorBottom={true}
|
||||||
component={RenderDatePicker}
|
/>
|
||||||
label="Date served "
|
<Field
|
||||||
dateStart={"-6m"}
|
id={`${member}.${fields.name}_lastname`}
|
||||||
dateEnd={"0"}
|
name={`${member}.${fields.name}_lastname`}
|
||||||
validate={[required]}
|
type="text"
|
||||||
className="govuk-input govuk-input--width-10"
|
component={RenderTextfield}
|
||||||
showErrorBottom={true}
|
validate={[checkValue]}
|
||||||
/>
|
label={"Last name"}
|
||||||
|
className="govuk-input govuk-input--width-12"
|
||||||
<button
|
showErrorBottom={true}
|
||||||
type="button"
|
/>
|
||||||
title="Remove"
|
</div>
|
||||||
onClick={() => fields.remove(index)}
|
<div
|
||||||
className="govuk-button fieldArrayDelete"
|
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}
|
||||||
|
/>
|
||||||
|
<Field
|
||||||
|
name={`${member}.dateserved`}
|
||||||
|
type="text"
|
||||||
|
component={RenderDatePicker}
|
||||||
|
label="Date served "
|
||||||
|
dateStart={"-6m"}
|
||||||
|
dateEnd={"0"}
|
||||||
|
validate={[required]}
|
||||||
|
className="govuk-input govuk-input--width-12"
|
||||||
|
showErrorBottom={true}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="gouk-grid-row"
|
||||||
|
style={{ display: "flex" }}
|
||||||
>
|
>
|
||||||
X
|
<button
|
||||||
</button>
|
type="button"
|
||||||
|
title="Remove"
|
||||||
|
onClick={() => fields.remove(index)}
|
||||||
|
className="govuk-button fieldArrayDelete"
|
||||||
|
>
|
||||||
|
X
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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:{" "}
|
||||||
|
|||||||
+216
-235
@@ -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
|
props={props}
|
||||||
.ticketnumber
|
ticketnumber={ticketnumber}
|
||||||
}
|
/>
|
||||||
props={props}
|
),
|
||||||
ticketnumber={
|
"{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}": (
|
||||||
props.props.props.appealType.caseReference
|
<PickList
|
||||||
.ticketnumber
|
name={datafieldname}
|
||||||
}
|
label={label}
|
||||||
/>
|
datafieldname={datafieldname}
|
||||||
);
|
picklistData={picklistData}
|
||||||
break;
|
validation={validation}
|
||||||
case "{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}":
|
hint={hint}
|
||||||
return (
|
/>
|
||||||
<PickList
|
),
|
||||||
name={props.datafieldname}
|
"{67FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}": (
|
||||||
label={props.label}
|
<YesNofield
|
||||||
datafieldname={props.datafieldname}
|
name={datafieldname}
|
||||||
picklistData={props.picklistData}
|
label={label}
|
||||||
validation={props.validation}
|
requiredDocumentValue={requiredDocumentValue}
|
||||||
hint={props.hint}
|
requiredDocumentLabel={requiredDocumentLabel}
|
||||||
/>
|
validation={validation}
|
||||||
);
|
setDocumentsList={setDocumentsList}
|
||||||
break;
|
documentList={documentList}
|
||||||
case "{67FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}":
|
form={form}
|
||||||
return (
|
formProps={formProps}
|
||||||
<YesNofield
|
parentField={parentField}
|
||||||
name={props.datafieldname}
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
label={props.label}
|
/>
|
||||||
requiredDocumentValue={props.requiredDocumentValue}
|
),
|
||||||
requiredDocumentLabel={props.requiredDocumentLabel}
|
"{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}": (
|
||||||
validation={props.validation}
|
<Radiofield
|
||||||
setDocumentsList={props.setDocumentsList}
|
name={datafieldname}
|
||||||
documentList={props.documentList}
|
label={label}
|
||||||
form={props.props.props.form}
|
datafieldname={datafieldname}
|
||||||
formProps={props.props.props.props.form}
|
options={datafieldcontent}
|
||||||
parentField={props.parentField}
|
inline={false}
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
hint={hint}
|
||||||
/>
|
form={form}
|
||||||
);
|
formProps={formProps}
|
||||||
break;
|
parentField={parentField}
|
||||||
case "{07FAC785-CD58-4f9f-ABB3-4B7DDC6ED5ED}":
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
return (
|
validation={validation}
|
||||||
<Radiofield
|
setDocumentsList={setDocumentsList}
|
||||||
name={props.datafieldname}
|
documentList={documentList}
|
||||||
label={props.label}
|
requiredDocumentValue={requiredDocumentValue}
|
||||||
datafieldname={props.datafieldname}
|
requiredDocumentLabel={requiredDocumentLabel}
|
||||||
options={props.datafieldcontent}
|
/>
|
||||||
inline={false}
|
),
|
||||||
hint={props.hint}
|
"{4273EDBD-AC1D-40d3-9FB2-095C621B552D}": (
|
||||||
form={props.props.props.form}
|
<Textfield
|
||||||
formProps={props.props.props.props.form}
|
name={datafieldname}
|
||||||
parentField={props.parentField}
|
label={label}
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
props={props}
|
||||||
validation={props.validation}
|
ticketnumber={ticketnumber}
|
||||||
setDocumentsList={props.setDocumentsList}
|
form={form}
|
||||||
documentList={props.documentList}
|
formProps={formProps}
|
||||||
requiredDocumentValue={props.requiredDocumentValue}
|
parentField={parentField}
|
||||||
requiredDocumentLabel={props.requiredDocumentLabel}
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
/>
|
validation={validation}
|
||||||
);
|
hint={hint}
|
||||||
break;
|
maxFieldLength={maxFieldLength}
|
||||||
case "{4273EDBD-AC1D-40d3-9FB2-095C621B552D}":
|
/>
|
||||||
const required = (value) =>
|
),
|
||||||
value ? undefined : t("newappeal:is-required-label");
|
"{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}": (
|
||||||
|
<DateFieldPicker
|
||||||
return (
|
name={datafieldname}
|
||||||
<Textfield
|
label={label}
|
||||||
name={props.datafieldname}
|
form={form}
|
||||||
label={props.label}
|
formProps={formProps}
|
||||||
props={props}
|
parentField={parentField}
|
||||||
ticketnumber={
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
props.props.props.appealType.caseReference
|
validation={validation}
|
||||||
.ticketnumber
|
dateStart={dateStart}
|
||||||
}
|
dateEnd={dateEnd}
|
||||||
form={props.props.props.form}
|
hint={hint}
|
||||||
formProps={props.props.props.props.form}
|
/>
|
||||||
parentField={props.parentField}
|
),
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
"{E0DECE4B-6FC8-4a8f-A065-082708572369}": (
|
||||||
validation={props.validation}
|
<MultiLinefield
|
||||||
hint={props.hint}
|
name={datafieldname}
|
||||||
maxFieldLength={props.maxFieldLength}
|
label={label}
|
||||||
/>
|
form={form}
|
||||||
);
|
formProps={formProps}
|
||||||
break;
|
parentField={parentField}
|
||||||
case "{5B773807-9FB2-42db-97C3-7A91EFF8ADFF}":
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
return (
|
validation={validation}
|
||||||
<DateFieldPicker
|
maxFieldLength={maxFieldLength}
|
||||||
name={props.datafieldname}
|
hint={hint}
|
||||||
label={props.label}
|
/>
|
||||||
form={props.props.props.form}
|
),
|
||||||
formProps={props.props.props.props.form}
|
"{E0DECE4B-6666-4a8f-A065-082708572369}": (
|
||||||
parentField={props.parentField}
|
<RichMultiLinefield
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
name={datafieldname}
|
||||||
validation={props.validation}
|
label={label}
|
||||||
dateStart={props.dateStart}
|
form={form}
|
||||||
dateEnd={props.dateEnd}
|
formProps={formProps}
|
||||||
hint={props.hint}
|
parentField={parentField}
|
||||||
/>
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
);
|
validation={validation}
|
||||||
break;
|
maxFieldLength={maxFieldLength}
|
||||||
case "{E0DECE4B-6FC8-4a8f-A065-082708572369}":
|
hint={hint}
|
||||||
return (
|
/>
|
||||||
<MultiLinefield
|
),
|
||||||
name={props.datafieldname}
|
"{C6D124CA-7EDA-4a60-AEA9-7FB8D318B68F}": (
|
||||||
label={props.label}
|
<NumericField
|
||||||
form={props.props.props.form}
|
name={datafieldname}
|
||||||
formProps={props.props.props.props.form}
|
label={label}
|
||||||
parentField={props.parentField}
|
form={form}
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
formProps={formProps}
|
||||||
validation={props.validation}
|
validation={validation}
|
||||||
maxFieldLength={props.maxFieldLength}
|
parentField={parentField}
|
||||||
hint={props.hint}
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
/>
|
maxFieldLength={maxFieldLength}
|
||||||
);
|
/>
|
||||||
break;
|
),
|
||||||
case "{E0DECE4B-6666-4a8f-A065-082708572369}":
|
"{C3EFE0C3-0EC6-42be-8349-CBD9079DFD8E}": (
|
||||||
return (
|
<DecimalField
|
||||||
<RichMultiLinefield
|
name={datafieldname}
|
||||||
name={props.datafieldname}
|
label={label}
|
||||||
label={props.label}
|
form={form}
|
||||||
form={props.props.props.form}
|
formProps={formProps}
|
||||||
formProps={props.props.props.props.form}
|
validation={validation}
|
||||||
parentField={props.parentField}
|
parentField={parentField}
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
validation={props.validation}
|
maxFieldLength={maxFieldLength}
|
||||||
maxFieldLength={props.maxFieldLength}
|
/>
|
||||||
hint={props.hint}
|
),
|
||||||
/>
|
"{16D63FD6-119B-4353-BDCA-18358721C3FE}": (
|
||||||
);
|
<div className="govuk-!-margin-bottom-9">
|
||||||
break;
|
<FileUploadField
|
||||||
case "{C6D124CA-7EDA-4a60-AEA9-7FB8D318B68F}":
|
name={datafieldname}
|
||||||
return (
|
label={label}
|
||||||
<NumericField
|
ticketnumber={ticketnumber}
|
||||||
name={props.datafieldname}
|
documentTypeCode={documentTypeCode}
|
||||||
label={props.label}
|
hint={hint}
|
||||||
form={props.props.props.form}
|
fileList={fileList}
|
||||||
formProps={props.props.props.props.form}
|
setFilesForAppeal={setFilesForAppeal}
|
||||||
validation={props.validation}
|
containerID={containerID}
|
||||||
parentField={props.parentField}
|
uploadCount={uploadCount}
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
setFileCount={setFileCount}
|
||||||
maxFieldLength={props.maxFieldLength}
|
setUploadCount={setUploadCount}
|
||||||
/>
|
props={props?.props?.props}
|
||||||
);
|
/>
|
||||||
break;
|
</div>
|
||||||
case "{C3EFE0C3-0EC6-42be-8349-CBD9079DFD8E}":
|
),
|
||||||
return (
|
"{0273EDBD-AC1D-40d3-9FB2-095C621B552D}": (
|
||||||
<DecimalField
|
<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}
|
||||||
validation={props.validation}
|
parentField={parentField}
|
||||||
parentField={props.parentField}
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
maxSubField={maxSubField}
|
||||||
maxFieldLength={props.maxFieldLength}
|
/>
|
||||||
/>
|
),
|
||||||
);
|
"{9EF39988-22BB-4f0b-BBBE-64B5A3748AEE}": (
|
||||||
break;
|
<CheckBoxfield
|
||||||
case "{16D63FD6-119B-4353-BDCA-18358721C3FE}":
|
name={datafieldname}
|
||||||
return (
|
label={label}
|
||||||
<div className="govuk-!-margin-bottom-9">
|
props={props}
|
||||||
<FileUploadField
|
form={form}
|
||||||
name={props.datafieldname}
|
formProps={formProps}
|
||||||
label={props.label}
|
parentField={parentField}
|
||||||
ticketnumber={
|
parentFieldShowOnValue={parentFieldShowOnValue}
|
||||||
props.props.props.props.appealType.caseReference
|
validation={validation}
|
||||||
.ticketnumber
|
/>
|
||||||
}
|
),
|
||||||
documentTypeCode={props.documentTypeCode}
|
|
||||||
hint={props.hint}
|
|
||||||
fileList={
|
|
||||||
props.props.props.props.appealType.fileList
|
|
||||||
}
|
|
||||||
setFilesForAppeal={
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "{0273EDBD-AC1D-40d3-9FB2-095C621B552D}":
|
|
||||||
return (
|
|
||||||
<FieldArrayForm
|
|
||||||
name={props.datafieldname}
|
|
||||||
label={props.label}
|
|
||||||
form={props.props.props.form}
|
|
||||||
formProps={props.props.props.props.form}
|
|
||||||
parentField={props.parentField}
|
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
|
||||||
maxSubField={props.maxSubField}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
case "{9EF39988-22BB-4f0b-BBBE-64B5A3748AEE}":
|
|
||||||
return (
|
|
||||||
<CheckBoxfield
|
|
||||||
name={props.datafieldname}
|
|
||||||
label={props.label}
|
|
||||||
props={props}
|
|
||||||
form={props.props.props.form}
|
|
||||||
formProps={props.props.props.props.form}
|
|
||||||
parentField={props.parentField}
|
|
||||||
parentFieldShowOnValue={props.parentFieldShowOnValue}
|
|
||||||
validation={props.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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,31 +4,65 @@ 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();
|
progObj,
|
||||||
|
titleList,
|
||||||
|
currentSection,
|
||||||
|
documentListObj,
|
||||||
|
formObjXML,
|
||||||
|
mandatoryFieldsData,
|
||||||
|
gotoSection,
|
||||||
|
setCurrentSection,
|
||||||
|
props: outerProps,
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { locale } = router;
|
const { locale } = router;
|
||||||
|
|
||||||
const {
|
// Helper to safely access nested form values
|
||||||
progObj,
|
const getFormValue = (field) =>
|
||||||
titleList,
|
outerProps?.props?.form?.appealForm?.values?.[field];
|
||||||
currentSection,
|
|
||||||
documentListObj,
|
|
||||||
formObjXML,
|
|
||||||
mandatoryFieldsData,
|
|
||||||
gotoSection,
|
|
||||||
setCurrentSection,
|
|
||||||
} = props;
|
|
||||||
const parser = new DOMParser();
|
|
||||||
|
|
||||||
//const progObj = getProgressObj(
|
const renderDocumentList = () => {
|
||||||
// formObjXML,
|
const formValues = outerProps?.props?.form?.appealForm?.values || {};
|
||||||
// titleList,
|
|
||||||
// mandatoryFieldsData,
|
|
||||||
// props
|
|
||||||
// );
|
|
||||||
|
|
||||||
//console.log(progObj);
|
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,16 +74,17 @@ 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"
|
||||||
className="app-step-nav app-step-nav--active"
|
className="app-step-nav app-step-nav--active"
|
||||||
data-id="e01e924b-9c7c-4c71-8241-66a575c2f61f"
|
data-id="e01e924b-9c7c-4c71-8241-66a575c2f61f"
|
||||||
data-show-text="show"
|
data-show-text="show"
|
||||||
data-hide-text="hide"
|
data-hide-text="hide"
|
||||||
@@ -57,290 +92,105 @@ 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={
|
.toString()
|
||||||
"app-step-nav__step js-step app-step-nav__step--active" +
|
.replace(/\s+/g, "-")
|
||||||
(progObj[index].allFieldsComplete
|
.toLowerCase();
|
||||||
? " sectionComplete"
|
|
||||||
: " sectionIncomplete")
|
return (
|
||||||
}
|
<li
|
||||||
aria-current="step"
|
key={key}
|
||||||
data-show=""
|
className={`app-step-nav__step js-step app-step-nav__step--active ${
|
||||||
id={FieldsTranslations(progObj[index].title)
|
step.allFieldsComplete
|
||||||
.toString()
|
? "sectionComplete"
|
||||||
.replace(/\s+/g, "-")
|
: "sectionIncomplete"
|
||||||
.toLowerCase()}
|
}`}
|
||||||
>
|
aria-current="step"
|
||||||
<div
|
data-show=""
|
||||||
className="app-step-nav__header js-toggle-panel "
|
id={stepId}
|
||||||
data-position={index}
|
|
||||||
>
|
>
|
||||||
<h3 className="app-step-nav__title ">
|
<div
|
||||||
<span className="app-step-nav__circle app-step-nav__circle--number">
|
className="app-step-nav__header js-toggle-panel"
|
||||||
<span className="app-step-nav__circle-inner">
|
data-position={index}
|
||||||
<span className="app-step-nav__circle-background">
|
>
|
||||||
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
|
<h3 className="app-step-nav__title">
|
||||||
Step
|
<span className="app-step-nav__circle app-step-nav__circle--number">
|
||||||
</span>{" "}
|
<span className="app-step-nav__circle-inner">
|
||||||
{index + 1}
|
<span className="app-step-nav__circle-background">
|
||||||
<span
|
<span className="app-step-nav__circle-step-label govuk-visually-hidden">
|
||||||
className="app-step-nav__circle-step-colon govuk-visually-hidden"
|
Step
|
||||||
aria-hidden="true"
|
</span>{" "}
|
||||||
>
|
{index + 1}
|
||||||
:
|
<span
|
||||||
|
className="app-step-nav__circle-step-colon govuk-visually-hidden"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
:
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
|
||||||
|
|
||||||
<span className="js-step-title">
|
<span className="js-step-title">
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
onClick={() => {
|
onClick={(e) => {
|
||||||
gotoSection(
|
e.preventDefault();
|
||||||
parseInt(key) + 1
|
gotoSection(
|
||||||
);
|
parseInt(key, 10) +
|
||||||
}}
|
1
|
||||||
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
|
);
|
||||||
aria-expanded="false"
|
}}
|
||||||
aria-controls={
|
className="app-step-nav__button app-step-nav__button--title js-step-title-button"
|
||||||
"step-panel-" +
|
aria-expanded="false"
|
||||||
FieldsTranslations(
|
aria-controls={`step-panel-${stepId}`}
|
||||||
progObj[index].title
|
|
||||||
)
|
|
||||||
.toString()
|
|
||||||
.replace(/\s+/g, "-")
|
|
||||||
.toLowerCase()
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<span className="js-step-title-text govuk-!-font-size-16">
|
|
||||||
{FieldsTranslations(
|
|
||||||
progObj[index].title
|
|
||||||
)}{" "}
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
</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 className="js-step-title-text govuk-!-font-size-16">
|
||||||
</span>
|
{FieldsTranslations(
|
||||||
|
step.title
|
||||||
|
)}{" "}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</h3>
|
||||||
</span>
|
</div>
|
||||||
|
</li>
|
||||||
<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">
|
{renderDocumentList()}
|
||||||
<li>{t("newappeal:application-form")}</li>
|
</ol>
|
||||||
|
</li>
|
||||||
{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>
|
|
||||||
</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);
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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"
|
||||||
}
|
}
|
||||||
@@ -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
@@ -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';`;
|
||||||
|
|||||||
+165
-362
@@ -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
|
|
||||||
|
|
||||||
//jump out page for duplicates....
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
"Number of contacts with this email:",
|
|
||||||
loggedInUser.value.length
|
|
||||||
);
|
|
||||||
if (loggedInUser.value.length > 1) {
|
|
||||||
return {
|
|
||||||
redirect: {
|
|
||||||
destination:
|
|
||||||
ctx.locale == "cy"
|
|
||||||
? "/cy/manylionpellach"
|
|
||||||
: "/furtherdetails",
|
|
||||||
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 loggedInUserResponse = await getPortalLogin(
|
||||||
|
thisSession.user.email
|
||||||
|
);
|
||||||
|
const contacts = loggedInUserResponse?.value || [];
|
||||||
|
|
||||||
|
if (contacts.length > 1) {
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination:
|
||||||
|
locale === "cy"
|
||||||
|
? "/cy/manylionpellach"
|
||||||
|
: "/furtherdetails",
|
||||||
|
permanent: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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,290 +238,141 @@ 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) => {
|
||||||
|
return el.pinswg_representationsubmitted != null;
|
||||||
|
});
|
||||||
|
|
||||||
let showSubmittedReps = (submittedArr) => {
|
if (accountDetails.errorCode) {
|
||||||
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 (_.has(accountDetails, "errorCode") != false) {
|
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
destination: "/myportal/error",
|
destination: "/myportal/error",
|
||||||
permanent: false,
|
permanent: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
const [
|
|
||||||
myCasesDetails,
|
|
||||||
watchedCasesDetails,
|
|
||||||
mySubmittedRepsDetails,
|
|
||||||
myRepresentationsDetails,
|
|
||||||
] = await Promise.all([
|
|
||||||
await getDetails(myCases, "myCases"),
|
|
||||||
await getDetails(filteredWatchedCases, "myWatchedCases"),
|
|
||||||
await getDetails(mySubmittedReps, "mySubmittedReps"),
|
|
||||||
await getDetails(myRepresentations, "myRepresentations"),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// console.log(
|
|
||||||
// "=================================\nmySubmittedRepsDetails:",
|
|
||||||
// mySubmittedRepsDetails
|
|
||||||
// );
|
|
||||||
|
|
||||||
store.dispatch(setAccountDetails(accountDetails));
|
|
||||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
|
||||||
store.dispatch(setMyCases(myCases));
|
|
||||||
store.dispatch(setMyCasesDetails(myCasesDetails));
|
|
||||||
store.dispatch(setMyRepresentations(myRepresentations));
|
|
||||||
store.dispatch(
|
|
||||||
setMyRepresentationsDetails(myRepresentationsDetails)
|
|
||||||
);
|
|
||||||
|
|
||||||
store.dispatch(setWatchedCases(filteredWatchedCases));
|
|
||||||
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
|
||||||
store.dispatch(setMySubmittedReps(mySubmittedReps));
|
|
||||||
store.dispatch(setMySubmittedRepsDetails(mySubmittedRepsDetails));
|
|
||||||
//store.dispatch(setAwaitingSubmission(awaitingSubmission));
|
|
||||||
store.dispatch(
|
|
||||||
setAwaitingSubmissionFromBlob(awaitingSubmissionFromBlob)
|
|
||||||
);
|
|
||||||
|
|
||||||
store.dispatch(
|
|
||||||
setAwaitingSubmissionDetails(awaitingSubmissionFromBlob)
|
|
||||||
);
|
|
||||||
store.dispatch(setContainerID(thisSession.user.id));
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
showFileUpload: process.env.SHOWFILEUPLOAD,
|
|
||||||
containerID: thisSession.user.id,
|
|
||||||
showLoginCheck: process.env.SHOWLOGIN,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 [
|
||||||
|
myCasesDetails,
|
||||||
|
watchedCasesDetails,
|
||||||
|
mySubmittedRepsDetails,
|
||||||
|
myRepresentationsDetails,
|
||||||
|
] = await Promise.all([
|
||||||
|
getDetails(myCases, "myCases"),
|
||||||
|
getDetails(filteredWatchedCases, "myWatchedCases"),
|
||||||
|
getDetails(mySubmittedReps, "mySubmittedReps"),
|
||||||
|
getDetails(myRepresentations, "myRepresentations"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
store.dispatch(setAccountDetails(accountDetails));
|
||||||
|
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||||
|
store.dispatch(setMyCases(myCases));
|
||||||
|
store.dispatch(setMyCasesDetails(myCasesDetails));
|
||||||
|
store.dispatch(setMyRepresentations(myRepresentations));
|
||||||
|
store.dispatch(setMyRepresentationsDetails(myRepresentationsDetails));
|
||||||
|
store.dispatch(setWatchedCases(filteredWatchedCases));
|
||||||
|
store.dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
||||||
|
store.dispatch(setMySubmittedReps(mySubmittedReps));
|
||||||
|
store.dispatch(setMySubmittedRepsDetails(mySubmittedRepsDetails));
|
||||||
|
store.dispatch(
|
||||||
|
setAwaitingSubmissionFromBlob(awaitingSubmissionFromBlob)
|
||||||
|
);
|
||||||
|
store.dispatch(
|
||||||
|
setAwaitingSubmissionDetails(awaitingSubmissionFromBlob)
|
||||||
|
);
|
||||||
|
store.dispatch(setContainerID(thisSession.user.id));
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
showFileUpload: Boolean(process.env.SHOWFILEUPLOAD),
|
||||||
|
containerID: thisSession.user.id,
|
||||||
|
showLoginCheck,
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// const getDetails = async (resultsObj, detailsType) => {
|
const mapStateToProps = (state) => ({
|
||||||
// let detailsArr = [];
|
accountDetails: state.accountDetails,
|
||||||
// const limitRequests = pLimit(1); // Limit to 5 concurrent requests
|
currentView: state.currentView,
|
||||||
|
search: state.search,
|
||||||
// resultsObj =
|
searchResultsObj: state.searchResultsObj,
|
||||||
// detailsType == "mySubmittedReps" ? resultsObj : resultsObj.value;
|
formData: state.formData,
|
||||||
|
appealType: state.appealType,
|
||||||
// if (detailsType == "myRepresentations") {
|
form: state.form,
|
||||||
// limitRequests(async () => {
|
myCases: state.myCases,
|
||||||
// resultsObj.map((searchDetail, index) => {
|
watchedCases: state.watchedCases,
|
||||||
// detailsArr.push(
|
myRepresentations: state.myRepresentations,
|
||||||
// getCase(searchDetail["incidentID"])
|
mySubmittedReps: state.myRepresentations.mySubmittedReps,
|
||||||
// .then(async (data) => {
|
awaitingSubmission: state.awaitingSubmission,
|
||||||
// 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,
|
|
||||||
currentView: state.currentView,
|
|
||||||
search: state.search,
|
|
||||||
searchResultsObj: state.searchResultsObj,
|
|
||||||
formData: state.formData,
|
|
||||||
appealType: state.appealType,
|
|
||||||
form: state.form,
|
|
||||||
myCases: state.myCases,
|
|
||||||
watchedCases: state.watchedCases,
|
|
||||||
myRepresentations: state.myRepresentations,
|
|
||||||
mySubmittedReps: state.myRepresentations.mySubmittedReps,
|
|
||||||
awaitingSubmission: state.awaitingSubmission,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(Home);
|
export default connect(mapStateToProps)(Home);
|
||||||
|
|||||||
Reference in New Issue
Block a user