updated filelist obj to check else default to empty array
This commit is contained in:
+70
-34
@@ -3,7 +3,7 @@ import _ from "lodash";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { useEffect } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import transLookup from "../../data/lookuptranslations.json";
|
||||
import Documents from "./documents";
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
getLinkedCases,
|
||||
getPortalModuleDetailsProxy,
|
||||
getWatchedCasesProxy,
|
||||
setCaseInvolvment,
|
||||
} from "../../actions";
|
||||
import {
|
||||
setCurrentLinkedCases,
|
||||
@@ -56,6 +57,8 @@ import Pinswg_rowid from "./summaryTypes/pinswg_rowid";
|
||||
import Pinswg_transportandworkactid from "./summaryTypes/pinswg_transportandworkactid";
|
||||
import Pinswg_wayleaveid from "./summaryTypes/pinswg_wayleaveid";
|
||||
import CaseNoticeBanner from "./caseNoticeBanner";
|
||||
import WatchModal from "./watchmodal";
|
||||
|
||||
const CaseSummary = (props) => {
|
||||
let { t } = useTranslation();
|
||||
|
||||
@@ -88,6 +91,16 @@ const CaseSummary = (props) => {
|
||||
currentType == "directResultsObj" ? "true" : currentView.showLogin;
|
||||
const { data: session, status } = useSession();
|
||||
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
|
||||
const handleOpenModal = () => {
|
||||
setIsModalOpen(true);
|
||||
};
|
||||
|
||||
const handleCloseModal = () => {
|
||||
setIsModalOpen(false);
|
||||
};
|
||||
|
||||
const cookies = parseCookies();
|
||||
|
||||
const isLPA =
|
||||
@@ -114,6 +127,8 @@ const CaseSummary = (props) => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
setCaseInvolvment(incidentid, loggedInUser);
|
||||
};
|
||||
|
||||
const isWatchedCase = (whichIncident) => {
|
||||
@@ -586,39 +601,48 @@ const CaseSummary = (props) => {
|
||||
)}{" "}
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
className="govuk-link watchCase"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:you-are-watching-label"
|
||||
) +
|
||||
" " +
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference +
|
||||
"?"
|
||||
) &&
|
||||
selectWatchedCase(
|
||||
props
|
||||
.accountDetails
|
||||
.loggedinUserId,
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.incidentid,
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.appealType
|
||||
);
|
||||
}}
|
||||
>
|
||||
{t(
|
||||
"case:watch-this-case-link"
|
||||
)}
|
||||
</button>
|
||||
<>
|
||||
<button
|
||||
className="govuk-link watchCase"
|
||||
onClick={() => {
|
||||
confirm(
|
||||
t(
|
||||
"case:you-are-watching-label"
|
||||
) +
|
||||
" " +
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.currentReference +
|
||||
"?"
|
||||
) &&
|
||||
selectWatchedCase(
|
||||
props
|
||||
.accountDetails
|
||||
.loggedinUserId,
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.incidentid,
|
||||
props
|
||||
.currentView
|
||||
.caseReference
|
||||
.appealType
|
||||
);
|
||||
}}
|
||||
>
|
||||
{t(
|
||||
"case:watch-this-case-link"
|
||||
)}
|
||||
</button>
|
||||
{/* <button
|
||||
onClick={
|
||||
handleOpenModal
|
||||
}
|
||||
>
|
||||
Open Modal
|
||||
</button> */}
|
||||
</>
|
||||
))}
|
||||
|
||||
{!session && (
|
||||
@@ -669,6 +693,11 @@ const CaseSummary = (props) => {
|
||||
"case:watch-this-case-link"
|
||||
)}
|
||||
</button>
|
||||
{/* <button
|
||||
onClick={handleOpenModal}
|
||||
>
|
||||
Open Modal
|
||||
</button> */}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
@@ -714,6 +743,13 @@ const CaseSummary = (props) => {
|
||||
docsOffline={docsOffline}
|
||||
showFilteredDocs={props.showFilteredDocs}
|
||||
/>
|
||||
{/* <WatchModal
|
||||
isOpen={isModalOpen}
|
||||
onClose={handleCloseModal}
|
||||
casesObj={casesObj}
|
||||
currentType={currentType}
|
||||
props={props}
|
||||
/> */}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import { signOut } from "next-auth/react";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState, useEffect } from "react";
|
||||
import { destroyCookie, parseCookies, setCookie } from "nookies";
|
||||
import { signIn, useSession } from "next-auth/react";
|
||||
|
||||
const WatchModal = (props) => {
|
||||
let { t } = useTranslation();
|
||||
|
||||
const { isOpen, onClose } = props;
|
||||
|
||||
const currentType = props.currentType;
|
||||
const casesObj = props.casesObj;
|
||||
const { data: session, status } = useSession();
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
let now = new Date();
|
||||
let expDate = new Date(now);
|
||||
|
||||
expDate.setDate(now.getDate() + 365);
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={open ? "modal fade show" : "modal fade"}
|
||||
style={{
|
||||
display: open ? "flex" : "none",
|
||||
}}
|
||||
>
|
||||
<div className="modal-dialog">
|
||||
<div className="modal-content">
|
||||
<h3>Watch case</h3>
|
||||
<p className="govuk-body">
|
||||
{!session
|
||||
? " You will now be signed in to watch this case"
|
||||
: " you are logged in already"}
|
||||
</p>
|
||||
<div className="govuk-checkboxes__item">
|
||||
<input
|
||||
className="govuk-checkboxes__input"
|
||||
type="checkbox"
|
||||
name="addInvolvement"
|
||||
/>
|
||||
<label
|
||||
className="govuk-label-s govuk-checkboxes__label"
|
||||
htmlFor="addInvolvement"
|
||||
>
|
||||
{} Yes, I want you want to be emailed updates
|
||||
for case
|
||||
<div> {casesObj.title}</div>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<button
|
||||
className="govuk-button"
|
||||
onClick={() => {
|
||||
setCookie(
|
||||
null,
|
||||
"pedwWatchCase",
|
||||
currentType == "searchResultsObj"
|
||||
? detailsObj.pinswg_name
|
||||
: currentType == "directResultsObj"
|
||||
? casesObj.title
|
||||
: casesObj.reference,
|
||||
{
|
||||
path: "/",
|
||||
expires: expDate,
|
||||
}
|
||||
),
|
||||
signIn();
|
||||
}}
|
||||
>
|
||||
Yes
|
||||
</button>{" "}
|
||||
<button
|
||||
className="govuk-button govuk-button--secondary"
|
||||
onClick={onClose}
|
||||
>
|
||||
No
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-backdrop fade show"></div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default WatchModal;
|
||||
@@ -73,7 +73,9 @@ let BuildCheckSection = (props) => {
|
||||
//console.log("attached docs: - ", buildAppealFilesArray);
|
||||
buildAppealFilesArray = props.props.form.appealForm.values.filesList || [];
|
||||
|
||||
let filesUploadObj = props.appealType.fileList.value[0];
|
||||
let filesUploadObj = props.appealType.fileList.hasOwnProperty("value")
|
||||
? props.appealType.fileList.value[0]
|
||||
: [];
|
||||
|
||||
for (let key in filesUploadObj) {
|
||||
typeof filesUploadObj[key].name != "undefined" &&
|
||||
|
||||
Reference in New Issue
Block a user