diff --git a/actions/index.js b/actions/index.js index 76fb4818..d193e1b4 100644 --- a/actions/index.js +++ b/actions/index.js @@ -657,7 +657,7 @@ export const getLPA = (token) => { }; export const getPersonalAccount = (token, contactid) => { - console.log("getting personal details:", contactid); + //console.log("getting personal details:", contactid); return axios .get( WEBAPI_URL + @@ -682,7 +682,6 @@ export const getPersonalAccount = (token, contactid) => { }; export const getAppealID = ( - token, caseReference, updateFormCollection, primaryAttribute @@ -696,9 +695,9 @@ export const getAppealID = ( caseReference + "'"; - console.log("proxy url", weburl); + console.log("proxy url ", weburl); return axios - .get(weburl, azureHeaders(token)) + .get(weburl, azureHeaders(getSASToken())) .then((res) => { var appealID = res.data.value[0][primaryAttribute]; return appealID; @@ -723,13 +722,14 @@ export const getLogin = (emailAddress, pwd) => { }); }; -export const createCase = (token, appealTypeId, contactid) => { +export const createCase = (token, appealTypeId, lpaID, contactid) => { appealTypeId = parseInt(appealTypeId); var data = JSON.stringify({ "title": "insertion test case", "caseorigincode": 3, "customerid_contact@odata.bind": "/contacts(" + contactid + ")", "pinswg_appealcasetype": appealTypeId, + "pinswg_AssociatedLPA@odata.bind": "/accounts(" + lpaID + ")", }); var config = { @@ -757,7 +757,6 @@ export const createCase = (token, appealTypeId, contactid) => { }; export const updateCase = async ( - token, incidentId, updateBody, updateFormCollection, @@ -784,15 +783,15 @@ export const updateCase = async ( "Accept": "application/json", "Prefer": 'odata.include-annotations="*",return=representation', "Content-Type": "application/json", - "ServiceBusAuthorization": token, + "ServiceBusAuthorization": getSASToken(), }, data: data, }; - console.log(config); + //console.log(config); return axios(config) .then((res) => { - console.log("patched ", res.data); + //console.log("patched ", res.data); return res.data; }) .catch((error) => { @@ -801,7 +800,7 @@ export const updateCase = async ( }; export const getMyCases = (token, loggedInUserId) => { - console.log("in action ", loggedInUserId); + //console.log("in action ", loggedInUserId); return axios .get( WEBAPI_URL + @@ -839,24 +838,18 @@ export const getMyRepresentations = (token, loggedInUserId) => { }; export const getWatchedCases = (token, loggedInUserId) => { - return ( - axios - - // .get(BASE_URL + "/api/lookups/watchedCases", { - // httpsAgent: new https.Agent({ rejectUnauthorized: false }), - // }) - .get( - WEBAPI_URL + - "incidents?$select=ticketnumber,casetypecode,createdon,_customerid_value,description,incidentid,pinswg_appealcasetype,_pinswg_assignedinspectrids_value,statecode,statuscode,title&$filter=_customerid_value eq " + - loggedInUserId + - " and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3", - azureHeaders(token) - ) - .then((res) => res.data) - .catch((error) => { - console.log("this serror", error); - }) - ); + return axios + .get( + WEBAPI_URL + + "contacts(" + + loggedInUserId + + ")/pinswg_contact_incident?$count=true&$top=3&$orderby=createdon desc", + azureHeaders(token) + ) + .then((res) => res.data) + .catch((error) => { + console.log("this serror", error); + }); }; export const getAwaitingSubmission = (token) => { @@ -870,7 +863,7 @@ export const getAwaitingSubmission = (token) => { }); }; -export const getPortalModuelDetails = (token, appealType, caseReference) => { +export const getPortalModuleDetails = (token, appealType, caseReference) => { return axios .get( WEBAPI_URL + diff --git a/components/breadcrumbs.js b/components/breadcrumbs.js index 44061a11..0d76a426 100644 --- a/components/breadcrumbs.js +++ b/components/breadcrumbs.js @@ -368,9 +368,7 @@ const Breadcrumbs = (props) => { href={ router.locale == "cy" ? router.locale + "/myportal" - : "/myportal?q=" + - props.props.accountDetails - .loggedinUserId + : "/myportal" } > @@ -401,9 +399,7 @@ const Breadcrumbs = (props) => { href={ router.locale == "cy" ? router.locale + "/myportal" - : "/myportal?q=" + - props.props.accountDetails - .loggedinUserId + : "/myportal" } > diff --git a/components/header.js b/components/header.js index 128ac19f..7ee807ac 100644 --- a/components/header.js +++ b/components/header.js @@ -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) => { > { - window.localStorage.clear(); + destroyCookie(null, "pinsUser"), + window.localStorage.clear(); }} className="govuk-header__link govuk-!-margin-right-3" > diff --git a/components/homepage/login.js b/components/homepage/login.js index ac52a10f..9d0526dc 100644 --- a/components/homepage/login.js +++ b/components/homepage/login.js @@ -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 (
diff --git a/components/myportal/topthree.js b/components/myportal/topthree.js index 306ff1a1..2b4cfd1d 100644 --- a/components/myportal/topthree.js +++ b/components/myportal/topthree.js @@ -98,6 +98,11 @@ const TopThree = (props) => { "currentReference": showTopThreeArr[key].ticketnumber, "currentType": topThreeType, + "incidentid": + showTopThreeArr[key].incidentid, + "appealType": + showTopThreeArr[key] + .pinswg_appealcasetype, }); }} > diff --git a/components/myportal/viewall.js b/components/myportal/viewall.js index 54d25673..f49d637a 100644 --- a/components/myportal/viewall.js +++ b/components/myportal/viewall.js @@ -28,6 +28,9 @@ const ViewAllResults = (props) => { "currentReference": resultsArr[index].reference, "currentType": currentView.viewKey, + "incidentid": resultsArr[index].incidentid, + "appealType": + resultsArr[index].pinswg_appealcasetype, }); }} > diff --git a/components/myportal/youraccount.js b/components/myportal/youraccount.js index 305b094f..afab86bc 100644 --- a/components/myportal/youraccount.js +++ b/components/myportal/youraccount.js @@ -11,15 +11,17 @@ export default function YourAccount() { <>
-

Your details

+

+ {t("myportal:yourdetails-card-title")} +

- You can change your address and contact details + {t("myportal:yourdetails-card-paragraph-one")}

- View your account details + {t("myportal:yourdetails-card-link")}
@@ -28,14 +30,17 @@ export default function YourAccount() {

- Change your password + {t("myportal:changepassword-card-title")}

-

You can change your password

+

+ {" "} + {t("myportal:changepassword-card-paragraph-one")} +

diff --git a/components/newappeal/complete.js b/components/newappeal/complete.js index 84501620..e7ee1daa 100644 --- a/components/newappeal/complete.js +++ b/components/newappeal/complete.js @@ -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]; diff --git a/components/newappeal/createCase.js b/components/newappeal/createCase.js index c864a6f6..949f7e71 100644 --- a/components/newappeal/createCase.js +++ b/components/newappeal/createCase.js @@ -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=" + diff --git a/components/search/searchresults.js b/components/search/searchresults.js index bea46654..879f1cb1 100644 --- a/components/search/searchresults.js +++ b/components/search/searchresults.js @@ -37,6 +37,7 @@ const SearchResults = (props) => { setSearchResults, setSearchDetails, advancedSearch, + myportal, } = props; let { t } = useTranslation(); @@ -76,6 +77,9 @@ const SearchResults = (props) => {
{t("search:searchresults-status-label")}
+ {myportal == "true" && ( +
+ )}
{resultsArr.map((item, key) => { @@ -84,6 +88,7 @@ const SearchResults = (props) => { "$..value[?(@.pinswg_name=='" + item.title + "')]" ); detailsObj = detailsObj[0]; + console.log(props.myportal); return (
@@ -91,7 +96,11 @@ const SearchResults = (props) => { @@ -263,6 +272,19 @@ const SearchResults = (props) => { "statuscode@OData.Community.Display.V1.FormattedValue" ] || "N/A"} + {myportal == "true" && ( +
+ + {}} + title="Watch this case" + > + + + + +
+ )}
); })} diff --git a/components/searchresults.js b/components/searchresults.js index 4c015ac4..ad1555a7 100644 --- a/components/searchresults.js +++ b/components/searchresults.js @@ -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} />
diff --git a/data/collections.json b/data/collections.json index 6d29d42c..38bd23d0 100644 --- a/data/collections.json +++ b/data/collections.json @@ -202,7 +202,7 @@ }, { "LogicalCollectionName": "pinswg_householderappealhases", - "LogicalName": "pinswg_householderappealhas", + "LogicalName": "pinswg_HouseholderAppealHAS", "PrimaryIdAttribute": "pinswg_householderappealhasid", "UrlName": "householderappealhas", "MetadataId": "a6c728b0-9081-eb11-aac0-00224800be9c", diff --git a/locales/cy/myportal.json b/locales/cy/myportal.json index 82a52085..240792a3 100644 --- a/locales/cy/myportal.json +++ b/locales/cy/myportal.json @@ -19,5 +19,11 @@ "watchedcases-card-title": "Achosion a gwylio", "case-reference": "Cyfeirnod achos", "case-address": "Cyfeiriad", - "case-address-not-entered": "heb ei nodi" + "case-address-not-entered": "heb ei nodi", + "yourdetails-card-title": "Eich manylion", + "yourdetails-card-paragraph-one": "Gallwch newid eich cyfeiriad a'ch manylion cyswllt", + "yourdetails-card-link": "Gweld manylion eich cyfrif", + "changepassword-card-title": "Newid eich cyfrinair", + "changepassword-card-paragraph-one": "Gallwch chi newid eich cyfrinair", + "changepassword-card-link": "Diweddarwch eich cyfrinair" } \ No newline at end of file diff --git a/locales/en/myportal.json b/locales/en/myportal.json index d872218c..4af3f07c 100644 --- a/locales/en/myportal.json +++ b/locales/en/myportal.json @@ -12,12 +12,18 @@ "searchcases-card-search-example-label": "Example", "searchcases-card-button": "Submit Search", "searchcases-card-advanced-link": "Advanced Search", - "searchcases-search-validation-required": "Angenrheidiol", - "searchcases-search-validation-minlength": "Rhaid bod yn 4 nod neu fwy", + "searchcases-validation-required": "Required", + "searchcases-validation-minlength": "Must be 4 characters or more", "awatitingsubmission-card-title": "Awaiting submission", "myrepresentations-card-title": "My representations", "watchedcases-card-title": "Watched cases", "case-reference": "Case reference", "case-address": "Address", - "case-address-not-entered": "not entered" + "case-address-not-entered": "not entered", + "yourdetails-card-title": "Your details", + "yourdetails-card-paragraph-one": "You can change your address and contact details", + "yourdetails-card-link": "View your account details", + "changepassword-card-title": "Change your password", + "changepassword-card-paragraph-one": "You can change your password", + "changepassword-card-link": "Update your password" } \ No newline at end of file diff --git a/pages/index.js b/pages/index.js index f660c2d4..6b9797f9 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,4 +1,5 @@ import _ from "lodash"; +import { useState, useEffect, useRef } from "react"; import Head from "next/head"; import Header from "../components/header"; import ServiceBanner from "../components/servicebanner"; @@ -13,6 +14,7 @@ import { wrapper } from "../store/store"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { getIncidents } from "../actions"; +import { parseCookies } from "nookies"; const Home = (props) => { const { footerLinks, pages } = props; @@ -20,6 +22,7 @@ const Home = (props) => { const router = useRouter(); const { locale } = router; + return (
diff --git a/pages/myportal/case.js b/pages/myportal/case.js index 514f6380..8a449898 100644 --- a/pages/myportal/case.js +++ b/pages/myportal/case.js @@ -27,7 +27,9 @@ const Home = (props) => {
- {t("case:page-title")} - {t("common:service-name")} + {t("case:page-title")}:{" "} + {props.currentView.caseReference.currentReference}{" "} + {t("common:service-name")}{" "}
@@ -36,13 +38,21 @@ const Home = (props) => {
{ currentType={ props.currentView.caseReference.currentType } + appealTypeID={ + props.currentView.caseReference.appealType + } + incidentid={props.currentView.caseReference.incidentid} />