From a5774534e377dadd103eae7fadaf00bc451f2763 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Tue, 14 Dec 2021 10:31:47 +0000 Subject: [PATCH] login error and mutlitlingual login flow --- components/header.js | 3 + components/homepage/casesearch.js | 1 - components/homepage/login.js | 111 ++++++++++++++++-------------- i18n.js | 1 + locales/cy/home.json | 5 +- locales/en/home.json | 5 +- pages/index.js | 55 +++++++++++---- pages/myportal/error.js | 50 ++++++++++++++ pages/myportal/index.js | 57 ++++++++------- 9 files changed, 198 insertions(+), 90 deletions(-) create mode 100644 pages/myportal/error.js diff --git a/components/header.js b/components/header.js index fe9f7e84..228df3e4 100644 --- a/components/header.js +++ b/components/header.js @@ -30,6 +30,9 @@ const Header = (props) => { "/dnsdetails", "/404", "/account/register", + "/myportal/error", + "/accessibility", + "/details-about-cookies", ]; const hasContactLink = [ "/dns", diff --git a/components/homepage/casesearch.js b/components/homepage/casesearch.js index b8675b73..1448217a 100644 --- a/components/homepage/casesearch.js +++ b/components/homepage/casesearch.js @@ -92,7 +92,6 @@ let CaseSearch = (props) => { ? "/canlyniadauchwilio" : "/searchresults", query: { q: values.basicSearch.trim() }, - shallow: true, }); }; diff --git a/components/homepage/login.js b/components/homepage/login.js index 0edba169..274256ec 100644 --- a/components/homepage/login.js +++ b/components/homepage/login.js @@ -207,55 +207,6 @@ let Login = (props) => {

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

{" "} - {/*
- {validLoginID == false && ( -
- Incorrect username or password -
- )} - - - - -
- - -
- */}

{ }} className="govuk-button withChevron govuk-button-cta" > - Log in via Government Gateway + {t("home:login-via-gov-gateway-label")}

@@ -291,6 +242,66 @@ let Login = (props) => { {t("home:login-card-forgotten-label")}{" "}

+
+

+ {t("home:login-comingsoon-temp-2")} +

+ +
+ +

+ {t("home:login-comingsoon-email-link-label")}{" "} + + {t("home:login-contact-email")} + +

diff --git a/i18n.js b/i18n.js index c32a759f..b80b503c 100644 --- a/i18n.js +++ b/i18n.js @@ -22,6 +22,7 @@ module.exports = { "/viewall": ["search"], "/case": ["case"], "/myportal/representation": ["case"], + "/myportal/error": ["myportal", "common"], "/newappeal": ["newappeal"], "/newappeal/*": ["newappeal"], "/newappeal/selectappeal": ["newappeal"], diff --git a/locales/cy/home.json b/locales/cy/home.json index d553c16a..4bef2d41 100644 --- a/locales/cy/home.json +++ b/locales/cy/home.json @@ -21,6 +21,7 @@ "login-card-register-link": "Gofrestru", "login-card-forgotten-label": "Rwyf wedi anghofio fy nghyfrinair", "login-card-forgotten-link": "Cliciwch yma", + "login-via-gov-gateway-label": "Mewngofnodi trwy Borth y Llywodraeth", "casesearch-card-title": "Chwilio apeliadau a Datblygiadau o Arwyddocâd Cenedlaethol", "casesearch-card-search-hint": "Defnyddiwch gyfeimod yr achos neu deitl DAC i chwilio. Bydd cyfeirnod yr achos yn debyg i un o'r canlynol:", "casesearch-card-search-example-label-1": "APP-A12345-A-21-1234567", @@ -37,5 +38,7 @@ "inspectorate-card-alt-text": "Yr Arolygiaeth Gynllunio", "dns-card-title": "Gweld yr holl Ddatblygiadau o Arwyddocâd Cenedlaethol", "dns-card-paragraph": "Mae Datblygiad o Arwyddocâd Cenedlaethol yn fath o gais cynllunio ar gyfer prosiect seilwaith mawr o bwysigrwydd cenedlaethol.", - "dns-card-button": "Gweld pob cais" + "dns-card-button": "Gweld pob cais", + "logging-in-heading": "Mewngofnodi", + "logging-in-paragraph": "Arhoswch os gwelwch yn dda..." } \ No newline at end of file diff --git a/locales/en/home.json b/locales/en/home.json index 16a07582..66d34415 100644 --- a/locales/en/home.json +++ b/locales/en/home.json @@ -21,6 +21,7 @@ "login-card-register-link": "Register", "login-card-forgotten-label": "I have forgotten my password", "login-card-forgotten-link": "Click here", + "login-via-gov-gateway-label": "Log in via Government Gateway", "casesearch-card-title": "Search appeals and Developments of National Significance", "casesearch-card-search-hint": "Use the case reference or DNS title to search. Case reference will be similar to one of the following:", "casesearch-card-search-example-label-1": "APP-A12345-A-21-1234567", @@ -37,5 +38,7 @@ "inspectorate-card-alt-text": "The Planning Inspectorate", "dns-card-title": "View all Developments of National Significance ", "dns-card-paragraph": "A Development of National Significance is a type of planning application for a large infrastructure project of national importance.", - "dns-card-button": "View all applications" + "dns-card-button": "View all applications", + "logging-in-heading": "Logging in", + "logging-in-paragraph": "Please wait..." } \ No newline at end of file diff --git a/pages/index.js b/pages/index.js index 39ee0189..afe10ab8 100644 --- a/pages/index.js +++ b/pages/index.js @@ -42,6 +42,7 @@ const Home = (props) => { hasGGCode, loginEmailStr, loggedInUserEmail, + ggLocale, } = props; let { t, lang } = useTranslation(); @@ -71,7 +72,10 @@ const Home = (props) => { expires: expDate, }), router.replace({ - pathname: router.locale == "cy" ? "/fymhorth" : "/myportal", + pathname: + router.locale == "cy" || ggLocale == "cy" + ? "/cy/fymhorth" + : "/myportal", })) : console.log("no value in user id"); @@ -131,13 +135,22 @@ const Home = (props) => {
{hasGGCode ? ( <> -

Logging in

-

Please wait...

+

+ {ggLocale == "cy" + ? "Mewngofnodi" + : "Logging in"} +

+

+ {ggLocale == "cy" + ? "Arhoswch os gwelwch yn dda..." + : "Please wait..."} +

) : ( <>
+ + + {t("myportal:page-title")} - {t("common:service-name")} + + +
+ +
+
+
+
+
+

{t("common:error-page-title")}

+

+ A problem occured when trying to login +

+ + {t("common:404-not-found-link")} + +
+
+
+
+
+
+ ); +} + +Error.getInitialProps = ({ res, err }) => { + const statusCode = res ? res.statusCode : err ? err.statusCode : 404; + console.log(res, err); + return { statusCode }; +}; + +export default Error; diff --git a/pages/myportal/index.js b/pages/myportal/index.js index d38fb99e..c761f4a7 100644 --- a/pages/myportal/index.js +++ b/pages/myportal/index.js @@ -205,30 +205,41 @@ export const getServerSideProps = wrapper.getServerSideProps( _.has(accountDetails, "errorCode") != false ); - const [ - myCasesDetails, - myRepresentationsDetails, - watchedCasesDetails, - // awaitingSubmissionDetails, - ] = await Promise.all([ - await getDetails(token, myCases, "myCases"), - await getDetails(token, myRepresentations, "myRepresentations"), - await getDetails(token, watchedCases, "myWatchedCases"), - // await getDetails(awaitingSubmission), - ]); + if (_.has(accountDetails, "errorCode") != false) { + return { + redirect: { + destination: "/myportal/error", + permanent: false, + }, + }; + } else { + const [ + myCasesDetails, + myRepresentationsDetails, + watchedCasesDetails, + // awaitingSubmissionDetails, + ] = await Promise.all([ + await getDetails(token, myCases, "myCases"), + await getDetails(token, myRepresentations, "myRepresentations"), + await getDetails(token, watchedCases, "myWatchedCases"), + // await getDetails(awaitingSubmission), + ]); - store.dispatch(setAccountDetails(accountDetails)); - store.dispatch(setLoggedInUserId(loggedInUser)); - store.dispatch(setMyCases(myCases)); - store.dispatch(setMyCasesDetails(myCasesDetails)); - store.dispatch(setMyRepresentations(myRepresentations)); - store.dispatch(setMyRepresentationsDetails(myRepresentationsDetails)); - store.dispatch(setWatchedCases(watchedCases)); - store.dispatch(setWatchedCasesDetails(watchedCasesDetails)); - store.dispatch(setAwaitingSubmission(awaitingSubmission)); - // store.dispatch( - // setAwaitingSubmissionDetails(awaitingSubmissionDetails) - // ); + store.dispatch(setAccountDetails(accountDetails)); + store.dispatch(setLoggedInUserId(loggedInUser)); + store.dispatch(setMyCases(myCases)); + store.dispatch(setMyCasesDetails(myCasesDetails)); + store.dispatch(setMyRepresentations(myRepresentations)); + store.dispatch( + setMyRepresentationsDetails(myRepresentationsDetails) + ); + store.dispatch(setWatchedCases(watchedCases)); + store.dispatch(setWatchedCasesDetails(watchedCasesDetails)); + store.dispatch(setAwaitingSubmission(awaitingSubmission)); + // store.dispatch( + // setAwaitingSubmissionDetails(awaitingSubmissionDetails) + // ); + } } );