added in right hand nav and titles to store
This commit is contained in:
@@ -12,15 +12,27 @@ import { wrapper } from "../../store/store";
|
||||
import Cookies from "cookies";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import jsonpath from "jsonpath";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import {
|
||||
setAppealType,
|
||||
setAppealTypeTitle,
|
||||
setAppealTypeID,
|
||||
getAppealTypeObj,
|
||||
} from "../../store/appealType/action";
|
||||
import { setForm, getFormObj } from "../../store/formData/action";
|
||||
import { getFormData } from "../../actions";
|
||||
import { getFormData, getAppealsTypes } from "../../actions";
|
||||
|
||||
import xpath from "xpath";
|
||||
import { reduxForm } from "redux-form";
|
||||
|
||||
import BuildSection from "../../components/newappeal/buildsection";
|
||||
|
||||
let Home = (props) => {
|
||||
useEffect(() => {
|
||||
props.setFormTitle(formTitle);
|
||||
}, []);
|
||||
const { footerLinks, pages, formData } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
@@ -40,6 +52,31 @@ let Home = (props) => {
|
||||
|
||||
var tabs = xpath.select("//form/tabs/tab[*]", doc);
|
||||
|
||||
let optionsStr = props.appealType.appealTypeOptions.GlobalOptionSet.Options;
|
||||
|
||||
let selectedObj = jsonpath.query(
|
||||
optionsStr,
|
||||
"$..LocalizedLabels[?(@.Label)].Label"
|
||||
);
|
||||
|
||||
//let optionsTitleObj = [];
|
||||
|
||||
const optionsTitleObj = selectedObj.reduce(
|
||||
(obj, arrValue) => (
|
||||
(obj[arrValue] = arrValue
|
||||
.replace(/[\s\-\+\(\)\,]/g, "")
|
||||
.toLowerCase()),
|
||||
obj
|
||||
),
|
||||
{}
|
||||
);
|
||||
|
||||
const formTitle = Object.keys(optionsTitleObj).find(
|
||||
(key) => optionsTitleObj[key] === appealtypes
|
||||
);
|
||||
|
||||
console.log(formTitle);
|
||||
|
||||
// crm api query for looking up picklist fields/drop downs
|
||||
// <url path to >/api/data/v8.2/EntityDefinitions(LogicalName='{appeal type form}')/Attributes(LogicalName='{drop down datafield name}')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)
|
||||
// eg https://devcrm2016.llcdt.gov.wales/DVPINS/api/data/v8.2/EntityDefinitions(LogicalName='pinswg_householderappealhas')/Attributes(LogicalName='pinswg_casetype')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)
|
||||
@@ -58,15 +95,6 @@ let Home = (props) => {
|
||||
/// to get dropdowns names
|
||||
// form/tabs/tab[*]//rows/row//control[@classid="{3EF39988-22BB-4f0b-BBBE-64B5A3748AEE}"]/@datafieldname
|
||||
|
||||
const Sections = Object.keys(tabs).map((key, index) => (
|
||||
<BuildSection
|
||||
formXML={formXML}
|
||||
whichSection={key}
|
||||
sectionCount={sectionCount}
|
||||
key={key}
|
||||
/>
|
||||
));
|
||||
|
||||
const { onSubmit } = props;
|
||||
|
||||
return (
|
||||
@@ -87,6 +115,7 @@ let Home = (props) => {
|
||||
formXML={formXML}
|
||||
sectionCount={sectionCount}
|
||||
onSubmit={onSubmit}
|
||||
formTitle={formTitle}
|
||||
/>
|
||||
</div>
|
||||
<Footer footerLinks={footerLinks} />
|
||||
@@ -99,11 +128,15 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) =>
|
||||
async ({ query, req, res }) => {
|
||||
console.log("the query", query);
|
||||
store.dispatch(setAppealTypeID(query.appealtypes));
|
||||
const appealTypeData = await getAppealsTypes();
|
||||
const formdata = (await getFormData(query.appealtypes)) || null;
|
||||
|
||||
let xmlStr = formdata;
|
||||
xmlStr = formdata.value[0].formxml;
|
||||
xmlStr = xmlStr.replace(/\\"/g, "");
|
||||
store.dispatch(setForm(xmlStr));
|
||||
store.dispatch(setAppealType(appealTypeData));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -139,4 +172,12 @@ const mapStateToProps = (state) => {
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(Home);
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setFormTitle: (title) => {
|
||||
dispatch(setAppealTypeTitle(title));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Home);
|
||||
|
||||
Reference in New Issue
Block a user