diff --git a/.eslintrc b/.eslintrc index 15b1ed91..f03a56fe 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,3 +1,6 @@ { - "extends": "next" + "extends": "next", + "rules": { + "@next/next/no-img-element": "off" + } } diff --git a/actions/index.js b/actions/index.js index da2a4138..0d40180a 100644 --- a/actions/index.js +++ b/actions/index.js @@ -110,7 +110,9 @@ const hashAPIPath = (queryPath) => { ); hashlink = hashlink.toString(CryptoJS.enc.Hex); - return "&hash=" + hashlink; + //return "&hash=" + hashlink; + + return (hashPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink; }; export const getBasicSearch = (token, searchString) => { @@ -990,19 +992,11 @@ export const getEmailAccountCheck = (emailAddress) => { }; export const createAccount = (formValues) => { - var data = JSON.stringify(formValues); + var data = formValues; //JSON.stringify(formValues); var queryUrl = "/api/proxy/contacts"; var config = { method: "post", url: queryUrl + hashAPIPath(queryUrl), - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - "Authorization": getToken(), - }, data: data, }; // console.log(config); @@ -1016,48 +1010,32 @@ export const createAccount = (formValues) => { }); }; -export const updateAccount = (contactId, updateBody) => { - var data = JSON.stringify(updateBody); +export const updateAccount = async (contactId, updateBody) => { + var data = updateBody; //JSON.stringify(updateBody); var queryUrl = "/api/proxy/contacts(" + contactId + ")"; + queryUrl = queryUrl + hashAPIPath(queryUrl); var config = { method: "patch", - url: queryUrl + hashAPIPath(queryUrl), - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - "Authorization": getToken(), - }, + url: queryUrl, 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); + console.log("this error:", error); }); }; export const updatePassword = (contactId, newpassword) => { let updateBody = { "pinswg_custom_password": newpassword }; - var data = JSON.stringify(updateBody); + var data = updateBody; //JSON.stringify(updateBody); var queryUrl = "/api/proxy/contacts(" + contactId + ")"; + queryUrl = queryUrl + hashAPIPath(queryUrl); var config = { method: "patch", - url: queryUrl + hashAPIPath(queryUrl), - headers: { - "OData-MaxVersion": "4.0", - "OData-Version": "4.0", - "Accept": "application/json", - "Prefer": 'odata.include-annotations="*",return=representation', - "Content-Type": "application/json", - "Authorization": getToken(), - }, + url: queryUrl, data: data, }; // console.log(config); diff --git a/components/account/registerComplete.js b/components/account/registerComplete.js index 4c057085..797c1c3e 100644 --- a/components/account/registerComplete.js +++ b/components/account/registerComplete.js @@ -75,52 +75,70 @@ const RegisterComplete = (props) => { } }); - return props.accountDetails.accCr == "created" ? ( - <> -

- {t("account:register-new-account-confirmation-email")} -

+ var registerBody = ""; + switch (props.accountDetails.accCr) { + case "created": + return (registerBody = ( + <> +

+ {t("account:register-new-account-confirmation-email")} +

-

- {t("account:register-new-account-sub-heading-what-next")} -

+

+ {t( + "account:register-new-account-sub-heading-what-next" + )} +

-

- {t("account:register-new-account-paragraph-what-next")} -

+

+ {t("account:register-new-account-paragraph-what-next")} +

-

- - { - setLogout(), window.localStorage.clear(); - }} - > - {t("account:register-new-account-my-portal-link")} - - -

- - ) : ( - <> -

- {t("account:register-new-account-account-failed")} -

-

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

- - ); +

+ + { + setLogout(), window.localStorage.clear(); + }} + > + {t( + "account:register-new-account-my-portal-link" + )} + + +

+ + )); + + break; + + case "exists": + return (registerBody = ( + <> +

+ {t("account:register-new-account-account-failed")} +

+

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

+ + )); + + default: + return (registerBody = ""); + break; + } + return registerBody; }; const mapStateToProps = (state) => { diff --git a/components/account/registerform.js b/components/account/registerform.js index 63981f1f..0b350e15 100644 --- a/components/account/registerform.js +++ b/components/account/registerform.js @@ -109,7 +109,7 @@ const RegisterForm = (props) => { setRegisterFormComplete(true); }; - console.log(pristine); + //console.log(pristine); return ( <> {!pristine && !valid && ( diff --git a/components/myportal/searchcases.js b/components/myportal/searchcases.js index 0668b7e5..941b27b1 100644 --- a/components/myportal/searchcases.js +++ b/components/myportal/searchcases.js @@ -24,41 +24,46 @@ const RenderTextfield = ({ input, hint1, hint2, + hint3, meta: { touched, error }, ...custom }) => { return ( <> -
+
- -
- - {hint2} CAS-00009-W8N6W4 - +
    +
  • {hint2}
  • +
  • {hint3}
  • +
- {touched && error && ( - - Error:{" "} - {error} - - )} - +
+ + {touched && error && ( + + + Error: + {" "} + {error} + + )} +
); @@ -121,7 +126,10 @@ let CaseSearch = (props) => { aria-describedby="basicSearch-hint" hint1={t("myportal:searchcases-card-search-hint")} hint2={t( - "myportal:searchcases-card-search-example-label" + "myportal:searchcases-card-search-example-label-1" + )} + hint3={t( + "myportal:searchcases-card-search-example-label-2" )} /> diff --git a/components/myportal/topthree.js b/components/myportal/topthree.js index 408b07dd..a77252e8 100644 --- a/components/myportal/topthree.js +++ b/components/myportal/topthree.js @@ -218,16 +218,16 @@ const TopThree = (props) => { let noRecordsLabel = ""; switch (topThreeType) { case "watchedCases": - noRecordsLabel = "You are not watching any cases"; + noRecordsLabel = t("myportal:norecords-watched-cases"); break; case "myRepresentations": - noRecordsLabel = "You have no representations"; + noRecordsLabel = t("myportal:norecords-representations"); break; case "myCases": - noRecordsLabel = "You have no cases"; + noRecordsLabel = t("myportal:norecords-cases"); break; case "awaitingSubmission": - noRecordsLabel = "You have no awaiting submissions"; + noRecordsLabel = t("myportal:norecords-awaiting-submissions"); break; } return ( diff --git a/i18n.js b/i18n.js index 235a7ade..7191ff53 100644 --- a/i18n.js +++ b/i18n.js @@ -33,6 +33,7 @@ module.exports = { "/dnsdetails": ["case", "search", "dnsCommon", "dnsApplications"], "/help/cookies": ["common", "cookies"], "/account/register": ["common", "account"], + "/account/personaldetails": ["common", "search"], "/details-about-cookies": ["common", "cookies"], "/terms-and-conditions": ["common"], }, diff --git a/locales/cy/account.json b/locales/cy/account.json index ca0bd367..bcb31768 100644 --- a/locales/cy/account.json +++ b/locales/cy/account.json @@ -1,7 +1,7 @@ { "register-new-account-heading": "Creu cyfrif newydd", - "register-new-account-status-created-label": "Nid yw'ch cyfrif wedi creu", - "register-new-account-status-not-created-label": "Mae eich cyfrif wedi'i greu", + "register-new-account-status-created-label": "Mae eich cyfrif wedi'i greu", + "register-new-account-status-not-created-label": "Nid yw'ch cyfrif wedi creu", "register-new-account-checking-label": "Gwirio am gyfrif...", "help-heading": "Help", "help-sub-heading-1": "Cwmnïau neu gyflwyniadau gan fwy nag un unigolyn (grwpiau)", diff --git a/locales/cy/myportal.json b/locales/cy/myportal.json index 240792a3..60cbc88f 100644 --- a/locales/cy/myportal.json +++ b/locales/cy/myportal.json @@ -7,10 +7,11 @@ "makenewappeal-card-paragraph-two": "Wedi i chi glicio'r botwm 'gwneud apêl newydd' isod, cewch eich arwain drwy broses i'ch helpu i ddewis y math cywir o apêl.", "makenewappeal-card-button-label": "Gwneud apêl newydd", "mycases-card-title": "Fy achosion", - "searchcases-card-title": "Chwilio am ddogfennau apêl", - "searchcases-card-search-hint": "Chwiliwch drwy roi cyfeirnod 7 digid yr achos", - "searchcases-card-search-example-label": "Enghraifft:", - "searchcases-card-button": "Cyflwyno Chwiliad", + "searchcases-card-title": "Chwilio apeliadau a Datblygiadau o Arwyddocâd Cenedlaethol", + "searchcases-card-search-hint": "Defnyddiwch gyfeimod yr achos neu deitl DAC i chwilio. Bydd cyfeirnod yr achos yn debyg i un o'r canlynol:", + "searchcases-card-search-example-label-1": "APP-A12345-A-21-1234567", + "searchcases-card-search-example-label-2": "CAS-12345-A1B2C3", + "searchcases-card-button": "Cyflwyno chwiliad", "searchcases-card-advanced-link": "Chwiliad uwch", "searchcases-validation-required": "Angenrheidiol", "searchcases-validation-minlength": "Rhaid bod yn 4 nod neu fwy", @@ -25,5 +26,9 @@ "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" + "changepassword-card-link": "Diweddarwch eich cyfrinair", + "norecords-cases": "Nid oes gennych unrhyw achosion", + "norecords-representations": "Nid oes gennych unrhyw sylwadau", + "norecords-watched-cases": "Nid ydych yn gwylio unrhyw achosion", + "norecords-awaiting-submission": "Nid oes gennych unrhyw gyflwyniadau sy'n aros" } \ No newline at end of file diff --git a/locales/en/account.json b/locales/en/account.json index d5b11a32..6ec50ee2 100644 --- a/locales/en/account.json +++ b/locales/en/account.json @@ -1,7 +1,7 @@ { "register-new-account-heading": "Create a new account", - "register-new-account-status-created-label": "Your account has not created", - "register-new-account-status-not-created-label": "Your account has been created", + "register-new-account-status-created-label": "Your account has created", + "register-new-account-status-not-created-label": "Your account has not been created", "register-new-account-checking-label": "Checking for account...", "help-heading": "Help", "help-sub-heading-1": "Companies or submissions by more than one individual (groups)", diff --git a/locales/en/myportal.json b/locales/en/myportal.json index 4af3f07c..a50b8bcd 100644 --- a/locales/en/myportal.json +++ b/locales/en/myportal.json @@ -7,9 +7,10 @@ "makenewappeal-card-paragraph-two": "Once you click the 'make a new appeal' button below you will be guided through a process to help you select the correct appeal type", "makenewappeal-card-button-label": "Make a new appeal", "mycases-card-title": "My cases", - "searchcases-card-title": "Appeal documentation search", - "searchcases-card-search-hint": "Search by entering the 7 digit case reference number", - "searchcases-card-search-example-label": "Example", + "searchcases-card-title": "Search appeals and Developments of National Significance", + "searchcases-card-search-hint": "Use the case reference or DNS title to search. Case reference will be similar to one of the following:", + "searchcases-card-search-example-label-1": "APP-A12345-A-21-1234567", + "searchcases-card-search-example-label-2": "CAS-12345-A1B2C3", "searchcases-card-button": "Submit Search", "searchcases-card-advanced-link": "Advanced Search", "searchcases-validation-required": "Required", @@ -25,5 +26,9 @@ "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" + "changepassword-card-link": "Update your password", + "norecords-cases": "You have no cases", + "norecords-representations": "You have no representations", + "norecords-watched-cases": "You are not watching any cases", + "norecords-awaiting-submission": "You have no awaiting submissions" } \ No newline at end of file diff --git a/pages/account/register.js b/pages/account/register.js index d77a917d..3981a80b 100644 --- a/pages/account/register.js +++ b/pages/account/register.js @@ -61,19 +61,26 @@ const Home = (props) => { ) : (

- {props.accountDetails.accCr != - "false" - ? props.accountDetails - .accCr == "exists" - ? t( - "account:register-new-account-status-not-created-label" - ) - : t( - "account:register-new-account-status-created-label" - ) - : t( + {console.log( + props.accountDetails.accCr + )} + + {props.accountDetails.accCr === + false + ? t( "account:register-new-account-checking-label" - )} + ) + : props.accountDetails + .accCr === "created" + ? t( + "account:register-new-account-status-created-label" + ) + : props.accountDetails + .accCr === "exists" + ? t( + "account:register-new-account-status-not-created-label" + ) + : "wewer"}

)} -1; - let hashCheckPath = isDocument - ? req.url.split("?hash=")[0] - : req.url.split("&hash=")[0]; - let hashCheckValue = isDocument - ? req.url.split("?hash=")[1] - : req.url.split("&hash=")[1]; + let hashCheckPath = + req.url.indexOf("?hash=") > -1 + ? req.url.split("?hash=")[0] + : req.url.split("&hash=")[0]; + + let hashCheckValue = + req.url.indexOf("?hash=") > -1 + ? req.url.split("?hash=")[1] + : req.url.split("&hash=")[1]; + let hashFromRequest = checkProxyPath(hashCheckPath); + let proxyDestinationURL = + PROXY_RELAY_URL + + (req.url.indexOf("?hash=") > -1 + ? req.url.split("?hash=")[0] + : req.url.split("&hash=")[0] + ).split("/api/proxy/")[1] + + (req.url.indexOf("?hash=") > -1 + ? "?hash=" + req.url.split("?hash=")[1] + : "&hash=" + req.url.split("&hash=")[1]); + var configNoData = { method: req.method, //url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")", - url: - PROXY_RELAY_URL + - req.url.split("&hash=")[0].split("/api/proxy/")[1] + - "&hash=" + - req.url.split("&hash=")[1], + url: proxyDestinationURL, headers: { "OData-MaxVersion": "4.0", "OData-Version": "4.0", @@ -105,11 +115,7 @@ export default async function ApiProxy(req, res) { var config = { method: req.method, - url: - PROXY_RELAY_URL + - req.query.route[0] + - "&hash=" + - req.url.split("&hash=")[1], + url: proxyDestinationURL, headers: { "OData-MaxVersion": "4.0", "OData-Version": "4.0", @@ -145,7 +151,9 @@ export default async function ApiProxy(req, res) { hashCheckPath.indexOf("/download") > 0 ? true : false; axios( - req.method == "GET" + req.method == "PATCH" + ? config + : req.method == "GET" ? hasDocument ? configDocument : configNoData @@ -177,6 +185,10 @@ export default async function ApiProxy(req, res) { }); }); } else { + console.log( + "no matching hash", + hashCheckValue + " - " + hashFromRequest + ); res.status(405).end(); return resolve(); }