1029 lines
47 KiB
JavaScript
1029 lines
47 KiB
JavaScript
import Link from "next/link";
|
|
import { useRouter } from "next/router";
|
|
import { useState, useEffect, useRef } from "react";
|
|
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
|
|
import useTranslation from "next-translate/useTranslation";
|
|
import jsonpath from "jsonpath";
|
|
import _ from "lodash";
|
|
import transLookup from "../../data/lookuptranslations.json";
|
|
|
|
import {
|
|
getLinkedCases,
|
|
createWatchedCases,
|
|
getWatchedCasesProxy,
|
|
getPortalModuleDetailsProxy,
|
|
deleteWatchedCases,
|
|
} from "../../actions";
|
|
import {
|
|
setCurrentLinkedCases,
|
|
setCurrentReference,
|
|
} from "../../store/currentView/action";
|
|
|
|
import {
|
|
setWatchedCases,
|
|
setWatchedCasesDetails,
|
|
} from "../../store/watchedCases/action";
|
|
|
|
import { getFormCollectionByID } from "../utils";
|
|
import { getSession, useSession, signIn } from "next-auth/react";
|
|
import { parseCookies, setCookie, destroyCookie } from "nookies";
|
|
|
|
import Pinswg_advertsid from "./summaryTypes/pinswg_advertsid";
|
|
import Pinswg_callinss77id from "./summaryTypes/pinswg_callinss77id";
|
|
import Pinswg_commonlandid from "./summaryTypes/pinswg_commonlandid";
|
|
import Pinswg_communityinfrastructurelevyid from "./summaryTypes/pinswg_communityinfrastructurelevyid";
|
|
import Pinswg_compulsorypurchaseordersid from "./summaryTypes/pinswg_compulsorypurchaseordersid";
|
|
import Pinswg_dnsid from "./summaryTypes/pinswg_dnsid";
|
|
import Pinswg_electricityactid from "./summaryTypes/pinswg_electricityactid";
|
|
import Pinswg_enforcementlistedbuildingconseid from "./summaryTypes/pinswg_enforcementlistedbuildingconseid";
|
|
import Pinswg_enforcementnoticeappeals174id from "./summaryTypes/pinswg_enforcementnoticeappeals174id";
|
|
import Pinswg_environmentalpermittingid from "./summaryTypes/pinswg_environmentalpermittingid";
|
|
import Pinswg_harbourrevisionorderid from "./summaryTypes/pinswg_harbourrevisionorderid";
|
|
import Pinswg_hedgeshedgerowstreepreservatioid from "./summaryTypes/pinswg_hedgeshedgerowstreepreservatioid";
|
|
import Pinswg_householderappealhasid from "./summaryTypes/pinswg_householderappealhasid";
|
|
import Pinswg_lawfuldevelopmentcertificatappid from "./summaryTypes/pinswg_lawfuldevelopmentcertificatappid";
|
|
import Pinswg_ldpid from "./summaryTypes/pinswg_ldpid";
|
|
import Pinswg_listedbuildingandconservationrid from "./summaryTypes/pinswg_listedbuildingandconservationrid";
|
|
import Pinswg_maintenanceoflands217id from "./summaryTypes/pinswg_maintenanceoflands217id";
|
|
import Pinswg_miscellaneouscasewordid from "./summaryTypes/pinswg_miscellaneouscasewordid";
|
|
import Pinswg_nonvalidationid from "./summaryTypes/pinswg_nonvalidationid";
|
|
import Pinswg_planningappeals78id from "./summaryTypes/pinswg_planningappeals78id";
|
|
import Pinswg_planningconditionss73s79id from "./summaryTypes/pinswg_planningconditionss73s79id";
|
|
import Pinswg_planningobligationappeals106id from "./summaryTypes/pinswg_planningobligationappeals106id";
|
|
import Pinswg_rowid from "./summaryTypes/pinswg_rowid";
|
|
import Pinswg_transportandworkactid from "./summaryTypes/pinswg_transportandworkactid";
|
|
import Pinswg_wayleaveid from "./summaryTypes/pinswg_wayleaveid";
|
|
|
|
const CaseSummary = (props) => {
|
|
let { t } = useTranslation();
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
const {
|
|
appealTypeID,
|
|
incidentid,
|
|
caseReference,
|
|
myCases,
|
|
myRepresentations,
|
|
watchedCases,
|
|
awaitingSubmission,
|
|
searchResultsObj,
|
|
searchDetailsObj,
|
|
currentType,
|
|
setCurrentLinkedCases,
|
|
linkedCasesReference,
|
|
setCurrentReference,
|
|
setWatchedCases,
|
|
setWatchedCasesDetails,
|
|
showMap,
|
|
currentView,
|
|
} = props;
|
|
|
|
const showLoginCheck = currentView.showLogin;
|
|
const { data: session, status } = useSession();
|
|
//console.log("session status:", status, session);
|
|
|
|
const cookies = parseCookies();
|
|
|
|
const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
|
|
let updateBody = {
|
|
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
|
|
"pinswg_Contact@odata.bind": "/contacts(" + loggedInUser + ")",
|
|
"pinswg_appealcasetype": +appealType,
|
|
};
|
|
|
|
createWatchedCases(updateBody)
|
|
.then((data) => data)
|
|
.then(() => {
|
|
getWatchedCasesProxy(loggedInUser).then((data) => {
|
|
setWatchedCases(data),
|
|
getDetails(data, "myWatchedCases").then((data) => {
|
|
setWatchedCasesDetails(data);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
|
|
const getDetails = (resultsObj, detailsType) => {
|
|
console.log(resultsObj);
|
|
let detailsArr = [];
|
|
resultsObj = resultsObj.value;
|
|
const detailsObj = resultsObj.map((searchDetail, index) => {
|
|
if (searchDetail.pinswg_appealcasetype == null) {
|
|
console.log(
|
|
detailsType != "myWatchedCases"
|
|
? searchDetail.ticketnumber
|
|
: searchDetail[
|
|
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
|
]
|
|
);
|
|
} else {
|
|
detailsArr.push(
|
|
getPortalModuleDetailsProxy(
|
|
getFormCollectionByID(
|
|
searchDetail.pinswg_appealcasetype
|
|
).LogicalCollectionName,
|
|
detailsType != "myWatchedCases"
|
|
? searchDetail.ticketnumber
|
|
: searchDetail[
|
|
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
|
|
]
|
|
)
|
|
);
|
|
}
|
|
});
|
|
//console.log(detailsArr);
|
|
return Promise.all(detailsArr);
|
|
};
|
|
|
|
const isWatchedCase = (whichIncident) => {
|
|
let isWatched = jsonpath.query(
|
|
watchedCases,
|
|
"$..value[?(@._pinswg_watchedcase_value=='" + whichIncident + "')]"
|
|
);
|
|
|
|
return isWatched;
|
|
};
|
|
|
|
const deleteItem = (caseID, topThreeType) => {
|
|
let cookies = parseCookies();
|
|
topThreeType == "watchedCases" &&
|
|
deleteWatchedCases(caseID)
|
|
.then((data) => data)
|
|
.then(() => {
|
|
getWatchedCasesProxy(cookies.pinsUser).then((data) => {
|
|
setWatchedCases(data),
|
|
getDetails(data, "myWatchedCases").then((data) => {
|
|
setWatchedCasesDetails(data);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
|
|
const noRepresentationLink = ["/dnsdetails", "/dns/[developmentName]"];
|
|
|
|
let setCaseQueryObj = props[currentType];
|
|
let setCaseDetailsObj = props[currentType + "Details"];
|
|
|
|
var casesObj = {};
|
|
|
|
currentType == "searchResultsObj"
|
|
? (casesObj = jsonpath.query(
|
|
searchResultsObj,
|
|
'$..[?(@.title=="' + caseReference + '")]'
|
|
))
|
|
: currentType == "watchedCases"
|
|
? (casesObj = jsonpath.query(
|
|
setCaseQueryObj,
|
|
'$..[?(@.pinswg_title=="' + caseReference + '")]'
|
|
))
|
|
: currentType == "myCases"
|
|
? (casesObj = jsonpath.query(
|
|
setCaseQueryObj,
|
|
'$..[?(@.pinswg_title=="' + caseReference + '")]'
|
|
))
|
|
: (casesObj = jsonpath.query(
|
|
setCaseQueryObj,
|
|
'$..[?(@.reference=="' + caseReference + '")]'
|
|
));
|
|
|
|
casesObj = Object.assign({}, ...casesObj);
|
|
|
|
var detailsObj = {};
|
|
|
|
currentType == "searchResultsObj"
|
|
? (detailsObj = jsonpath.query(
|
|
searchDetailsObj,
|
|
'$..[?(@.pinswg_name=="' + caseReference + '")]'
|
|
))
|
|
: (detailsObj = jsonpath.query(
|
|
setCaseDetailsObj,
|
|
'$..[?(@.pinswg_name=="' + caseReference + '")]'
|
|
));
|
|
|
|
detailsObj = detailsObj[0];
|
|
|
|
let showDetails = typeof detailsObj != "undefined" ? true : false;
|
|
|
|
var timestamp = showDetails
|
|
? detailsObj.hasOwnProperty("pinswg_representation_period_end_date")
|
|
? Date.parse(detailsObj.pinswg_representation_period_end_date)
|
|
: "n/a"
|
|
: "n/a";
|
|
|
|
if (isNaN(timestamp) == false) {
|
|
var d = new Date(timestamp);
|
|
}
|
|
|
|
let hasEndDate = typeof d != "undefined";
|
|
|
|
let showDetailsBlock =
|
|
showDetails == true ? (
|
|
<div>
|
|
<div className="govuk-grid-row">
|
|
<div className="govuk-grid-column-full">
|
|
<h1 className="govuk-heading-xl govuk-!-margin-bottom-7">
|
|
{t("case:summary-reference-label")}:{" "}
|
|
{currentType == "searchResultsObj"
|
|
? detailsObj.pinswg_name
|
|
: casesObj.reference}
|
|
</h1>
|
|
|
|
<dl className="govuk-summary-list govuk-!-margin-bottom-9">
|
|
<div className="govuk-summary-list__row">
|
|
<dt className="govuk-summary-list__key">
|
|
{getFormCollectionByID(appealTypeID)
|
|
.PrimaryIdAttribute == "pinswg_dnsid"
|
|
? t("case:summary-applicantonly-label")
|
|
: getFormCollectionByID(appealTypeID)
|
|
.PrimaryIdAttribute ==
|
|
"pinswg_nonvalidationid"
|
|
? t("case:summary-appellantonly-label")
|
|
: t("case:summary-applicant-label")}
|
|
</dt>
|
|
<dd className="govuk-summary-list__value">
|
|
{detailsObj[
|
|
"_pinswg_appellant_value@OData.Community.Display.V1.FormattedValue"
|
|
] || "not entered"}
|
|
</dd>
|
|
</div>
|
|
{detailsObj.pinswg_agentcontactname != null &&
|
|
(_.has(
|
|
detailsObj,
|
|
"pinswg_agentcontactname"
|
|
) ? (
|
|
<div className="govuk-summary-list__row">
|
|
<dt className="govuk-summary-list__key">
|
|
{t("case:summary-agent-label")}
|
|
</dt>
|
|
<dd className="govuk-summary-list__value">
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_agentcontactname"
|
|
)
|
|
? detailsObj.pinswg_agentcontactname
|
|
: ""}
|
|
</dd>
|
|
</div>
|
|
) : (
|
|
""
|
|
))}
|
|
<div className="govuk-summary-list__row">
|
|
<dt className="govuk-summary-list__key">
|
|
{t("case:summary-site-address-label")}
|
|
</dt>
|
|
<dd className="govuk-summary-list__value">
|
|
{getFormCollectionByID(appealTypeID)
|
|
.PrimaryIdAttribute == "pinswg_dnsid"
|
|
? detailsObj.pinswg_projectlocation !=
|
|
null
|
|
? detailsObj.pinswg_projectlocation.indexOf(
|
|
";"
|
|
) < 0
|
|
? detailsObj.pinswg_projectlocation
|
|
: router.locale == "cy"
|
|
? detailsObj.pinswg_projectlocation.split(
|
|
";"
|
|
)[1]
|
|
: detailsObj.pinswg_projectlocation.split(
|
|
";"
|
|
)[0]
|
|
: ""
|
|
: ""}
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_siteaddressline1"
|
|
)
|
|
? detailsObj.pinswg_siteaddressline1
|
|
: ""}
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_siteaddressline1"
|
|
) &&
|
|
detailsObj.pinswg_siteaddressline1 !=
|
|
null && <br />}
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_siteaddressline2"
|
|
)
|
|
? detailsObj.pinswg_siteaddressline2
|
|
: ""}
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_siteaddressline2"
|
|
) &&
|
|
detailsObj.pinswg_siteaddressline2 !=
|
|
null && <br />}
|
|
{_.has(detailsObj, "pinswg_siteaddresstown")
|
|
? detailsObj.pinswg_siteaddresstown
|
|
: ""}
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_siteaddresstown"
|
|
) &&
|
|
detailsObj.pinswg_siteaddresstown !=
|
|
null && <br />}
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_siteaddresscounty"
|
|
)
|
|
? detailsObj.pinswg_siteaddresscounty
|
|
: ""}
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_siteaddresscounty"
|
|
) &&
|
|
detailsObj.pinswg_siteaddresscounty !=
|
|
null && <br />}
|
|
{_.has(
|
|
detailsObj,
|
|
"pinswg_siteaddresspostcode"
|
|
)
|
|
? detailsObj.pinswg_siteaddresspostcode
|
|
: ""}
|
|
</dd>
|
|
</div>
|
|
{casesObj.description != null && (
|
|
<div className="govuk-summary-list__row">
|
|
<dt className="govuk-summary-list__key">
|
|
{t("case:summary-description-label")}
|
|
</dt>
|
|
<dd className="govuk-summary-list__value">
|
|
{casesObj.description.indexOf(";") < 0
|
|
? casesObj.description
|
|
: router.locale == "cy"
|
|
? casesObj.description.split(";")[1]
|
|
: casesObj.description.split(
|
|
";"
|
|
)[0]}
|
|
</dd>
|
|
</div>
|
|
)}
|
|
{detailsObj.pinswg_casestage != null && (
|
|
<div className="govuk-summary-list__row">
|
|
<dt className="govuk-summary-list__key">
|
|
{t("case:summary-case-stage-label")}
|
|
</dt>
|
|
<dd className="govuk-summary-list__value">
|
|
{router.locale == "cy"
|
|
? jsonpath.query(
|
|
transLookup,
|
|
'$..[?(@.value=="' +
|
|
detailsObj[
|
|
"pinswg_casestage@OData.Community.Display.V1.FormattedValue"
|
|
] +
|
|
'")].value_cy'
|
|
)
|
|
: detailsObj[
|
|
"pinswg_casestage@OData.Community.Display.V1.FormattedValue"
|
|
] ||
|
|
t(
|
|
"case:summary-no-date-entered-label"
|
|
)}
|
|
</dd>
|
|
</div>
|
|
)}
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
|
|
{showLoginCheck == "true" && (
|
|
<>
|
|
<div className="govuk-grid-row">
|
|
<div className="govuk-grid-column-full">
|
|
<div className="govuk-button-group">
|
|
{_.has(detailsObj, "pinswg_startdate") &&
|
|
showReps(
|
|
detailsObj.pinswg_startdate,
|
|
detailsObj.pinswg_finalcommentsduedate
|
|
) && (
|
|
<>
|
|
<Link
|
|
href={{
|
|
pathname:
|
|
"/myportal/representation",
|
|
query: {
|
|
case:
|
|
currentType ==
|
|
"searchResultsObj"
|
|
? detailsObj.pinswg_name
|
|
: currentType ==
|
|
"watchedCases"
|
|
? casesObj.pinswg_title
|
|
: casesObj.reference,
|
|
},
|
|
}}
|
|
className="govuk-button"
|
|
>
|
|
{t(
|
|
"case:summary-make-representation-label"
|
|
)}
|
|
</Link>
|
|
|
|
<a
|
|
onClick={() => {
|
|
//spinnerState();
|
|
router.back();
|
|
}}
|
|
className="govuk-button govuk-button--secondary"
|
|
>
|
|
{t(
|
|
"case:summary-back-button-label"
|
|
)}
|
|
</a>
|
|
</>
|
|
)}
|
|
<div className="govuk-body">
|
|
{session &&
|
|
(isWatchedCase(
|
|
props.currentView.caseReference
|
|
.incidentid
|
|
).length >
|
|
0 ==
|
|
true ? (
|
|
<span
|
|
className="govuk-link"
|
|
onClick={() => {
|
|
confirm(
|
|
t(
|
|
"case:you-have-stopped-watching-label"
|
|
) +
|
|
props
|
|
.currentView
|
|
.caseReference
|
|
.currentReference +
|
|
"?"
|
|
) &&
|
|
deleteItem(
|
|
isWatchedCase(
|
|
props
|
|
.currentView
|
|
.caseReference
|
|
.incidentid
|
|
)[0]
|
|
.pinswg_watchlistid,
|
|
|
|
"watchedCases"
|
|
);
|
|
}}
|
|
title={t(
|
|
"case:stop-watching-case-link"
|
|
)}
|
|
>
|
|
{t(
|
|
"case:stop-watching-case-link"
|
|
)}{" "}
|
|
</span>
|
|
) : (
|
|
<span
|
|
className=" govuk-link"
|
|
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"
|
|
)}
|
|
</span>
|
|
))}
|
|
|
|
{!session && (
|
|
<span
|
|
className="govuk-link"
|
|
onClick={() => {
|
|
// signIn("email");
|
|
// signIn();
|
|
// selectWatchedCase(
|
|
// cookies.pinsUser,
|
|
// item.incidentid,
|
|
// item.pinswg_appealcasetype
|
|
// );
|
|
// alert(
|
|
// "Trying to watch case " +
|
|
// item.title
|
|
// );
|
|
confirm(
|
|
"Trying to watch case " +
|
|
props.currentView
|
|
.caseReference
|
|
.currentReference +
|
|
"\n\nYou will now be prompted to sign in"
|
|
) &&
|
|
signIn("email", {
|
|
callbackUrl:
|
|
"/myportal/searchresults?q=" +
|
|
props
|
|
.currentView
|
|
.caseReference
|
|
.currentReference,
|
|
});
|
|
}}
|
|
title={t(
|
|
"case:watch-this-case-link"
|
|
)}
|
|
>
|
|
{t("case:watch-this-case-link")}
|
|
</span>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="govuk-grid-row">
|
|
<div className="govuk-grid-column-full">
|
|
{_.has(detailsObj, "pinswg_startdate") &&
|
|
showRepsEnded(
|
|
detailsObj.pinswg_startdate,
|
|
detailsObj.pinswg_finalcommentsduedate
|
|
) && (
|
|
<div className="govuk-body">
|
|
{t(
|
|
"case:representation-period-ended-on-label"
|
|
)}
|
|
|
|
{formatDates(
|
|
detailsObj.pinswg_finalcommentsduedate
|
|
)}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</>
|
|
)}
|
|
|
|
{showSummary(casesObj, detailsObj)}
|
|
</div>
|
|
) : (
|
|
<>
|
|
<div>
|
|
<div className="govuk-grid-row">
|
|
<div className="govuk-grid-column-full">
|
|
<h1>{t("case:summary-no-details-label")}</h1>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{showLoginCheck == "true" && (
|
|
<div className="govuk-grid-row">
|
|
<div className="govuk-grid-column-full">
|
|
<div className="govuk-button-group">
|
|
{noRepresentationLink.includes(
|
|
router.pathname
|
|
) == true ? (
|
|
""
|
|
) : (
|
|
<Link
|
|
href="/representation"
|
|
className="govuk-button"
|
|
>
|
|
{t(
|
|
"case:summary-make-representation-label"
|
|
)}
|
|
</Link>
|
|
)}
|
|
|
|
<a
|
|
onClick={() => {
|
|
// spinnerState();
|
|
router.back();
|
|
}}
|
|
className="govuk-button govuk-button--secondary"
|
|
>
|
|
{t("case:summary-back-button-label")}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
|
|
function showSummary(casesObj, detailsObj) {
|
|
let appealIDObj =
|
|
getFormCollectionByID(appealTypeID).PrimaryIdAttribute;
|
|
|
|
switch (appealIDObj) {
|
|
case "pinswg_advertsid":
|
|
return (
|
|
<Pinswg_advertsid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_callinss77id":
|
|
return (
|
|
<Pinswg_callinss77id
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_commonlandid":
|
|
return (
|
|
<Pinswg_commonlandid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_communityinfrastructurelevyid":
|
|
return (
|
|
<Pinswg_communityinfrastructurelevyid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
|
|
case "pinswg_compulsorypurchaseordersid":
|
|
return (
|
|
<Pinswg_compulsorypurchaseordersid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_dnsid":
|
|
return (
|
|
<Pinswg_dnsid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
showMap={showMap}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_electricityactid":
|
|
return (
|
|
<Pinswg_electricityactid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_enforcementlistedbuildingconseid":
|
|
return (
|
|
<Pinswg_enforcementlistedbuildingconseid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_enforcementnoticeappeals174id":
|
|
return (
|
|
<Pinswg_enforcementnoticeappeals174id
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_enforcementpermittingid":
|
|
return (
|
|
<Pinswg_environmentalpermittingid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_harbourrevisionorderid":
|
|
return (
|
|
<Pinswg_harbourrevisionorderid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_hedgeshedgerowstreepreservatioid":
|
|
return (
|
|
<Pinswg_hedgeshedgerowstreepreservatioid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_householderappealhasid":
|
|
return (
|
|
<Pinswg_householderappealhasid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_lawfuldevelopmentcertificatappid":
|
|
return (
|
|
<Pinswg_lawfuldevelopmentcertificatappid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_ldpid":
|
|
return (
|
|
<Pinswg_ldpid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_listedbuildingandconservationrid":
|
|
return (
|
|
<Pinswg_listedbuildingandconservationrid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_maintenanceoflands217id":
|
|
return (
|
|
<Pinswg_maintenanceoflands217id
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_miscellaneouscasewordid":
|
|
return (
|
|
<Pinswg_miscellaneouscasewordid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_nonvalidationid":
|
|
return (
|
|
<Pinswg_nonvalidationid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_planningappeals78id":
|
|
return (
|
|
<Pinswg_planningappeals78id
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
|
|
case "pinswg_planningconditionss73s79id":
|
|
return (
|
|
<Pinswg_planningconditionss73s79id
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
|
|
case "pinswg_planningobligationappeals106id":
|
|
return (
|
|
<Pinswg_planningobligationappeals106id
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_rowid":
|
|
return (
|
|
<Pinswg_rowid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_transportandworkactid":
|
|
return (
|
|
<Pinswg_transportandworkactid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
case "pinswg_wayleaveid":
|
|
return (
|
|
<Pinswg_wayleaveid
|
|
casesObj={casesObj}
|
|
detailsObj={detailsObj}
|
|
formatDates={formatDates}
|
|
linkedCasesList={linkedCasesList}
|
|
currentView={props.currentView}
|
|
/>
|
|
);
|
|
break;
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
const linkCaseObj = async () => {
|
|
let docObj = await getLinkedCases(incidentid).then((data) => {
|
|
//console.log(data);
|
|
setCurrentLinkedCases(data);
|
|
return data;
|
|
});
|
|
|
|
return linkCaseObj;
|
|
};
|
|
|
|
const linkedCases = linkCaseObj();
|
|
}, [incidentid, setCurrentLinkedCases]);
|
|
|
|
// const [showSpinnerState, setShowSpinnerState] = useState(false);
|
|
|
|
// let spinnerState = () => {
|
|
// showSpinnerState == true
|
|
// ? setShowSpinnerState(false)
|
|
// : setShowSpinnerState(true);
|
|
// };
|
|
|
|
function formatDates(dateObj, showTime) {
|
|
var dateObj = new Date(dateObj);
|
|
var dd = String(dateObj.getDate()).padStart(2, "0");
|
|
var mm = String(dateObj.getMonth() + 1).padStart(2, "0"); //January is 0!
|
|
var yyyy = dateObj.getFullYear();
|
|
var hh = dateObj.getHours();
|
|
hh = ("0" + hh).slice(-2);
|
|
var mins = dateObj.getMinutes();
|
|
mins = ("0" + mins).slice(-2);
|
|
|
|
const dateStr = showTime
|
|
? hh == 0 && mins == 0
|
|
? ""
|
|
: hh + ":" + mins
|
|
: dd + "/" + mm + "/" + yyyy + " ";
|
|
return dateStr;
|
|
}
|
|
|
|
function linkedCasesList(linkedCasesReference) {
|
|
//console.log(linkedCasesReference);
|
|
|
|
linkedCasesReference = linkedCasesReference.value || [];
|
|
|
|
return (
|
|
<>
|
|
<ul className="govuk-list govuk-!-font-size-16">
|
|
{linkedCasesReference.map((item, key) => {
|
|
return (
|
|
<li key={key}>
|
|
<Link
|
|
href={
|
|
router.locale == "cy"
|
|
? "/canlyniadauchwilio?q=" +
|
|
item.title +
|
|
"&lk=1"
|
|
: "/searchresults?q=" +
|
|
item.title +
|
|
"&lk=1"
|
|
}
|
|
className=""
|
|
>
|
|
{item.title}
|
|
</Link>
|
|
</li>
|
|
);
|
|
// console.log(item.incidentid, item.title);
|
|
})}
|
|
</ul>
|
|
</>
|
|
);
|
|
}
|
|
|
|
function showReps(startDate, endDate) {
|
|
let date = new Date();
|
|
date = new Date(date.toDateString());
|
|
const start = new Date(startDate);
|
|
const end = new Date(endDate);
|
|
|
|
return date >= start && date <= end ? true : false;
|
|
}
|
|
|
|
function showRepsEnded(startDate, endDate) {
|
|
let date = new Date();
|
|
date = new Date(date.toDateString());
|
|
const start = new Date(startDate);
|
|
const end = new Date(endDate);
|
|
return date > start && date > end ? true : false;
|
|
}
|
|
|
|
return <>{showDetailsBlock}</>;
|
|
};
|
|
|
|
const mapStateToProps = (state) => {
|
|
return {
|
|
...state,
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
return {
|
|
setCurrentLinkedCases: (parentIncidentid) => {
|
|
dispatch(setCurrentLinkedCases(parentIncidentid));
|
|
},
|
|
setCurrentReference: (currentReference) => {
|
|
dispatch(setCurrentReference(currentReference));
|
|
},
|
|
setWatchedCases: (watchedCases) => {
|
|
dispatch(setWatchedCases(watchedCases));
|
|
},
|
|
setWatchedCasesDetails: (watchedCasesDetails) => {
|
|
dispatch(setWatchedCasesDetails(watchedCasesDetails));
|
|
},
|
|
};
|
|
};
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(CaseSummary);
|