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}
+
+
+ {label}
+
+ {touched && error && (
+
+ Error: {" "}
+ {error}
+
+ )}
+
+
+ >
+ );
+};
+const RenderPasswordfield = ({
+ id,
+ className,
+ rows,
+ datafieldname,
+ name,
+ label,
+ input,
+ hint1,
+ hint2,
+ meta: { touched, error },
+ ...custom
+}) => {
+ return (
+ <>
+
+
+ {hint1}
+
+
+ {label}
+
+ {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")}
-
+
+
);
-}
+};
+
+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")}
-
- Please enable javascript
+ {t("common:enable-js-label")}
- 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() {
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) => {
@@ -59,14 +68,38 @@ export const getServerSideProps = wrapper.getServerSideProps(
(store) =>
async ({ query, req, res }) => {
console.log("query-", query);
- // const [searchResultsObj, searchDetailsObj] = await Promise.all(
- // await getBasicSearch(query.q),
- // await getBasicSearchDetails(query.d)
+
+ const token = await getSASToken();
+
+ let searchResultsObj = await getBasicSearch(token, query.q);
+
+ searchResultsObj =
+ searchResultsObj.status == 502
+ ? {
+ value: [],
+ errorCode: searchResultsObj.status,
+ errorMsg: searchResultsObj.statusText,
+ }
+ : searchResultsObj;
+
+ //console.log("sssss", searchResultsObj);
+
+ const searchDetailsObj = await getSearchDetails(
+ token,
+ searchResultsObj
+ );
+
+ // const searchDocumentResultsObj = await getDocumentDetails(
+ // token,
+ // searchResultsObj
// );
- const searchResultsObj = await getBasicSearch(query.q);
- const searchDetailsObj = await getSearchDetails(searchResultsObj);
- // console.log(searchDetailsObj);
+ // const searchDocumentHistoryObj = await getDocumentHistory(
+ // token,
+ // searchDocumentResultsObj
+ // );
+ // console.log(searchDocumentHistoryObj);
+
store.dispatch(setSearchResults(searchResultsObj));
store.dispatch(setSearchDetails(searchDetailsObj));
store.dispatch(setSearch(query.q));
@@ -82,7 +115,7 @@ const getFormCollection = (formtype) => {
return collectionName[0];
};
-const getSearchDetails = (searchResultsObj) => {
+const getSearchDetails = (token, searchResultsObj) => {
//console.log(searchResultsObj);
let detailsArr = [];
@@ -93,13 +126,15 @@ const getSearchDetails = (searchResultsObj) => {
} else {
detailsArr.push(
getBasicSearchDetails(
+ token,
getFormCollection(
"pinswg_" +
searchDetail[
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
]
- .replace(/[\s\-\+\(\)\,\&\.]/g, "")
+ .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
.toLowerCase()
+ .slice(0, 39)
),
searchDetail.ticketnumber
)
@@ -122,6 +157,7 @@ const mapStateToProps = (state) => {
watchedCases: state.watchedCases,
myRepresentations: state.myRepresentations,
awaitingSubmission: state.awaitingSubmission,
+ accountDetails: state.accountDetails,
};
};
diff --git a/pages/newappeal/[appealtypes].js b/pages/newappeal/[appealtypes].js
index 8c3d8755..6158875a 100644
--- a/pages/newappeal/[appealtypes].js
+++ b/pages/newappeal/[appealtypes].js
@@ -258,49 +258,42 @@ let Home = (props) => {
};
export const getServerSideProps = wrapper.getServerSideProps(
- (store) =>
- async ({ query, req, res }) => {
- console.log("the query", query);
- const token = await getSASToken();
- const [
- caseReferenceData,
- appealTypeData,
- mandatoryFieldsData,
- pickListData,
- formdata,
- ] = await Promise.all([
- await createCase(token, query.apt),
- await getAppealsTypes(token),
- await getMandatoryFields(token, query.appealtypes),
- await getPickLists(token, query.appealtypes),
- await getFormData(token, query.appealtypes),
- ]);
+ (store) => async (ctx) => {
+ const { query, req, res } = ctx;
+ const { cookies } = req;
- // let updateCaseReferenceData = await updateCase(
- // caseReferenceData.incidentid,
- // query.apt
- // );
+ console.log(cookies);
+ console.log("the query", query);
+ let loggedInUser = cookies.pinsUser;
- const cookies = new Cookies(req, res);
- // Get a cookie
+ const token = await getSASToken();
+ const [
+ caseReferenceData,
+ appealTypeData,
+ mandatoryFieldsData,
+ pickListData,
+ formdata,
+ ] = await Promise.all([
+ await createCase(token, query.apt, loggedInUser),
+ await getAppealsTypes(token),
+ await getMandatoryFields(token, query.appealtypes),
+ await getPickLists(token, query.appealtypes),
+ await getFormData(token, query.appealtypes),
+ ]);
- console.log(cookies.get("pipinsUser"));
+ let caseReference = caseReferenceData;
+ let xmlStr = formdata;
+ xmlStr = formdata.value[0].formxml;
+ xmlStr = xmlStr.replace(/\\"/g, "");
- let caseReference = caseReferenceData;
- let xmlStr = formdata;
- xmlStr = formdata.value[0].formxml;
- xmlStr = xmlStr.replace(/\\"/g, "");
-
- //console.log(caseReference, query.appealtypes, formdata);
- store.dispatch(
- setLoggedInUserId("f8b454ed-eded-eb11-aac7-00224800be9c")
- );
- store.dispatch(setAppealLPA(query.lpa));
- store.dispatch(setAppealTypeID(query.apt));
- store.dispatch(setCaseReference(caseReference));
- store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
- store.dispatch(setAppealType(appealTypeData));
- }
+ //console.log(caseReference, query.appealtypes, formdata);
+ store.dispatch(setLoggedInUserId(loggedInUser));
+ store.dispatch(setAppealLPA(query.lpa));
+ store.dispatch(setAppealTypeID(query.apt));
+ store.dispatch(setCaseReference(caseReference));
+ store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
+ store.dispatch(setAppealType(appealTypeData));
+ }
);
const mapStateToProps = (state) => {
diff --git a/pages/newappeal/index.js b/pages/newappeal/index.js
index 6e40b72d..e2b0a1ea 100644
--- a/pages/newappeal/index.js
+++ b/pages/newappeal/index.js
@@ -19,6 +19,10 @@ import { reduxForm, formValueSelector } from "redux-form";
import CreateCase from "../../components/newappeal/createCase";
import xpath from "xpath";
+import {
+ setLoggedInUserId,
+ setAccountDetails,
+} from "../../store/accountDetails/action";
import {
setAppealType,
setAppealTypeTitle,
@@ -78,18 +82,25 @@ const Home = (props) => {
};
export const getServerSideProps = wrapper.getServerSideProps(
- (store) =>
- async ({ query, req, res }) => {
- const token = await getSASToken();
+ (store) => async (ctx) => {
+ const { req, res } = ctx;
+ const { cookies } = req;
- const [appealTypeData, lpaData, caseData] = await Promise.all([
- await getAppealsTypes(token),
- await getLPA(token),
- ]);
+ console.log(cookies);
- store.dispatch(setAppealType(appealTypeData));
- store.dispatch(setLPA(lpaData));
- }
+ let loggedInUser = cookies.pinsUser;
+
+ const token = await getSASToken();
+
+ const [appealTypeData, lpaData, caseData] = await Promise.all([
+ await getAppealsTypes(token),
+ await getLPA(token),
+ ]);
+
+ store.dispatch(setAppealType(appealTypeData));
+ store.dispatch(setLPA(lpaData));
+ store.dispatch(setLoggedInUserId(loggedInUser));
+ }
);
const mapStateToProps = (state) => {
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,
diff --git a/store/accountDetails/action.js b/store/accountDetails/action.js
index 884c3090..e8ffd37c 100644
--- a/store/accountDetails/action.js
+++ b/store/accountDetails/action.js
@@ -1,7 +1,11 @@
+import actions from "redux-form/lib/actions";
+
export const AccountDetailsDataActionTypes = {
GETACCOUNTDETAILSDATA: "GETACCOUNTDETAILSDATA",
SETACCOUNTDETAILSDATA: "SETACCOUNTDETAILSDATA",
SETLOGGEDINUSER: "SETLOGGEDINUSER",
+ SETACCOUNTCREATED: "SETACCOUNTCREATED",
+ USER_LOGOUT: "USER_LOGOUT",
};
export const getAccountDetailsObj = () => (dispatch) => {
@@ -29,3 +33,10 @@ export const setLogout = () => (dispatch) => {
type: "USER_LOGOUT",
});
};
+
+export const setAccCr = (accCr) => (dispatch) => {
+ return dispatch({
+ type: AccountDetailsDataActionTypes.SETACCOUNTCREATED,
+ accCr: accCr,
+ });
+};
diff --git a/store/accountDetails/reducer.js b/store/accountDetails/reducer.js
index 24a102c3..0d0ffc9d 100644
--- a/store/accountDetails/reducer.js
+++ b/store/accountDetails/reducer.js
@@ -3,6 +3,7 @@ import { AccountDetailsDataActionTypes } from "./action";
const AccountDetailsDataInitialState = {
accountDetails: {},
loggedinUserId: "",
+ accCr: false,
};
export default function reducer(
@@ -20,6 +21,11 @@ export default function reducer(
...state,
loggedinUserId: action.loggedinUserId,
};
+ case AccountDetailsDataActionTypes.SETACCOUNTCREATED:
+ return {
+ ...state,
+ accCr: action.accCr,
+ };
default:
return state;
}
diff --git a/styles/sass/welshgov/_application.scss b/styles/sass/welshgov/_application.scss
index 15423e67..165badfd 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,11 +642,26 @@ 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;
}
}
+.results .govuk-summary-list__key {
+ &:last-of-type {
+ width: 30%;
+ }
+}
.results_wider {
width: 170px !important;
@@ -679,8 +708,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 +719,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 {