added in right hand nav and titles to store
This commit is contained in:
@@ -14,7 +14,12 @@ import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
|
||||
import { setAppealType, gtAppealTypeObj } from "../../store/appealType/action";
|
||||
import {
|
||||
setAppealType,
|
||||
setAppealTypeTitle,
|
||||
setAppealTypeID,
|
||||
getAppealTypeObj,
|
||||
} from "../../store/appealType/action";
|
||||
import { getAppealsTypes } from "../../actions";
|
||||
import xpath from "xpath";
|
||||
|
||||
@@ -28,7 +33,8 @@ const Home = (props) => {
|
||||
|
||||
const { appealType } = props;
|
||||
|
||||
const optionsObj = props.appealType.appealType.GlobalOptionSet.Options;
|
||||
const optionsObj =
|
||||
props.appealType.appealTypeOptions.GlobalOptionSet.Options;
|
||||
|
||||
const appealOptions = Object.keys(optionsObj).map((key, index) => (
|
||||
<option
|
||||
@@ -47,11 +53,8 @@ const Home = (props) => {
|
||||
|
||||
const selectAppealType = (event) => {
|
||||
event.preventDefault();
|
||||
console.log(appealTypeSelect);
|
||||
// /searchresults
|
||||
|
||||
router.push({
|
||||
pathname: "/newappeal/" + appealTypeSelect,
|
||||
router.replace("/newappeal/" + props.appealType.appealTypeID, null, {
|
||||
shallow: true,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -86,9 +89,9 @@ const Home = (props) => {
|
||||
className="govuk-select"
|
||||
id="appealTypes"
|
||||
name="appealTypes"
|
||||
onChange={handleParam(
|
||||
setAppealTypeSelect
|
||||
)}
|
||||
onChange={(e) =>
|
||||
props.onChangeSelect(e)
|
||||
}
|
||||
>
|
||||
{appealOptions}
|
||||
</select>
|
||||
@@ -113,7 +116,7 @@ const Home = (props) => {
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) =>
|
||||
async ({ query, req, res }) => {
|
||||
const appealTypeData = (await getAppealsTypes()) || null;
|
||||
const appealTypeData = await getAppealsTypes();
|
||||
console.log("appeal types", appealTypeData);
|
||||
store.dispatch(setAppealType(appealTypeData));
|
||||
}
|
||||
@@ -128,4 +131,17 @@ const mapStateToProps = (state) => {
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(Home);
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
onChangeSelect: (event) => {
|
||||
dispatch(
|
||||
setAppealTypeTitle(
|
||||
event.target.options[event.target.selectedIndex].text
|
||||
)
|
||||
);
|
||||
dispatch(setAppealTypeID(event.target.value));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Home);
|
||||
|
||||
Reference in New Issue
Block a user