diff --git a/actions/index.js b/actions/index.js index dfd370b0..3e902345 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); }); }; @@ -298,6 +299,7 @@ export const getSearchDocumentHistory1 = (documentID) => { console.log("thiserror", error); }); }; + export const getBasicDNSSearchDetails = (token, appealType, caseReference) => { return axios .get( @@ -399,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 @@ -507,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, }); @@ -586,6 +559,7 @@ export const updateCase = async ( }; export const getMyCases = (token, loggedInUserId) => { + console.log("in action ", loggedInUserId); return axios .get( WEBAPI_URL + @@ -594,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", { @@ -608,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) @@ -618,7 +596,7 @@ export const getMyRepresentations = (token) => { ); }; -export const getWatchedCases = (token) => { +export const getWatchedCases = (token, loggedInUserId) => { return ( axios @@ -627,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,17 +644,43 @@ export const getPortalModuelDetails = (token, appealType, caseReference) => { }); }; -export const getFileFromCRM = (docRef) => { - const weburl = "/api/proxy/documents/download/" + docRef; - - console.log("proxy url", weburl); +export const getEmailAccountCheck = (emailAddress) => { + let token = getSASToken(); return axios - .get(weburl, { responseType: "arraybuffer" }) - .then((res) => { - console.log(res); - return res; - }) + .get( + "/api/proxy/contacts?$filter=emailaddress1 eq '" + + emailAddress + + "'&$count=true&$select=emailaddress1, contactid" + ) + .then((res) => res.data) .catch((error) => { - console.log("thi serror", 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/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/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/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 ( <>
{ "/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/main.js b/components/main.js index 19cfb3e3..77401b4b 100644 --- a/components/main.js +++ b/components/main.js @@ -28,8 +28,8 @@ export default function Home({ children, pages }) { - {/* - */} + + {/* */}
    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() {
    - Edit your account details + View your account details
    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 = @@ -61,7 +49,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(); @@ -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 @@ -121,18 +114,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/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) => {