Merged PR 563: updated query to remove ldp and misc types
updated query to remove ldp and misc types Related work items: #6501
This commit is contained in:
+75
-10
@@ -617,7 +617,7 @@ export const getAppealsTypes = (token) => {
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
"stringmaps?$filter=attributename%20eq%20%27pinswg_appealcasetype%27&$count=true&$select=value,stringmapid,organizationid,attributevalue",
|
||||
"stringmaps?$filter=attributename eq 'pinswg_appealcasetype' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue",
|
||||
azureHeaders(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
@@ -642,7 +642,7 @@ export const getLPA = (token) => {
|
||||
azureHeaders(token)
|
||||
)
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
//console.log(res.data);
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -656,18 +656,28 @@ export const getLPA = (token) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getPersonalAccount = () => {
|
||||
console.log("api_root: ", BASE_URL);
|
||||
export const getPersonalAccount = (token, contactid) => {
|
||||
console.log("getting personal details:", contactid);
|
||||
return axios
|
||||
|
||||
.get(
|
||||
BASE_URL + "/api/lookups/personaldetails",
|
||||
//.get("https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/contacts?$select=name",
|
||||
{ httpsAgent: new https.Agent({ rejectUnauthorized: false }) }
|
||||
WEBAPI_URL +
|
||||
"contacts(" +
|
||||
contactid +
|
||||
")?$select=firstname, lastname, emailaddress1, telephone1, company, address1_line1,address1_line2,address1_city, address1_county,address1_postalcode&$count=true",
|
||||
azureHeaders(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("thi serror", error);
|
||||
let ErrResponse = {
|
||||
value: [],
|
||||
errorCode: error.response.status,
|
||||
errorMsg: error.response.statusText,
|
||||
};
|
||||
|
||||
return ErrResponse;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -916,3 +926,58 @@ export const createAccount = (formValues) => {
|
||||
console.log("this serror", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const updateAccount = (contactId, updateBody) => {
|
||||
var data = JSON.stringify(updateBody);
|
||||
|
||||
var config = {
|
||||
method: "patch",
|
||||
url: "/api/proxy/contacts(" + contactId + ")",
|
||||
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);
|
||||
});
|
||||
};
|
||||
|
||||
export const updatePassword = (contactId, newpassword) => {
|
||||
let updateBody = { "pinswg_custom_password": newpassword };
|
||||
var data = JSON.stringify(updateBody);
|
||||
|
||||
var config = {
|
||||
method: "patch",
|
||||
url: "/api/proxy/contacts(" + contactId + ")",
|
||||
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);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ const RenderTextfield = ({
|
||||
input,
|
||||
type,
|
||||
errorMsg,
|
||||
disabled,
|
||||
meta: { touched, error },
|
||||
...custom
|
||||
}) => {
|
||||
@@ -55,18 +56,23 @@ const RenderTextfield = ({
|
||||
name={id}
|
||||
id={id}
|
||||
type={type}
|
||||
disabled={disabled ? true : false}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const PersonalDetails = (props) => {
|
||||
let PersonalDetails = (props) => {
|
||||
const {
|
||||
handleSubmit,
|
||||
value,
|
||||
setPersonalDetailsComplete,
|
||||
setAccountUpdatedComplete,
|
||||
load,
|
||||
pristine,
|
||||
reset,
|
||||
submitting,
|
||||
} = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
@@ -126,17 +132,18 @@ const PersonalDetails = (props) => {
|
||||
errorMsg="Is required"
|
||||
/>
|
||||
<Field
|
||||
name="email"
|
||||
id="email"
|
||||
name="emailaddress1"
|
||||
id="emailaddress1"
|
||||
component={RenderTextfield}
|
||||
type="email"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
validate={[required, email]}
|
||||
label="Email address"
|
||||
disabled
|
||||
/>
|
||||
<Field
|
||||
name="telephone"
|
||||
id="telephone"
|
||||
name="telephone1"
|
||||
id="telephone1"
|
||||
component={RenderTextfield}
|
||||
type="number"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
@@ -145,8 +152,8 @@ const PersonalDetails = (props) => {
|
||||
/>
|
||||
|
||||
<Field
|
||||
name="companygroup"
|
||||
id="companygroup"
|
||||
name="company"
|
||||
id="company"
|
||||
component={RenderTextfield}
|
||||
type="text"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
@@ -162,8 +169,8 @@ const PersonalDetails = (props) => {
|
||||
</legend>
|
||||
|
||||
<Field
|
||||
name="addressline1"
|
||||
id="addressline1"
|
||||
name="address1_line1"
|
||||
id="address1_line1"
|
||||
component={RenderTextfield}
|
||||
type="text"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
@@ -172,8 +179,8 @@ const PersonalDetails = (props) => {
|
||||
errorMsg="Is required"
|
||||
/>
|
||||
<Field
|
||||
name="addressline2"
|
||||
id="addressline2"
|
||||
name="address1_line2"
|
||||
id="address1_line2"
|
||||
component={RenderTextfield}
|
||||
type="text"
|
||||
className="govuk-input govuk-input--width-20"
|
||||
@@ -181,8 +188,8 @@ const PersonalDetails = (props) => {
|
||||
errorMsg="Is required"
|
||||
/>
|
||||
<Field
|
||||
name="towncity"
|
||||
id="towncity"
|
||||
name="address1_city"
|
||||
id="address1_city"
|
||||
component={RenderTextfield}
|
||||
type="text"
|
||||
className="govuk-input govuk-input--width-10"
|
||||
@@ -191,8 +198,8 @@ const PersonalDetails = (props) => {
|
||||
errorMsg="Is required"
|
||||
/>
|
||||
<Field
|
||||
name="county"
|
||||
id="county"
|
||||
name="address1_county"
|
||||
id="address1_county"
|
||||
component={RenderTextfield}
|
||||
type="text"
|
||||
className="govuk-input govuk-input--width-10"
|
||||
@@ -201,8 +208,8 @@ const PersonalDetails = (props) => {
|
||||
errorMsg="Is required"
|
||||
/>
|
||||
<Field
|
||||
name="postcode"
|
||||
id="postcode"
|
||||
name="address1_postalcode"
|
||||
id="address1_postalcode"
|
||||
component={RenderTextfield}
|
||||
type="text"
|
||||
className="govuk-input govuk-input--width-5"
|
||||
@@ -235,7 +242,7 @@ const PersonalDetails = (props) => {
|
||||
</>
|
||||
)
|
||||
) : (
|
||||
<PersonalDetailsComplete />
|
||||
<PersonalDetailsComplete props={props} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
@@ -262,23 +269,37 @@ const mapDispatchToProps = (dispatch) => {
|
||||
|
||||
const selector = formValueSelector("personalDetailsForm"); // <-- same as form name
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
//, (state) => ({
|
||||
// initialValues: state.accountDetails.accountDetails.data,
|
||||
// // search: state.search,
|
||||
// searchResultsObj: state.searchResultsObj,
|
||||
// formData: state.formData,
|
||||
// appealType: state.appealType,
|
||||
// accountDetails: state.accountDetails,
|
||||
// form: state.form,
|
||||
// pull initial values from account reducer
|
||||
//})
|
||||
)(
|
||||
reduxForm({
|
||||
form: "personalDetailsForm",
|
||||
enableReinitialize: true, // this is needed!!
|
||||
destroyOnUnmount: false,
|
||||
})(PersonalDetails)
|
||||
);
|
||||
// export default connect(
|
||||
// mapStateToProps,
|
||||
// mapDispatchToProps
|
||||
// //, (state) => ({
|
||||
// // initialValues: state.accountDetails.accountDetails.data,
|
||||
// // // search: state.search,
|
||||
// // searchResultsObj: state.searchResultsObj,
|
||||
// // formData: state.formData,
|
||||
// // appealType: state.appealType,
|
||||
// // accountDetails: state.accountDetails,
|
||||
// // form: state.form,
|
||||
// // pull initial values from account reducer
|
||||
// //})
|
||||
// )(
|
||||
// reduxForm({
|
||||
// form: "personalDetailsForm",
|
||||
// enableReinitialize: true, // this is needed!!
|
||||
// destroyOnUnmount: false,
|
||||
// })(PersonalDetails)
|
||||
// );
|
||||
|
||||
// Decorate with reduxForm(). It will read the initialValues prop provided by connect()
|
||||
PersonalDetails = reduxForm({
|
||||
form: "personalDetailsForm",
|
||||
enableReinitialize: true, // this is needed!!
|
||||
destroyOnUnmount: false,
|
||||
})(PersonalDetails);
|
||||
|
||||
// You have to connect() to any reducers that you wish to connect to yourself
|
||||
PersonalDetails = connect((state) => ({
|
||||
initialValues: state.accountDetails.accountDetails, // pull initial values from account reducer
|
||||
}))(PersonalDetails);
|
||||
|
||||
export default PersonalDetails;
|
||||
|
||||
@@ -80,7 +80,7 @@ const BuildCheckPersonalDetails = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{
|
||||
props.props.props.form.personalDetailsForm.values
|
||||
.email
|
||||
.emailaddress1
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__actions">
|
||||
@@ -104,7 +104,7 @@ const BuildCheckPersonalDetails = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{
|
||||
props.props.props.form.personalDetailsForm.values
|
||||
.telephone
|
||||
.telephone1
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__actions">
|
||||
@@ -127,7 +127,7 @@ const BuildCheckPersonalDetails = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{
|
||||
props.props.props.form.personalDetailsForm.values
|
||||
.companygroup
|
||||
.company
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__actions">
|
||||
@@ -155,7 +155,7 @@ const BuildCheckPersonalDetails = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{
|
||||
props.props.props.form.personalDetailsForm.values
|
||||
.addressline1
|
||||
.address1_line1
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__actions">
|
||||
@@ -179,7 +179,7 @@ const BuildCheckPersonalDetails = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{
|
||||
props.props.props.form.personalDetailsForm.values
|
||||
.addressline2
|
||||
.address1_line2
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__actions">
|
||||
@@ -203,7 +203,7 @@ const BuildCheckPersonalDetails = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{
|
||||
props.props.props.form.personalDetailsForm.values
|
||||
.towncity
|
||||
.address1_city
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__actions">
|
||||
@@ -227,7 +227,7 @@ const BuildCheckPersonalDetails = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{
|
||||
props.props.props.form.personalDetailsForm.values
|
||||
.county
|
||||
.address1_county
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__actions">
|
||||
@@ -251,7 +251,7 @@ const BuildCheckPersonalDetails = (props) => {
|
||||
<dd className="govuk-summary-list__value">
|
||||
{
|
||||
props.props.props.form.personalDetailsForm.values
|
||||
.postcode
|
||||
.address1_postalcode
|
||||
}
|
||||
</dd>
|
||||
<dd className="govuk-summary-list__actions">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import _ from "lodash";
|
||||
import Link from "next/link";
|
||||
import React, { useState } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import {
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
setRegisterFormComplete,
|
||||
setAccountCreatedComplete,
|
||||
} from "react-redux";
|
||||
import { updateAccount } from "../../actions";
|
||||
|
||||
const PersonalDetailsComplete = (props) => {
|
||||
const {
|
||||
@@ -30,6 +31,12 @@ const PersonalDetailsComplete = (props) => {
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
useEffect(() => {
|
||||
let contactid = props.accountDetails.loggedinUserId;
|
||||
let updateBody = props.props.props.form.personalDetailsForm.values;
|
||||
updateAccount(contactid, updateBody);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<p className="govuk-body">Your details have been updated</p>
|
||||
@@ -41,7 +48,9 @@ const PersonalDetailsComplete = (props) => {
|
||||
</p>
|
||||
|
||||
<p className="govuk-body">
|
||||
<Link href="/myportal">
|
||||
<Link
|
||||
href={"/myportal?q=" + props.accountDetails.loggedinUserId}
|
||||
>
|
||||
<a className="govuk-link">Return to My Portal</a>
|
||||
</Link>
|
||||
</p>
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ export default function Home({ children, pages }) {
|
||||
<CaseComment />
|
||||
<Dns />
|
||||
{/* <Login />
|
||||
<Inspectorate /> */}
|
||||
<Inspectorate /> */}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -297,7 +297,7 @@
|
||||
"pinswg_lpa": 0
|
||||
},
|
||||
{
|
||||
"value": "Rhondda Cynon Taf County Borough Council",
|
||||
"value": "Rhondda Cynon Taff County Borough Council",
|
||||
"value_cy": "Cyngor Bwrdeistref Sirol Rhondda Cynon Taf",
|
||||
"pinswg_lpa": 0
|
||||
},
|
||||
|
||||
@@ -88,17 +88,17 @@ const Home = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) =>
|
||||
async ({ query, req, res }) => {
|
||||
const appealTypeData = await getAppealsTypes();
|
||||
const lpaData = await getLPA();
|
||||
console.log("appeal types", appealTypeData);
|
||||
console.log("lpa typeswwwww", lpaData);
|
||||
store.dispatch(setAppealType(appealTypeData));
|
||||
store.dispatch(setLPA(lpaData));
|
||||
}
|
||||
);
|
||||
// export const getServerSideProps = wrapper.getServerSideProps(
|
||||
// (store) =>
|
||||
// async ({ query, req, res }) => {
|
||||
// const appealTypeData = await getAppealsTypes();
|
||||
// const lpaData = await getLPA();
|
||||
// console.log("appeal types", appealTypeData);
|
||||
// console.log("lpa typeswwwww", lpaData);
|
||||
// store.dispatch(setAppealType(appealTypeData));
|
||||
// store.dispatch(setLPA(lpaData));
|
||||
// }
|
||||
// );
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
|
||||
+29
-13
@@ -15,6 +15,7 @@ import { wrapper } from "../../store/store";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import data from "../../data/collections.json";
|
||||
import nookies from "nookies";
|
||||
import {
|
||||
setLoggedInUserId,
|
||||
setAccountDetails,
|
||||
@@ -34,6 +35,7 @@ import {
|
||||
} from "../../store/awaitingSubmission/action";
|
||||
import {
|
||||
getSASToken,
|
||||
getPersonalAccount,
|
||||
getMyCases,
|
||||
getMyRepresentations,
|
||||
getWatchedCases,
|
||||
@@ -157,21 +159,35 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
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 [
|
||||
accountDetails,
|
||||
myCases,
|
||||
myRepresentations,
|
||||
watchedCases,
|
||||
awaitingSubmission,
|
||||
] = await Promise.all([
|
||||
await getPersonalAccount(token, loggedInUser),
|
||||
await getMyCases(token, loggedInUser),
|
||||
await getMyRepresentations(token, loggedInUser),
|
||||
await getWatchedCases(token, loggedInUser),
|
||||
await getAwaitingSubmission(token),
|
||||
]);
|
||||
|
||||
// const cookiesMaker = new Cookies(req, res);
|
||||
console.log("perosnal: ", accountDetails);
|
||||
|
||||
// cookiesMaker.set("pinsUser", query.q, {
|
||||
// httpOnly: true, // true by default
|
||||
// });
|
||||
//const cookiesMaker = nookies.get(ctx)
|
||||
|
||||
let now = new Date();
|
||||
let expDate = new Date(now);
|
||||
expDate.setDate(now.getDate() + 1);
|
||||
|
||||
nookies.set(ctx, "pinsUser", query.q, {
|
||||
expires: expDate,
|
||||
httpOnly: false,
|
||||
});
|
||||
|
||||
console.log(" from cookie ", cookies);
|
||||
|
||||
// console.log(" from cookie ", cookiesMaker.get("pinsUser"));
|
||||
console.log(myCases);
|
||||
|
||||
const [
|
||||
@@ -187,7 +203,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
]);
|
||||
|
||||
console.log(myCasesDetails);
|
||||
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||
store.dispatch(setMyCases(myCases));
|
||||
store.dispatch(setMyCasesDetails(myCasesDetails));
|
||||
|
||||
Reference in New Issue
Block a user