From c1448b6ff64533dfe28d69f598d17c159fef3025 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Fri, 29 Oct 2021 16:29:04 +0100 Subject: [PATCH] updated drop downs --- .env.local | 20 ++++++------ components/header.js | 31 +++++++++++++----- components/homepage/login.js | 26 +++++++++------ components/main.js | 4 +-- components/myportal/mycases.js | 31 +++++++++--------- components/myportal/myrepresentations.js | 31 +++++++++--------- components/myportal/topthree.js | 25 ++++++++++++++- components/myportal/watchedcases.js | 30 +++++++++--------- components/search/advancedsearch.js | 12 +++++-- components/utils/index.js | 22 +++---------- data/collections.json | 2 +- data/lookuptranslations.json | 40 ++++++++++++++++++++++++ next.config.js | 8 +++++ pages/account/personaldetails.js | 4 +++ pages/myportal/index.js | 18 ++++++----- styles/sass/welshgov/_application.scss | 1 - 16 files changed, 204 insertions(+), 101 deletions(-) diff --git a/.env.local b/.env.local index 035eccf5..bdac164f 100644 --- a/.env.local +++ b/.env.local @@ -1,9 +1,9 @@ // dev -RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/ -RELAYURI = "dev-pedw-ns.servicebus.windows.net" -RELAYPATH = "dev-pedw-hc" -SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=" -SASKEYNAME = "devpedwnspolicy" +//RELAY_ROOT = https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/ +//RELAYURI = "dev-pedw-ns.servicebus.windows.net" +//RELAYPATH = "dev-pedw-hc" +//SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=" +//SASKEYNAME = "devpedwnspolicy" PORT= "3000" @@ -15,11 +15,11 @@ I18N_DOMAIN = "cymru.local" //I18N_DOMAIN ="gwaithcynllunio.gwasanaeth.llyw.cymru" //test -//RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ -//RELAYURI = "test-pedw-ns.servicebus.windows.net" -//RELAYPATH = "test-pedw-hc" -//SASKEY = "kTLrs9UHwuW9Msc9uNfjf+89qLYT6ly80lK0zdTYJW4=" -//SASKEYNAME = "testpedwhcpolicy" +RELAY_ROOT = https://test-pedw-ns.servicebus.windows.net/test-pedw-hc/ +RELAYURI = "test-pedw-ns.servicebus.windows.net" +RELAYPATH = "test-pedw-hc" +SASKEY = "kTLrs9UHwuW9Msc9uNfjf+89qLYT6ly80lK0zdTYJW4=" +SASKEYNAME = "testpedwhcpolicy" //preprod diff --git a/components/header.js b/components/header.js index 042c2761..128ac19f 100644 --- a/components/header.js +++ b/components/header.js @@ -5,6 +5,7 @@ import useTranslation from "next-translate/useTranslation"; import Banner from "../components/banner"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; import { setLogout } from "../store/accountDetails/action"; +import _ from "lodash"; const Header = (props) => { let { t, lang } = useTranslation(); @@ -45,6 +46,8 @@ const Header = (props) => { } else { domainSwitch = process.env.I18N_DOMAIN; } + + console.log(_.isEmpty(router.query)); return (
{ + key + + "=" + + router.query[key] + ) + .join("&") + : _.isEmpty(router.query) != false + ? router.asPath + + "?" + + Object.keys(router.query) + .map( + (key) => + key + "=" + router.query[key] + ) + .join("&") : router.asPath } locale={locale == "en" ? "cy" : "en"} diff --git a/components/homepage/login.js b/components/homepage/login.js index 3daef51a..ac52a10f 100644 --- a/components/homepage/login.js +++ b/components/homepage/login.js @@ -113,6 +113,7 @@ let Login = (props) => { const { locale } = router; const [showSpinnerState, setShowSpinnerState] = useState(false); + const [validLoginID, setValidLoginID] = useState(null); let spinnerState = () => { showSpinnerState == true @@ -124,14 +125,17 @@ let Login = (props) => { spinnerState(); getLogin(values.loginUserID, values.loginUserPassword).then((data) => { - setLoggedInUserId(data.value[0].contactid); - - spinnerState(); - router.replace({ - pathname: router.locale == "cy" ? "/fymhorth" : "/myportal", - query: { q: data.value[0].contactid }, - shallow: true, - }); + data.value.length != 0 + ? (setValidLoginID(true), + setLoggedInUserId(data.value[0].contactid), + spinnerState(), + router.replace({ + pathname: + router.locale == "cy" ? "/fymhorth" : "/myportal", + query: { q: data.value[0].contactid }, + shallow: true, + })) + : (setShowSpinnerState(false), setValidLoginID(false)); }); }; @@ -142,7 +146,11 @@ let Login = (props) => {

{t("home:login-card-title")}

- + {validLoginID == false && ( +
+ Incorrect username or password +
+ )} - {/* - */} + {/* + */} diff --git a/components/myportal/mycases.js b/components/myportal/mycases.js index 1726e8a7..f53f2521 100644 --- a/components/myportal/mycases.js +++ b/components/myportal/mycases.js @@ -24,21 +24,22 @@ const MyCases = (props) => { topThreeType={"myCases"} /> - - + {props.myCases.myCases["@odata.count"] != 0 && ( + + )} ); diff --git a/components/myportal/myrepresentations.js b/components/myportal/myrepresentations.js index 3f1a1cf3..3c622cb5 100644 --- a/components/myportal/myrepresentations.js +++ b/components/myportal/myrepresentations.js @@ -25,20 +25,23 @@ const MyRepresentations = (props) => { /> - + {props.myRepresentations.myRepresentations["@odata.count"] != + 0 && ( + + )} ); diff --git a/components/myportal/topthree.js b/components/myportal/topthree.js index c2c52db9..306ff1a1 100644 --- a/components/myportal/topthree.js +++ b/components/myportal/topthree.js @@ -140,7 +140,30 @@ const TopThree = (props) => { ); }); - return <>{topthreeRow}; + let noRecordsLabel = ""; + switch (topThreeType) { + case "watchedCases": + noRecordsLabel = "You are not watching any cases"; + break; + case "myRepresentations": + noRecordsLabel = "You have no representations"; + break; + case "myCases": + noRecordsLabel = "You have no cases"; + break; + case "awaitingSubmission": + noRecordsLabel = "You have no awaiting submissions"; + break; + } + return ( + <> + {topthreeRow.length == 0 ? ( +
{noRecordsLabel}
+ ) : ( + topthreeRow + )} + + ); }; const mapDispatchToProps = (dispatch) => { diff --git a/components/myportal/watchedcases.js b/components/myportal/watchedcases.js index de0cee07..47b487e8 100644 --- a/components/myportal/watchedcases.js +++ b/components/myportal/watchedcases.js @@ -25,20 +25,22 @@ const WatchedCases = (props) => { /> - + {props.watchedCases.watchedCases["@odata.count"] != 0 && ( + + )} ); diff --git a/components/search/advancedsearch.js b/components/search/advancedsearch.js index 1b4be97f..0721210b 100644 --- a/components/search/advancedsearch.js +++ b/components/search/advancedsearch.js @@ -249,9 +249,15 @@ let AdvancedSearch = (props) => { ("apt=" + values.appealTypes.split(",")[0]) : ""; - router.replace("/advancedsearchresults" + searchString, null, { - shallow: true, - }); + router.replace( + (router.locale == "cy" + ? "/canlyniadauchwiliouwch" + : "/advancedsearchresults") + searchString, + null, + { + shallow: true, + } + ); }; return ( diff --git a/components/utils/index.js b/components/utils/index.js index 35eaf98b..a77cde8a 100644 --- a/components/utils/index.js +++ b/components/utils/index.js @@ -39,16 +39,10 @@ export const getSearchDetails = (token, searchResultsObj) => { if (searchDetail.pinswg_appealcasetype == null) { console.log(searchDetail.title); } else { - let formMeta = getFormCollection( - "pinswg_" + - searchDetail[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] - .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") - .toLowerCase() - .slice(0, 39) + let formMeta = getFormCollectionByID( + searchDetail.pinswg_appealcasetype ); - + //console.log(formMeta); detailsArr.push( getBasicSearchDetails( token, @@ -79,14 +73,8 @@ export const getSearchDetailsPaged = (searchResultsObj) => { if (searchDetail.pinswg_appealcasetype == null) { console.log(searchDetail.title); } else { - let formMeta = getFormCollection( - "pinswg_" + - searchDetail[ - "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" - ] - .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") - .toLowerCase() - .slice(0, 39) + let formMeta = getFormCollectionByID( + searchDetail.pinswg_appealcasetype ); detailsArr.push( diff --git a/data/collections.json b/data/collections.json index 8a128efc..6d29d42c 100644 --- a/data/collections.json +++ b/data/collections.json @@ -259,7 +259,7 @@ { "LogicalCollectionName": "pinswg_hedgeshedgerowstreepreservationreplacems", "LogicalName": "pinswg_hedgeshedgerowstreepreservationreplacem", - "PrimaryIdAttribute": "pinswg_hedgeshedgerowstreepreservatioids", + "PrimaryIdAttribute": "pinswg_hedgeshedgerowstreepreservatioid", "UrlName": "hedgeshedgerowstreepreservationreplacem", "MetadataId": "60f38fed-5382-eb11-aac0-00224800be9c", "appealTypeID": "846040017" diff --git a/data/lookuptranslations.json b/data/lookuptranslations.json index 665106c4..98ad578c 100644 --- a/data/lookuptranslations.json +++ b/data/lookuptranslations.json @@ -24,6 +24,12 @@ "stringmapid": "cf4aa9f2-e275-eb11-aabd-00224800be9c", "attributevalue": 846040004 }, + { + "value": "Householder and Minor Commercial Appeals - HAS/CAS", + "value_cy": "Apeliadau Deiliaid Tai a Mân Apeliadau Masnachol", + "stringmapid": "cf4aa9f2-e275-eb11-aabd-00224800be9c", + "attributevalue": 846040004 + }, { "value": "Enforcement Notice Appeal - S174", "value_cy": "Apêl Hysbysiad Gorfodi - A174", @@ -54,6 +60,12 @@ "stringmapid": "ba56f05c-7f90-eb11-aac2-00224800be9c", "attributevalue": 846040009 }, + { + "value": "Called In Applications - S77", + "value_cy": "Cais a Alwyd i Mewn - A77", + "stringmapid": "bb56f05c-7f90-eb11-aac2-00224800be9c", + "attributevalue": 846040010 + }, { "value": "Call-Ins - S77", "value_cy": "Galwadau i Mewn - A77", @@ -66,6 +78,12 @@ "stringmapid": "bc56f05c-7f90-eb11-aac2-00224800be9c", "attributevalue": 846040011 }, + { + "value": "Developments of National Significance", + "value_cy": "Datblygiad o Arwyddocâd Cenedlaethol", + "stringmapid": "bc56f05c-7f90-eb11-aac2-00224800be9c", + "attributevalue": 846040011 + }, { "value": "Electricity Act", "value_cy": "Deddf Trydan", @@ -90,6 +108,12 @@ "stringmapid": "c056f05c-7f90-eb11-aac2-00224800be9c", "attributevalue": 846040015 }, + { + "value": "Rights of Way", + "value_cy": "Hawliau Tramwy", + "stringmapid": "c056f05c-7f90-eb11-aac2-00224800be9c", + "attributevalue": 846040015 + }, { "value": "Common Land", "value_cy": "Tir Comin", @@ -149,6 +173,12 @@ "value_cy": "Caniatâd Adeilad Rhestredig ac Ardal Gadwraeth - A20", "stringmapid": "977522df-8aef-eb11-aac7-00224800be9c", "attributevalue": 846040025 + }, + { + "value": "Listed Building and Conservation Area Consent", + "value_cy": "Caniatâd Adeilad Rhestredig ac Ardal Gadwraeth - A20", + "stringmapid": "977522df-8aef-eb11-aac7-00224800be9c", + "attributevalue": 846040025 } ], "statusCodes": [ @@ -301,6 +331,11 @@ "value_cy": "Cyngor Bwrdeistref Sirol Rhondda Cynon Taf", "pinswg_lpa": 0 }, + { + "value": "Rhondda Cynon Taf County Borough Council", + "value_cy": "Cyngor Bwrdeistref Sirol Rhondda Cynon Taf", + "pinswg_lpa": 0 + }, { "value": "Rhondda Cynon Taf CBC", "value_cy": "Cyngor Bwrdeistref Sirol Rhondda Cynon Taf", @@ -326,6 +361,11 @@ "value_cy": "Cyngor Bro Morgannwg", "pinswg_lpa": 0 }, + { + "value": "Vale of Glamorgan Borough Council", + "value_cy": "Cyngor Bro Morgannwg", + "pinswg_lpa": 0 + }, { "value": "Wrexham County Borough Council", "value_cy": "Cyngor Bwrdeistref Sirol Wrecsam", diff --git a/next.config.js b/next.config.js index 687dbf46..0c1c7ee3 100644 --- a/next.config.js +++ b/next.config.js @@ -49,6 +49,14 @@ module.exports = { source: "/fymhorth/chwiliouwch", destination: "/myportal/advancedsearch", }, + { + source: "/canlyniadauchwiliouwch", + destination: "/advancedsearchresults", + }, + { + source: "/fymhorth/canlyniadauchwiliouwch", + destination: "/myportal/advancedsearchresults", + }, { source: "/fymhorth", destination: "/myportal", diff --git a/pages/account/personaldetails.js b/pages/account/personaldetails.js index 4cb102c3..04645ae1 100644 --- a/pages/account/personaldetails.js +++ b/pages/account/personaldetails.js @@ -19,6 +19,7 @@ import { reduxForm, formValueSelector } from "redux-form"; import PersonalDetails from "../../components/account/personaldetails"; import { setAccountDetails } from "../../store/accountDetails/action"; import { getPersonalAccount } from "../../actions"; +import { setCookie } from "nookies"; const Home = (props) => { const { footerLinks, formData } = props; @@ -32,6 +33,9 @@ const Home = (props) => { useState(false); const [accountUpdatedComplete, setAccountUpdatedComplete] = useState(false); + setCookie(null, "pinsUser", props.accountDetails.loggedinUserId), + { path: "/" }; + return (
diff --git a/pages/myportal/index.js b/pages/myportal/index.js index 47cbef79..96072b93 100644 --- a/pages/myportal/index.js +++ b/pages/myportal/index.js @@ -151,9 +151,9 @@ export const getServerSideProps = wrapper.getServerSideProps( const { cookies } = req; - console.log(cookies); const token = await getSASToken(); + console.log("does it have ", cookies.pinsUser); let loggedInUser = typeof query.q == undefined ? cookies.pinsUser : query.q; @@ -173,23 +173,28 @@ export const getServerSideProps = wrapper.getServerSideProps( await getAwaitingSubmission(token), ]); - console.log("perosnal: ", accountDetails); - //const cookiesMaker = nookies.get(ctx) let now = new Date(); let expDate = new Date(now); expDate.setDate(now.getDate() + 1); - nookies.set(ctx, "pinsUser", query.q, { + console.log( + "Check: ", + cookies, + cookies.pinsUser, + loggedInUser, + nookies.get("pinsUser") + ); + + nookies.set(ctx, "pinsUser", loggedInUser, { expires: expDate, httpOnly: false, + path: "/", }); console.log(" from cookie ", cookies); - console.log(myCases); - const [ myCasesDetails, myRepresentationsDetails, @@ -202,7 +207,6 @@ export const getServerSideProps = wrapper.getServerSideProps( // await getDetails(awaitingSubmission), ]); - console.log(myCasesDetails); store.dispatch(setAccountDetails(accountDetails)); store.dispatch(setLoggedInUserId(loggedInUser)); store.dispatch(setMyCases(myCases)); diff --git a/styles/sass/welshgov/_application.scss b/styles/sass/welshgov/_application.scss index a03b73d0..91a16514 100644 --- a/styles/sass/welshgov/_application.scss +++ b/styles/sass/welshgov/_application.scss @@ -276,7 +276,6 @@ textarea, .govuk-select { appearance: none; - width: 100%; margin-bottom: 20px; background-image: url(/assets/images/select-down-arrow.svg); background-size: 19px 12px;