From e19efb8b62fd30ca220f8c453dcde4de387291bf Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Fri, 8 Oct 2021 11:10:15 +0100 Subject: [PATCH 1/3] download link with filename from api --- actions/index.js | 15 -------- components/case/documents.js | 49 +++++++++++--------------- components/elements/index.js | 6 +++- components/main.js | 4 +-- package.json | 1 + pages/api/proxy/[...route].js | 15 ++++---- styles/sass/welshgov/_application.scss | 41 +++++++++++++++++++-- 7 files changed, 76 insertions(+), 55 deletions(-) diff --git a/actions/index.js b/actions/index.js index dfd370b0..6925cf69 100644 --- a/actions/index.js +++ b/actions/index.js @@ -663,18 +663,3 @@ export const getPortalModuelDetails = (token, appealType, caseReference) => { console.log("thiserror", error); }); }; - -export const getFileFromCRM = (docRef) => { - const weburl = "/api/proxy/documents/download/" + docRef; - - console.log("proxy url", weburl); - return axios - .get(weburl, { responseType: "arraybuffer" }) - .then((res) => { - console.log(res); - return res; - }) - .catch((error) => { - console.log("thi serror", error); - }); -}; diff --git a/components/case/documents.js b/components/case/documents.js index 593a6f12..181882fc 100644 --- a/components/case/documents.js +++ b/components/case/documents.js @@ -47,9 +47,9 @@ const DocumentDetails = (props) => { documentDetailsArr = documentDetailsArr.value; return ( -
+
-
+
{t("case:documents-name-label")}
@@ -58,9 +58,9 @@ const DocumentDetails = (props) => {
{t("case:documents-date-published-label")}
-
+ {/*
{t("case:documents-size-label")} -
+ */}
{documentDetailsArr.map((item) => { @@ -88,29 +88,25 @@ const DocumentDetails = (props) => { className="govuk-summary-list__row" key={key} > -
- + - - - {t( - "case:documents-name-label" - )} - : - - {_.has(historyObj, [ - "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue", - ]) - ? historyObj[ - "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue" - ] - : ""} - - + + {t("case:documents-name-label")} + : + + {_.has(historyObj, [ + "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue", + ]) + ? historyObj[ + "_pinswg_documentid_value@OData.Community.Display.V1.FormattedValue" + ] + : ""} +
@@ -152,12 +148,12 @@ const DocumentDetails = (props) => { ) : ""}
-
+ {/*
{t("case:documents-size-label")}: 92 -
+ */} ) : ( "" @@ -212,11 +208,6 @@ const DocumentDetails = (props) => { }; const searchDocumentResultsObj = docDetailsObj(); - - const getFileFromCRM = (event, docRef) => { - console.log(e, docRef); - return alert(docRef); - }; }, [incidentid, setDocumentHistory, setDocumentDetails]); function formatDates(dateObj) { diff --git a/components/elements/index.js b/components/elements/index.js index 6584ef61..d6b2934c 100644 --- a/components/elements/index.js +++ b/components/elements/index.js @@ -1,7 +1,8 @@ import useSWR from "swr"; import { Field, reduxForm } from "redux-form"; import { useRouter } from "next/router"; -import DatePicker from "react-datepicker"; +import DatePicker, { registerLocale, setDefaultLocale } from "react-datepicker"; +import cy from "date-fns/locale/cy"; import React, { useState } from "react"; import "react-datepicker/dist/react-datepicker.css"; import moment from "moment"; @@ -140,6 +141,8 @@ const RenderDatePicker = ({ meta: { touched, error }, ...custom }) => { + const router = useRouter(); + registerLocale("cy", cy); return ( <>
- {/* - */} + + {/* */}
diff --git a/package.json b/package.json index 9b3c7b60..da2773a7 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "compression": "^1.7.4", "cookies": "^0.8.0", "crypto-js": "^4.1.1", + "date-fns": "^2.25.0", "dom": "^0.0.3", "dynamics-web-api": "^1.7.4", "express": "^4.17.1", diff --git a/pages/api/proxy/[...route].js b/pages/api/proxy/[...route].js index 454592a9..8cc34063 100644 --- a/pages/api/proxy/[...route].js +++ b/pages/api/proxy/[...route].js @@ -61,7 +61,7 @@ const getSASToken = () => { }; export default async function ApiProxy(req, res) { - console.log(req.method); + //console.log(req.method); var data = JSON.stringify(req.body); const SASToken = getSASToken(); @@ -121,18 +121,21 @@ export default async function ApiProxy(req, res) { : config ) .then((response) => { - // console.log(response); res.statusCode = 200; if (hasDocument) { - res.setHeader("Content-Type", "text/plain"); + res.setHeader( + "Content-disposition", + "attachment; filename=" + + response.headers["content-disposition"].split( + "filename=" + )[1] + ); res.end(response.data); } else { res.setHeader("Content-Type", "application/json"); - res.setHeader("Cache-Control", "max-age=1800000"); + // res.setHeader("Cache-Control", "max-age=1800000"); res.end(JSON.stringify(response.data)); } - - //console.log("response data", response.data); resolve(); }) .catch((error) => { diff --git a/styles/sass/welshgov/_application.scss b/styles/sass/welshgov/_application.scss index 15423e67..aa586101 100644 --- a/styles/sass/welshgov/_application.scss +++ b/styles/sass/welshgov/_application.scss @@ -18,6 +18,7 @@ html { .govuk-button, .govuk-label, .govuk-select, +.govuk-radios__item, .govuk-breadcrumbs__link, .govuk-fieldset__legend--s, .govuk-input, @@ -136,6 +137,7 @@ body { a.longLinkBreak { word-wrap: break-word; } + .govuk-header { background-color: $charcoal; @@ -189,6 +191,18 @@ a.longLinkBreak { } } +.govuk-input, +.govuk-select, +textarea, +.react-datepicker__input-container input { + border: 1px solid $darkgrey; + padding: 10px 15px; +} + +.govuk-radios__label:before { + border: 1px solid $darkgrey; +} + .govuk-checkboxes__conditional--hidden { display: none; } @@ -628,10 +642,22 @@ a.longLinkBreak { outline: 3px solid transparent; } } + +.documentList { + .govuk-summary-list__key:first-of-type { + width: 20%; + } + .govuk-summary-list__key:last-of-type { + width: 20%; + } +} .results .govuk-summary-list__row { @media screen and (max-width: 900px) { padding: 20px 10px; } + &::last-of-type { + width: 30%; + } } .results_wider { @@ -679,8 +705,8 @@ a.longLinkBreak { height: 40px; height: 2.5rem; margin-top: 0; - padding: 5px; - border: 2px solid #0b0c0c; + padding: 10px 15px; + border: 1px solid $darkgrey !important; border-radius: 0; -webkit-appearance: none; appearance: none; @@ -690,6 +716,17 @@ a.longLinkBreak { line-height: 1.3157894737; } +.react-datepicker-popper[data-placement^="top"] + .react-datepicker__triangle::before, +.react-datepicker-popper[data-placement^="bottom"] + .react-datepicker__triangle::before, +.react-datepicker-popper[data-placement^="top"] + .react-datepicker__triangle::after, +.react-datepicker-popper[data-placement^="bottom"] + .react-datepicker__triangle::after { + left: -20px !important; +} + //sharebar .btn--arrow-up a { From 76422f01df4e17d4f8d514e288084cce67bcfb74 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Fri, 8 Oct 2021 11:56:12 +0100 Subject: [PATCH 2/3] defects for mappin of date fields --- .env.local | 20 ++++++++++---------- actions/index.js | 3 ++- components/case/summary.js | 6 +++--- data/collections.json | 2 +- pages/searchresults.js | 15 +++++++++++++++ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.env.local b/.env.local index 74e6fb27..4600c635 100644 --- a/.env.local +++ b/.env.local @@ -1,8 +1,8 @@ -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" @@ -14,8 +14,8 @@ I18N_DOMAIN = "cymru.local" //I18N_DOMAIN ="gwaithcynllunio.gwasanaeth.llyw.cymru" -//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" diff --git a/actions/index.js b/actions/index.js index 6925cf69..6343eb0d 100644 --- a/actions/index.js +++ b/actions/index.js @@ -223,6 +223,7 @@ export const getAdvancedSearch = (token, searchString) => { }; export const getBasicSearchDetails = (token, appealType, caseReference) => { + //console.log("check appealtype:", appealType, caseReference); return axios .get( WEBAPI_URL + @@ -234,7 +235,7 @@ export const getBasicSearchDetails = (token, appealType, caseReference) => { ) .then((res) => res.data) .catch((error) => { - console.log("thiserror", error); + console.log("this error", error); }); }; diff --git a/components/case/summary.js b/components/case/summary.js index 27de4e8e..b5421159 100644 --- a/components/case/summary.js +++ b/components/case/summary.js @@ -541,13 +541,13 @@ const CaseSummary = (props) => {
{_.has( detailsObj, - "pinswg_dateoflpadecision" + "pinswg_casedecisiondate" ) ? !_.isEmpty( - detailsObj.pinswg_dateoflpadecision + detailsObj.pinswg_casedecisiondate ) ? formatDates( - detailsObj.pinswg_dateoflpadecision + detailsObj.pinswg_casedecisiondate ) : t( "case:summary-no-date-entered-label" diff --git a/data/collections.json b/data/collections.json index d4059743..4ce9e8ea 100644 --- a/data/collections.json +++ b/data/collections.json @@ -352,7 +352,7 @@ }, { "LogicalCollectionName": "pinswg_listedbuildingandconservationareaconsens", - "LogicalName": "pinswg_listedbuildingconservationareaconsents7", + "LogicalName": "pinswg_listedbuildingconservationareaconsent", "PrimaryIdAttribute": "pinswg_listedbuildingandconservationareaconsenid", "UrlName": "listedbuildingandconservationareaconsen", "MetadataId": "4cd95405-8f81-eb11-aac0-00224800be9c" diff --git a/pages/searchresults.js b/pages/searchresults.js index ef0cd531..dcf34598 100644 --- a/pages/searchresults.js +++ b/pages/searchresults.js @@ -123,9 +123,24 @@ const getSearchDetails = (token, searchResultsObj) => { //console.log("search results", searchResultsObj); searchResultsObj = searchResultsObj.value; const detailsObj = searchResultsObj.map((searchDetail, index) => { + //console.log(searchDetail); if (searchDetail.pinswg_appealcasetype == null) { console.log(searchDetail.ticketnumber); } else { + // console.log( + // "appealtype collection name", + // searchDetail[ + // "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + // ], + // "pinswg_" + + // searchDetail[ + // "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue" + // ] + // .replace(/(\band|[\s\-\+\(\)\,\&])/g, "") + // .toLowerCase() + // .slice(0, 39), + // searchDetail.ticketnumber + // ); detailsArr.push( getBasicSearchDetails( token, From b34c56145dc6488bde5f4ffc7524819f126f5066 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Wed, 13 Oct 2021 07:40:36 +0100 Subject: [PATCH 3/3] added create contact flow for registration --- .env.local | 20 +- actions/index.js | 122 +++++----- components/account/registerCheck.js | 25 ++- components/account/registerComplete.js | 91 ++++++-- components/account/registerform.js | 69 ++++-- components/header.js | 19 +- components/homepage/login.js | 296 +++++++++++++++++++------ components/loading.js | 13 +- components/myportal/youraccount.js | 2 +- components/search/searchresults.js | 1 + locales/cy/common.json | 2 + locales/en/common.json | 2 + pages/account/register.js | 8 +- pages/api/proxy/[...route].js | 21 +- pages/logout.js | 6 +- pages/myportal/index.js | 95 ++++---- pages/myportal/searchresults.js | 54 ++++- pages/newappeal/[appealtypes].js | 71 +++--- pages/newappeal/index.js | 31 ++- store/accountDetails/action.js | 11 + store/accountDetails/reducer.js | 6 + styles/sass/welshgov/_application.scss | 5 +- 22 files changed, 663 insertions(+), 307 deletions(-) diff --git a/.env.local b/.env.local index 4600c635..74e6fb27 100644 --- a/.env.local +++ b/.env.local @@ -1,8 +1,8 @@ -//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" @@ -14,8 +14,8 @@ I18N_DOMAIN = "cymru.local" //I18N_DOMAIN ="gwaithcynllunio.gwasanaeth.llyw.cymru" -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" diff --git a/actions/index.js b/actions/index.js index 6343eb0d..3e902345 100644 --- a/actions/index.js +++ b/actions/index.js @@ -299,6 +299,7 @@ export const getSearchDocumentHistory1 = (documentID) => { console.log("thiserror", error); }); }; + export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { return axios .get( @@ -400,49 +401,6 @@ export const getAppealsTypes = (token) => { }); }; -//get list of entitydefinitions -//https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/EntityDefinitions?$select=LogicalName - -// get list of appealtypes -//https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/stringmaps?$filter=attributename%20eq%20%27pinswg_appealcasetype%27&$count=true - -//get crm xml form for appealtype -//https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/systemforms?$select=formid,name,formxml&$filter=(objecttypecode%20eq%20%27pinswg_dns%27and%20type%20eq%202)&$count=true -// then use regex to remove the escape -// convert xml to json and return -// promise example -// var xml2js = require('xml2js'); -// var xml = ''; - -// // With parser -// var parser = new xml2js.Parser(/* options */); -// parser.parseStringPromise(data).then(function (result) { -// console.dir(result); -// console.log('Done'); -// }) -// .catch(function (err) { -// // Failed -// }); - -// export const getAppealTypeDetail = (caseReference, appealcasetype) => { -// console.log("got to axios", searchString); -// console.log("api_root: ", BASE_URL); -// // example appealcasetype type pinswg_householderappealhases -// return axios -// .get( -// "https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/" + -// appealcasetype + -// "?$filter=pinswg_name eq '" + -// caseReference + -// "'", -// { httpsAgent: new https.Agent({ rejectUnauthorized: false }) } -// ) -// .then((res) => res.data) -// .catch((error) => { -// console.log("thi serror", error); -// }); -// }; - export const getLPA = (token) => { // console.log("api_root: ", BASE_URL); return axios @@ -508,13 +466,27 @@ export const getAppealID = ( }); }; -export const createCase = (token, appealTypeId) => { +export const getLogin = (emailAddress, pwd) => { + return axios + .get( + "/api/proxy/contacts?$filter=emailaddress1 eq '" + + emailAddress + + "' and pinswg_custom_password eq '" + + pwd + + "'&$count=true&$select=emailaddress1,%20contactid,pinswg_custom_password, yomifullname, firstname, lastname" + ) + .then((res) => res.data) + .catch((error) => { + console.log("thiserror", error); + }); +}; + +export const createCase = (token, appealTypeId, contactid) => { appealTypeId = parseInt(appealTypeId); var data = JSON.stringify({ "title": "insertion test case", "caseorigincode": 3, - "customerid_contact@odata.bind": - "/contacts(f8b454ed-eded-eb11-aac7-00224800be9c)", + "customerid_contact@odata.bind": "/contacts(" + contactid + ")", "pinswg_appealcasetype": appealTypeId, }); @@ -587,6 +559,7 @@ export const updateCase = async ( }; export const getMyCases = (token, loggedInUserId) => { + console.log("in action ", loggedInUserId); return axios .get( WEBAPI_URL + @@ -595,13 +568,15 @@ export const getMyCases = (token, loggedInUserId) => { " and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3", azureHeaders(token) ) - .then((res) => res.data) + .then((res) => { + return res.data; + }) .catch((error) => { console.log("thi serror", error); }); }; -export const getMyRepresentations = (token) => { +export const getMyRepresentations = (token, loggedInUserId) => { return ( axios // .get(BASE_URL + "/api/lookups/myRepresentations", { @@ -609,7 +584,9 @@ export const getMyRepresentations = (token) => { // }) .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype ne null &$count=true&$top=3", + "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) @@ -619,7 +596,7 @@ export const getMyRepresentations = (token) => { ); }; -export const getWatchedCases = (token) => { +export const getWatchedCases = (token, loggedInUserId) => { return ( axios @@ -628,7 +605,9 @@ export const getWatchedCases = (token) => { // }) .get( WEBAPI_URL + - "incidents?$select=_accountid_value,_customerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype ne null &$count=true&$top=3", + "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) @@ -664,3 +643,44 @@ export const getPortalModuelDetails = (token, appealType, caseReference) => { console.log("thiserror", error); }); }; + +export const getEmailAccountCheck = (emailAddress) => { + let token = getSASToken(); + return axios + .get( + "/api/proxy/contacts?$filter=emailaddress1 eq '" + + emailAddress + + "'&$count=true&$select=emailaddress1, contactid" + ) + .then((res) => res.data) + .catch((error) => { + console.log("thiserror", error); + }); +}; + +export const createAccount = (formValues) => { + var data = JSON.stringify(formValues); + + var config = { + method: "post", + url: "/api/proxy/contacts", + headers: { + "OData-MaxVersion": "4.0", + "OData-Version": "4.0", + "Accept": "application/json", + "Prefer": 'odata.include-annotations="*",return=representation', + "Content-Type": "application/json", + "ServiceBusAuthorization": getSASToken(), + }, + data: data, + }; + // console.log(config); + return axios(config) + .then((res) => { + // console.log("posted ", res.data); + return res.data; + }) + .catch((error) => { + console.log("this serror", error); + }); +}; diff --git a/components/account/registerCheck.js b/components/account/registerCheck.js index 6e2c4f78..9c63b5b2 100644 --- a/components/account/registerCheck.js +++ b/components/account/registerCheck.js @@ -9,6 +9,7 @@ import { getFormSubmitErrors, } from "redux-form"; import { useDispatch, useSelector, shallowEqual, connect } from "react-redux"; +import { setAccCr } from "../../store/accountDetails/action"; const RegisterFormCheck = (props) => { const { @@ -18,6 +19,7 @@ const RegisterFormCheck = (props) => { value, setRegisterFormComplete, setAccountCreatedComplete, + setAccCr, } = props; let { t, lang } = useTranslation(); @@ -70,7 +72,6 @@ const RegisterFormCheck = (props) => { > Change - {" "} last name @@ -81,7 +82,7 @@ const RegisterFormCheck = (props) => {
{ props.props.props.form.accountRegisterForm.values - .email + .emailaddress1 }
@@ -105,7 +106,7 @@ const RegisterFormCheck = (props) => {
{ props.props.props.form.accountRegisterForm.values - .telephone + .telephone1 }
@@ -123,7 +124,7 @@ const RegisterFormCheck = (props) => {
-
+ {/*
Company/Group
{ @@ -146,7 +147,7 @@ const RegisterFormCheck = (props) => {
-
+
*/}

Your address

@@ -156,7 +157,7 @@ const RegisterFormCheck = (props) => {
{ props.props.props.form.accountRegisterForm.values - .addressline1 + .address1_line1 }
@@ -180,7 +181,7 @@ const RegisterFormCheck = (props) => {
{ props.props.props.form.accountRegisterForm.values - .addressline2 + .address1_line2 }
@@ -204,7 +205,7 @@ const RegisterFormCheck = (props) => {
{ props.props.props.form.accountRegisterForm.values - .towncity + .address1_city }
@@ -228,7 +229,7 @@ const RegisterFormCheck = (props) => {
{ props.props.props.form.accountRegisterForm.values - .county + .address1_county }
@@ -252,7 +253,7 @@ const RegisterFormCheck = (props) => {
{ props.props.props.form.accountRegisterForm.values - .postcode + .address1_postalcode }
@@ -278,6 +279,7 @@ const RegisterFormCheck = (props) => { className="govuk-button" data-module="govuk-button" onClick={() => { + setAccCr(false); setAccountCreatedComplete(true); }} > @@ -304,6 +306,9 @@ const mapDispatchToProps = (dispatch) => { setCurrentSection: (currentSection) => { dispatch(setCurrentSection(currentSection)); }, + setAccCr: (accState) => { + dispatch(setAccCr(accState)); + }, }; }; diff --git a/components/account/registerComplete.js b/components/account/registerComplete.js index 8c117be8..2c494ee1 100644 --- a/components/account/registerComplete.js +++ b/components/account/registerComplete.js @@ -1,8 +1,10 @@ import _ from "lodash"; import Link from "next/link"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; + +import jsonpath from "jsonpath"; import { Field, reduxForm, @@ -18,6 +20,10 @@ import { setAccountCreatedComplete, } from "react-redux"; +import { setAccCr, setLogout } from "../../store/accountDetails/action"; + +import { getEmailAccountCheck, createAccount } from "../../actions"; + const RegisterComplete = (props) => { const { footerLinks, @@ -26,13 +32,50 @@ const RegisterComplete = (props) => { value, setRegisterFormComplete, setAccountCreatedComplete, + setAccCr, } = props; let { t, lang } = useTranslation(); const router = useRouter(); const { locale } = router; - return ( + const [accountCreated, setAccountCreated] = useState(false); + + useEffect(() => { + let accountBody = props.props.props.form.accountRegisterForm.values; + let emailAddress = + props.props.props.form.accountRegisterForm.values.emailaddress1; + Object.assign(accountBody, { + "pinswg_typeofinvolvement": 846040001, + }); + + accountBody = _.omit(accountBody, ["custom_password_check"]); + + let checkEmailObj = {}; + + switch (props.accountDetails.accCr) { + case "created": + case "exists": + break; + + default: + let emailExists = getEmailAccountCheck( + accountBody.emailaddress1 + ).then((data) => { + data["@odata.count"] > 0 + ? setAccCr("exists") + : (checkEmailObj = createAccount(accountBody).then( + (data) => { + //console.log(data); + setAccCr("created"); + } + )); + }); + break; + } + }); + + return props.accountDetails.accCr == "created" ? ( <>

We have sent you a confirmation email.

@@ -43,18 +86,35 @@ const RegisterComplete = (props) => { metus non quam mollis egestas. Integer ac leo cursus, laoreet nulla sed, tempus tellus. Mauris condimentum erat arcu.

-

- Sed imperdiet dignissim ipsum. Orci varius natoque penatibus et - magnis dis parturient montes, nascetur ridiculus mus. In id leo - in turpis aliquam venenatis ut non erat. Ut est arcu, luctus sit - amet pretium sed, iaculis non purus. Etiam dictum tortor commodo - luctus rhoncus. -

- - Login to My Portal - + { + setLogout(), window.localStorage.clear(); + }} + > + Login to My Portal + +

+ + ) : ( + <> +

+ Please try again with a different email address +

+

+ { + setRegisterFormComplete(false), + setAccountCreatedComplete(false), + setAccCr("false"); + }} + className="govuk-link" + > + Try registering again +

); @@ -73,8 +133,11 @@ const mapStateToProps = (state) => { const mapDispatchToProps = (dispatch) => { return { - setCurrentSection: (currentSection) => { - dispatch(setCurrentSection(currentSection)); + setAccCr: (accountCreated) => { + dispatch(setAccCr(accountCreated)); + }, + setLogout: () => { + dispatch(setLogout()); }, }; }; diff --git a/components/account/registerform.js b/components/account/registerform.js index 9fcf8128..d0cf50a4 100644 --- a/components/account/registerform.js +++ b/components/account/registerform.js @@ -87,9 +87,21 @@ const RegisterForm = (props) => { ? "Invalid phone number" : undefined; + const passwordsMatch = (value, allValues) => + value !== allValues.pinswg_custom_password + ? "Passwords don't match" + : undefined; + + const minLength = (min) => (value) => + value && value.length < min + ? `Must be ${min} characters or more` + : undefined; + const minLength5 = minLength(5); + const [hasErrors, setHasErrors] = useState(""); const onHandleSubmit = (values) => { + //console.log(values); setRegisterFormComplete(true); }; @@ -125,8 +137,8 @@ const RegisterForm = (props) => { errorMsg="Is required" /> { label="Email address" /> { /> +
@@ -161,8 +188,8 @@ const RegisterForm = (props) => { { errorMsg="Is required" /> { errorMsg="Is required" /> { errorMsg="Is required" /> { errorMsg="Is required" /> { /> ) ) : ( - + )} ); diff --git a/components/header.js b/components/header.js index 24fd8596..07876f2b 100644 --- a/components/header.js +++ b/components/header.js @@ -27,6 +27,7 @@ const Header = (props) => { "/dnsapplications", "/dnsdetails", "/404", + "/account/register", ]; const hasContactLink = [ "/dns", @@ -112,22 +113,20 @@ const Header = (props) => { "" ) : (
  • - - { + onClick={() => { + setLogout(), window.localStorage.clear(); - }} - className="govuk-header__link " - > - {t("common:signout-label")} - - + }} + className="govuk-header__link " + > + {t("common:signout-label")} +
  • )} diff --git a/components/homepage/login.js b/components/homepage/login.js index a1742759..44b75db7 100644 --- a/components/homepage/login.js +++ b/components/homepage/login.js @@ -1,66 +1,187 @@ import Link from "next/link"; +import { useState } from "react"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; +import { connect } from "react-redux"; +import { Field, reduxForm } from "redux-form"; +import LoadingOverlay from "react-loading-overlay"; +import { getLogin } from "../../actions"; +import { setLoggedInUserId } from "../../store/accountDetails/action"; +import Cookies from "cookies"; -export default function Login() { +const required = (errorMsg) => (value) => + value || typeof value === "number" ? undefined : errorMsg; + +export const minLength = (errorMsg) => (value) => + value && value.length < 4 + ? errorMsg //`Must be ${min} characters or more` + : undefined; + +const RenderTextfield = ({ + id, + className, + rows, + datafieldname, + name, + label, + input, + hint1, + hint2, + meta: { touched, error }, + ...custom +}) => { + return ( + <> +
    +
    + {hint1} + +
    + {hint2} +
    + + {touched && error && ( + + Error:{" "} + {error} + + )} + +
    + + ); +}; +const RenderPasswordfield = ({ + id, + className, + rows, + datafieldname, + name, + label, + input, + hint1, + hint2, + meta: { touched, error }, + ...custom +}) => { + return ( + <> +
    +
    + {hint1} +
    + + {touched && error && ( + + Error:{" "} + {error} + + )} + +
    + + ); +}; + +let Login = (props) => { let { t } = useTranslation(); + const { handleSubmit, pristine, reset, submitting, setLoggedInUserId } = + props; const router = useRouter(); const { locale } = router; + + const [showSpinnerState, setShowSpinnerState] = useState(false); + + let spinnerState = () => { + showSpinnerState == true + ? setShowSpinnerState(false) + : setShowSpinnerState(true); + }; + + const onHandleSubmit = (values) => { + 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, + }); + }); + }; + return (
    -
    -

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

    +
    +
    +

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

    + + + + -
    - {" "} - -
    - {t("home:login-card-id-hint")} -
    - -
    -
    - {" "} - - -
    -
    - {/* */} - {t("home:login-card-button")} - + */} + +
    +
    +

    + {t("home:login-card-register-label")}{" "} + + {t("home:login-card-register-link")} + +

    +

    + + {t("home:login-card-forgotten-label")} + +

    - -
    -

    - {t("home:login-card-register-label")}{" "} - - {t("home:login-card-register-link")} - -

    -

    - - {t("home:login-card-forgotten-label")} - -

    -
    + +
    ); -} +}; + +const mapStateToProps = (state) => { + return { + currentView: state.currentView, + search: state.search, + searchResultsObj: state.searchResultsObj, + formData: state.formData, + appealType: state.appealType, + //form: state.form, + myCases: state.myCases, + watchedCases: state.watchedCases, + myRepresentations: state.myRepresentations, + awaitingSubmission: state.awaitingSubmission, + }; +}; + +const mapDispatchToProps = (dispatch) => { + return { + setLoggedInUserId: (userID) => { + dispatch(setLoggedInUserId(userID)); + }, + }; +}; + +export default connect( + mapStateToProps, + mapDispatchToProps +)( + reduxForm({ + form: "loginForm", + destroyOnUnmount: false, + })(Login) +); diff --git a/components/loading.js b/components/loading.js index 1cba4191..fc13e258 100644 --- a/components/loading.js +++ b/components/loading.js @@ -1,19 +1,20 @@ import Head from "next/head"; -import Banner from "../components/banner"; import Footer from "../components/footer"; import Header from "../components/header"; +import useTranslation from "next-translate/useTranslation"; export default function SkipLink(props) { + let { t } = useTranslation(); + return (
    - Appeals Casework Portal + {t("common:service-name")}
    -
    -

    Loading...

    +

    + {t("common:loading-label")}... +

    diff --git a/components/myportal/youraccount.js b/components/myportal/youraccount.js index e5819793..305b094f 100644 --- a/components/myportal/youraccount.js +++ b/components/myportal/youraccount.js @@ -19,7 +19,7 @@ export default function YourAccount() { diff --git a/components/search/searchresults.js b/components/search/searchresults.js index 0e057732..f012416d 100644 --- a/components/search/searchresults.js +++ b/components/search/searchresults.js @@ -55,6 +55,7 @@ const SearchResults = (props) => { return (
    + {router.pathname.indexOf("myportal")} {

    Create a new account

    ) : (

    - Your account has been created + {props.accountDetails.accCr != + "false" + ? props.accountDetails + .accCr == "exists" + ? "Your account has not created" + : "Your account has been created" + : "Checking for account.."}

    )} { var m_ResourceURI = @@ -82,7 +70,6 @@ export default async function ApiProxy(req, res) { var config = { method: req.method, - //url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")", url: PROXY_RELAY_URL + req.query.route[0], headers: { "OData-MaxVersion": "4.0", @@ -112,7 +99,13 @@ export default async function ApiProxy(req, res) { return new Promise((resolve, reject) => { let apiPath = req.url.split("/api/proxy/")[1]; let hasDocument = apiPath.indexOf("/download") > 0 ? true : false; - + console.log( + "//////////////", + req.url.split("/api/proxy/")[1], + PROXY_RELAY_URL + req.query.route[0], + req.method, + hasDocument + ); axios( req.method == "GET" ? hasDocument diff --git a/pages/logout.js b/pages/logout.js index 32341a8d..bccf5e70 100644 --- a/pages/logout.js +++ b/pages/logout.js @@ -10,6 +10,7 @@ import { useSelector, shallowEqual, connect } from "react-redux"; import { useRouter } from "next/router"; import useTranslation from "next-translate/useTranslation"; import { setLogout } from "../store/accountDetails/action"; +import { useEffect } from "react"; const LogOut = (props) => { const { footerLinks, pages, setLogout } = props; @@ -17,7 +18,10 @@ const LogOut = (props) => { const router = useRouter(); const { locale } = router; - setLogout(); + + useEffect(() => { + setLogout(); + }); return (
    diff --git a/pages/myportal/index.js b/pages/myportal/index.js index 89f0ebbc..f7f0f54b 100644 --- a/pages/myportal/index.js +++ b/pages/myportal/index.js @@ -82,58 +82,63 @@ const Home = (props) => { }; export const getServerSideProps = wrapper.getServerSideProps( - (store) => - async ({ query, req, res }) => { - //console.log("the query", query); + (store) => async (ctx) => { + const { query, req, res } = ctx; + console.log("the query", query); - const token = await getSASToken(); + const { cookies } = req; - const [ - myCases, - myRepresentations, - watchedCases, - awaitingSubmission, - ] = await Promise.all([ - await getMyCases(token, "f8b454ed-eded-eb11-aac7-00224800be9c"), - await getMyRepresentations(token), - await getWatchedCases(token), + console.log(cookies); + const token = await getSASToken(); + + let loggedInUser = + typeof query.q == undefined ? cookies.pinsUser : query.q; + + console.log("qweqe ", loggedInUser); + + const [myCases, myRepresentations, watchedCases, awaitingSubmission] = + await Promise.all([ + await getMyCases(token, loggedInUser), + await getMyRepresentations(token, loggedInUser), + await getWatchedCases(token, loggedInUser), await getAwaitingSubmission(token), ]); - const cookies = new Cookies(req, res); + const cookiesMaker = new Cookies(req, res); - cookies.set("pinsUser", "f8b454ed-eded-eb11-aac7-00224800be9c", { - httpOnly: true, // true by default - }); - //console.log("my cases ", myCases); - const [ - myCasesDetails, - // myRepresentationsDetails, - // watchedCasesDetails, - // awaitingSubmissionDetails, - ] = await Promise.all([ - await getDetails(token, myCases), - // await getDetails(myRepresentations), - // await getDetails(watchedCases), - // await getDetails(awaitingSubmission), - ]); + cookiesMaker.set("pinsUser", query.q, { + httpOnly: true, // true by default + }); - store.dispatch( - setLoggedInUserId("f8b454ed-eded-eb11-aac7-00224800be9c") - ); - 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) - // ); - } + console.log(" from cookie ", cookiesMaker.get("pinsUser")); + console.log(myCases); + + const [ + myCasesDetails, + myRepresentationsDetails, + watchedCasesDetails, + // awaitingSubmissionDetails, + ] = await Promise.all([ + await getDetails(token, myCases), + await getDetails(token, myRepresentations), + await getDetails(token, watchedCases), + // await getDetails(awaitingSubmission), + ]); + + console.log(myCasesDetails); + + 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) + // ); + } ); const getFormCollection = (formtype) => { diff --git a/pages/myportal/searchresults.js b/pages/myportal/searchresults.js index 40ee3f8f..21d459ea 100644 --- a/pages/myportal/searchresults.js +++ b/pages/myportal/searchresults.js @@ -20,9 +20,17 @@ import { setSearch, getSearchObj } from "../../store/search/action"; import { setSearchResults, setSearchDetails, + setDocumentDetails, + setDocumentHistory, getSearchResultsObj, } from "../../store/searchOutput/action"; -import { getBasicSearch, getBasicSearchDetails } from "../../actions"; +import { + getBasicSearch, + getBasicSearchDetails, + getSearchDocumentDetails, + getSearchDocumentHistory, + getSASToken, +} from "../../actions"; const Home = (props) => { const { footerLinks, pages } = props; @@ -47,6 +55,7 @@ const Home = (props) => {