212 lines
9.5 KiB
JavaScript
212 lines
9.5 KiB
JavaScript
import { signOut } from "next-auth/react";
|
|
import useTranslation from "next-translate/useTranslation";
|
|
import Link from "next/link";
|
|
import { useRouter } from "next/router";
|
|
import { destroyCookie } from "nookies";
|
|
import TimeOut from "../components/timeout";
|
|
import AwaitingSubmissionFromBlob from "./myportal/awaitingsubmissionfromblob";
|
|
|
|
import _ from "lodash";
|
|
import Dns from "./myportal/dns";
|
|
import MakeNewAppeal from "./myportal/makenewappeal";
|
|
import MyCases from "./myportal/mycases";
|
|
import MyRepresentations from "./myportal/myrepresentations";
|
|
import SearchCases from "./myportal/searchcases";
|
|
import WatchedCases from "./myportal/watchedcases";
|
|
import MySubmittedReps from "./myportal/mysubmittedrepresentations";
|
|
import ServiceBanner from "./myportal/servicebanner";
|
|
import { JSONPath as jsonpath } from "jsonpath-plus";
|
|
import transLookup from "../data/lookuptranslations.json";
|
|
|
|
const MyPortal = (props) => {
|
|
const { showFileUpload, showLoginCheck } = props;
|
|
let { t } = useTranslation();
|
|
|
|
const router = useRouter();
|
|
const { locale } = router;
|
|
|
|
const handleLogout = () => {
|
|
console.info("////////////\n" + "logout" + "\n////////////");
|
|
window.localStorage.clear(),
|
|
destroyCookie(null, "next-auth.csrf-token", { path: "/" }),
|
|
destroyCookie(null, "next-auth.callback-url", { path: "/" }),
|
|
destroyCookie(null, "pedw_locale", { path: "/" }),
|
|
destroyCookie(null, "pinsUser", { path: "/" }),
|
|
signOut({
|
|
callbackUrl: locale == "cy" ? "/cy/allgofnodi" : "/logout",
|
|
});
|
|
};
|
|
|
|
const isLPA =
|
|
props.accountDetails.accountDetails[
|
|
"pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue"
|
|
] == "LPA"
|
|
? true
|
|
: false;
|
|
|
|
return (
|
|
<>
|
|
<main className="" id="main-content" role="main">
|
|
{/* <div className="servicebanner myportal govuk-!-margin-bottom-4">
|
|
<h1>
|
|
<img
|
|
src={
|
|
router.locale == "cy"
|
|
? "/assets/images/planning-casework-cy.svg"
|
|
: "/assets/images/planning-casework-en.svg"
|
|
}
|
|
alt={
|
|
router.locale == "cy"
|
|
? "Fy mhorth"
|
|
: "My Portal"
|
|
}
|
|
/>
|
|
</h1>
|
|
|
|
<div className="serviceBanner_userDetails">
|
|
<img
|
|
className="user_logo"
|
|
src="/assets/images/user.svg"
|
|
alt={router.locale == "cy" ? "Defnyddiwr" : "User"}
|
|
/>{" "}
|
|
<div className="serviceBanner_userDetails_name">
|
|
<Link
|
|
href="/account/personaldetails"
|
|
className="govuk-button-secondary"
|
|
>
|
|
{props.accountDetails.accountDetails.firstname}{" "}
|
|
{props.accountDetails.accountDetails.lastname}
|
|
{" - "}
|
|
{
|
|
props.accountDetails.accountDetails[
|
|
"pinswg_typeofinvolvement@OData.Community.Display.V1.FormattedValue"
|
|
]
|
|
}
|
|
</Link>
|
|
</div>
|
|
<div>
|
|
<Link
|
|
href={
|
|
router.locale == "cy"
|
|
? "/allgofnodi"
|
|
: "/logout"
|
|
}
|
|
onClick={() => {
|
|
handleLogout();
|
|
}}
|
|
className="govuk-header__link "
|
|
>
|
|
{t("common:signout-label")}
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
</div> */}
|
|
<ServiceBanner props={props} />
|
|
{isLPA && (
|
|
<div>
|
|
<h2 className="heading-small card-heading">
|
|
{router.locale == "cy"
|
|
? jsonpath({
|
|
path:
|
|
'$..[?(@ && @.value=="' +
|
|
props.accountDetails.accountDetails[
|
|
"pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue"
|
|
] +
|
|
'")].value_cy',
|
|
json: transLookup,
|
|
eval: true,
|
|
})
|
|
: props.accountDetails.accountDetails[
|
|
"pinswg_contact_associatedlpa@OData.Community.Display.V1.FormattedValue"
|
|
]}{" "}
|
|
{t("myportal:lpa-portal-heading")}
|
|
</h2>
|
|
</div>
|
|
)}
|
|
<div className="govuk-grid-row">
|
|
<div className="govuk-grid-column-full">
|
|
<div className="flex-container grid-row govuk-body ">
|
|
{!isLPA && <MakeNewAppeal />}
|
|
<SearchCases />
|
|
{/* {props.awaitingSubmission.awaitingSubmission[
|
|
"@odata.count"
|
|
] > 0 && (
|
|
<AwaitingSubmission
|
|
awaitingSubmission={
|
|
props.awaitingSubmission
|
|
}
|
|
/>
|
|
)} */}
|
|
|
|
{!isLPA &&
|
|
_.has(props.awaitingSubmission, [
|
|
"awaitingSubmissionFromBlob",
|
|
"@odata.count",
|
|
]) &&
|
|
props.awaitingSubmission
|
|
.awaitingSubmissionFromBlob[
|
|
"@odata.count"
|
|
] > 0 && (
|
|
<AwaitingSubmissionFromBlob
|
|
containerID={props.containerID}
|
|
awaitingSubmissionFromBlob={
|
|
props.awaitingSubmission
|
|
.awaitingSubmissionFromBlob
|
|
}
|
|
/>
|
|
)}
|
|
{props.myCases.myCases["@odata.count"] > 0 && (
|
|
<MyCases
|
|
myCases={props.myCases}
|
|
isLPA={isLPA}
|
|
/>
|
|
)}
|
|
{props.watchedCases.watchedCases["@odata.count"] >
|
|
0 && (
|
|
<WatchedCases
|
|
currentView={props.currentView}
|
|
watchedCases={props.watchedCases}
|
|
isLPA={isLPA}
|
|
myReps={false}
|
|
/>
|
|
)}
|
|
{props.myRepresentations.hasOwnProperty(
|
|
"myRepresentations"
|
|
) &&
|
|
typeof props.myRepresentations
|
|
.myRepresentations != "undefined" &&
|
|
props.myRepresentations.myRepresentations[
|
|
"@odata.count"
|
|
] > 0 && (
|
|
<MyRepresentations
|
|
myRepresentations={
|
|
props.myRepresentations
|
|
}
|
|
isLPA={isLPA}
|
|
/>
|
|
)}
|
|
|
|
{props.myRepresentations.mySubmittedReps
|
|
.mySubmittedReps.length > 0 && (
|
|
<MySubmittedReps
|
|
currentView={props.currentView}
|
|
mySubmittedReps={
|
|
props.myRepresentations.mySubmittedReps
|
|
}
|
|
isLPA={isLPA}
|
|
myReps={true}
|
|
/>
|
|
)}
|
|
{!isLPA && <Dns />}
|
|
{/* <YourAccount /> */}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
<TimeOut />
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default MyPortal;
|