updated cookie login and watched cases

This commit is contained in:
2021-11-03 08:24:54 +00:00
parent 30a7e426af
commit fa4c765799
20 changed files with 208 additions and 130 deletions
+2 -6
View File
@@ -368,9 +368,7 @@ const Breadcrumbs = (props) => {
href={
router.locale == "cy"
? router.locale + "/myportal"
: "/myportal?q=" +
props.props.accountDetails
.loggedinUserId
: "/myportal"
}
>
<a className="govuk-breadcrumbs__link">
@@ -401,9 +399,7 @@ const Breadcrumbs = (props) => {
href={
router.locale == "cy"
? router.locale + "/myportal"
: "/myportal?q=" +
props.props.accountDetails
.loggedinUserId
: "/myportal"
}
>
<a className="govuk-breadcrumbs__link">
+3 -1
View File
@@ -6,6 +6,7 @@ import Banner from "../components/banner";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import { setLogout } from "../store/accountDetails/action";
import _ from "lodash";
import { parseCookies, setCookie, destroyCookie } from "nookies";
const Header = (props) => {
let { t, lang } = useTranslation();
@@ -211,7 +212,8 @@ const Header = (props) => {
>
<a
onClick={() => {
window.localStorage.clear();
destroyCookie(null, "pinsUser"),
window.localStorage.clear();
}}
className="govuk-header__link govuk-!-margin-right-3"
>
+16 -2
View File
@@ -1,5 +1,5 @@
import Link from "next/link";
import { useState } from "react";
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import useTranslation from "next-translate/useTranslation";
import { connect } from "react-redux";
@@ -7,6 +7,7 @@ import { Field, reduxForm } from "redux-form";
import LoadingOverlay from "react-loading-overlay";
import { getLogin } from "../../actions";
import { setLoggedInUserId } from "../../store/accountDetails/action";
import { parseCookies, setCookie, destroyCookie } from "nookies";
const required = (errorMsg) => (value) =>
value || typeof value === "number" ? undefined : errorMsg;
@@ -128,17 +129,30 @@ let Login = (props) => {
data.value.length != 0
? (setValidLoginID(true),
setLoggedInUserId(data.value[0].contactid),
setCookie(null, "pinsUser", data.value[0].contactid, {
path: "/",
}),
spinnerState(),
router.replace({
pathname:
router.locale == "cy" ? "/fymhorth" : "/myportal",
query: { q: data.value[0].contactid },
shallow: true,
}))
: (setShowSpinnerState(false), setValidLoginID(false));
});
};
const cookies = parseCookies();
useEffect(() => {
cookies.pinsUser != null || typeof cookies.pinsUser != "undefined"
? (spinnerState(),
router.replace("/myportal", null, {
shallow: true,
}))
: "";
}, []);
return (
<div className="card" id="login-card">
<form onSubmit={handleSubmit(onHandleSubmit)}>
+5
View File
@@ -98,6 +98,11 @@ const TopThree = (props) => {
"currentReference":
showTopThreeArr[key].ticketnumber,
"currentType": topThreeType,
"incidentid":
showTopThreeArr[key].incidentid,
"appealType":
showTopThreeArr[key]
.pinswg_appealcasetype,
});
}}
>
+3
View File
@@ -28,6 +28,9 @@ const ViewAllResults = (props) => {
"currentReference":
resultsArr[index].reference,
"currentType": currentView.viewKey,
"incidentid": resultsArr[index].incidentid,
"appealType":
resultsArr[index].pinswg_appealcasetype,
});
}}
>
+11 -6
View File
@@ -11,15 +11,17 @@ export default function YourAccount() {
<>
<div className="card" id="casescomment-card">
<div className="card-body">
<h3 className="heading-small card-heading">Your details</h3>
<h3 className="heading-small card-heading">
{t("myportal:yourdetails-card-title")}
</h3>
<p className="govuk-body-s">
You can change your address and contact details
{t("myportal:yourdetails-card-paragraph-one")}
</p>
<div>
<Link href="/account/personaldetails">
<a className="govuk-button-secondary">
View your account details
{t("myportal:yourdetails-card-link")}
</a>
</Link>
</div>
@@ -28,14 +30,17 @@ export default function YourAccount() {
<div className="card" id="casescomment-card">
<div className="card-body">
<h3 className="heading-small card-heading">
Change your password
{t("myportal:changepassword-card-title")}
</h3>
<p className="govuk-body-s">You can change your password</p>
<p className="govuk-body-s">
{" "}
{t("myportal:changepassword-card-paragraph-one")}
</p>
<div>
<Link href="/account/changepassword">
<a className="govuk-button-secondary">
Update your password
{t("myportal:changepassword-card-link")}
</a>
</Link>
</div>
+8 -22
View File
@@ -9,6 +9,7 @@ import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import { setCurrentSection } from "../../store/appealType/action";
import { updateCase } from "../../actions";
import jsonpath from "jsonpath";
import { getFormCollectionByID } from "../utils";
import data from "../../data/collections.json";
@@ -18,12 +19,11 @@ let CompleteAppeal = (props) => {
let incidentId = props.appealType.caseReference.incidentid;
let updateBody = props.props.form.appealForm.values;
let appTypeCollection = getFormCollectionByID(
props.appealType.appealTypeID
);
let updateBindAppealTypeToIncident =
"pinswg_" +
props.appealType.caseReference[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
].replace(/(\band|[\s\-\+\(\)\,\&])/g, "") +
"Ids";
appTypeCollection.LogicalName + "Ids";
Object.assign(updateBody, {
"pinswg_Appellant@odata.bind":
@@ -40,23 +40,9 @@ let CompleteAppeal = (props) => {
updateBody = updateBody.replace(/:"Yes"/gm, `:true`);
updateBody = updateBody.replace(/:"No"/gm, `:false`);
updateBody = JSON.parse(updateBody);
let updateFormCollection = getFormCollection(
"pinswg_" +
props.appealType.caseReference[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
]
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
.toLowerCase()
);
let primaryAttribute = getPrimaryAttr(
"pinswg_" +
props.appealType.caseReference[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
]
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
.toLowerCase()
);
let updateFormCollection = appTypeCollection.LogicalCollectionName;
let primaryAttribute = appTypeCollection.PrimaryIdAttribute;
updateCase(
incidentId,
@@ -75,7 +61,7 @@ let CompleteAppeal = (props) => {
const getFormCollection = (formtype) => {
const collectionName = jsonpath.query(
data,
"$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
"$..[?(@.LogicalName=='" + formtype + "')]"
);
//console.log(collectionName[0]);
return collectionName[0];
+5 -28
View File
@@ -8,6 +8,7 @@ import { reduxForm, formValueSelector, Field } from "redux-form";
import { useDispatch, useSelector, shallowEqual, connect } from "react-redux";
import jsonpath from "jsonpath";
import transLookup from "../../data/lookuptranslations.json";
import { getFormCollectionByID } from "../utils";
import data from "../../data/collections.json";
import {
@@ -181,14 +182,7 @@ let CreateCase = (props) => {
)
? ""
: optionsObj[key]
.attributevalue +
"," +
optionsObj[key].value
.replace(
/(\band|[\s\-\+\(\)\,\&])/g,
""
)
.toLowerCase()
.attributevalue
}
>
{_.isEmpty(optionsObj[key])
@@ -220,34 +214,17 @@ let CreateCase = (props) => {
const required = (value) => (value ? undefined : "Required");
const getFormCollection = (formtype) => {
formtype =
"pinswg_" +
(formtype.length > 39 ? formtype.slice(0, 39) : formtype);
const collectionName = jsonpath.query(
data,
"$..[?(@.LogicalName=='" + formtype + "')].UrlName"
);
//console.log(collectionName[0]);
return collectionName[0];
};
const onHandleSubmit = (values) => {
event.preventDefault();
var appTypeCollection = values.appealTypes.split(",")[1];
var appTypeCollection = values.appealTypes;
appTypeCollection = getFormCollection(
appTypeCollection.length > 39
? appTypeCollection.slice(0, 39)
: appTypeCollection
);
appTypeCollection = getFormCollectionByID(appTypeCollection);
router.replace(
(router.locale = "cy" ? "/apelnewydd" : "/newappeal") +
"/" +
appTypeCollection +
appTypeCollection.UrlName +
"?lpa=" +
values.lpaTypes +
"&apt=" +
+23 -1
View File
@@ -37,6 +37,7 @@ const SearchResults = (props) => {
setSearchResults,
setSearchDetails,
advancedSearch,
myportal,
} = props;
let { t } = useTranslation();
@@ -76,6 +77,9 @@ const SearchResults = (props) => {
<dd className="govuk-summary-list__key govuk-!-font-size-16">
{t("search:searchresults-status-label")}
</dd>
{myportal == "true" && (
<dd className="govuk-summary-list__key govuk-!-font-size-16 govuk-summary-list__action"></dd>
)}
</div>
{resultsArr.map((item, key) => {
@@ -84,6 +88,7 @@ const SearchResults = (props) => {
"$..value[?(@.pinswg_name=='" + item.title + "')]"
);
detailsObj = detailsObj[0];
console.log(props.myportal);
return (
<div className="govuk-summary-list__row" key={key}>
@@ -91,7 +96,11 @@ const SearchResults = (props) => {
<Link
href={
router.locale == "cy"
? "/achos"
? myportal == "true"
? "/fymhorth/achos"
: "/achos"
: myportal == "true"
? "/myportal/case"
: "/case"
}
>
@@ -263,6 +272,19 @@ const SearchResults = (props) => {
"statuscode@OData.Community.Display.V1.FormattedValue"
] || "N/A"}
</dd>
{myportal == "true" && (
<dd className="govuk-summary-list__value govuk-!-font-size-14 govuk-summary-list__action">
<Link href="">
<a
className="govuk-summary-list__actionLink"
onClick={() => {}}
title="Watch this case"
>
+
</a>
</Link>
</dd>
)}
</div>
);
})}
+2 -1
View File
@@ -7,7 +7,7 @@ import SearchResults from "./search/searchresults";
import CRMError from "./crmError";
export default function Search(props) {
const { searchString, searchResultsObj, advancedSearch } = props;
const { searchString, searchResultsObj, advancedSearch, myportal } = props;
let { t } = useTranslation();
const router = useRouter();
@@ -40,6 +40,7 @@ export default function Search(props) {
searchDetailsObj={
searchResultsObj.searchDetailsObj
}
myportal={myportal}
/>
</div>
</div>