base flow for representations
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import { setCurrentReference } from "../../store/currentView/action";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
export default function SearchResults(props) {
|
||||
const { searchString, searchResultsObj } = props;
|
||||
const SearchResults = (props) => {
|
||||
const { searchString, searchResultsObj, setCurrentReference } = props;
|
||||
let { t } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
const { locale } = router;
|
||||
|
||||
var resultsArr = props.searchResultsObj.searchResultsObj.value || [{}];
|
||||
var resultsArr = searchResultsObj.value || [{}];
|
||||
const resultRow = Object.keys(resultsArr).map((key, index) => {
|
||||
<div className="govuk-summary-list__row">
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-14 govuk-!-padding-left-2">
|
||||
@@ -58,9 +60,7 @@ export default function SearchResults(props) {
|
||||
</h1>
|
||||
<p className="govuk-body">
|
||||
{t("search:searchresults-count-label", {
|
||||
count: props.searchResultsObj.searchResultsObj[
|
||||
"@odata.count"
|
||||
].toString(),
|
||||
count: searchResultsObj["@odata.count"].toString(),
|
||||
})}
|
||||
. You searched for <em>"{searchString}"</em>
|
||||
</p>
|
||||
@@ -91,7 +91,16 @@ export default function SearchResults(props) {
|
||||
<div className="govuk-summary-list__row" key={key}>
|
||||
<dd className="govuk-summary-list__value govuk-!-font-size-14 govuk-!-padding-left-2">
|
||||
<Link href="/case">
|
||||
<a>
|
||||
<a
|
||||
onClick={() => {
|
||||
setCurrentReference({
|
||||
"currentReference":
|
||||
item.title,
|
||||
"currentType":
|
||||
"searchResultsObj",
|
||||
});
|
||||
}}
|
||||
>
|
||||
<span className="results-visually-hidden">
|
||||
Case Reference:
|
||||
</span>
|
||||
@@ -151,4 +160,14 @@ export default function SearchResults(props) {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
setCurrentReference: (currentReference) => {
|
||||
dispatch(setCurrentReference(currentReference));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(null, mapDispatchToProps)(SearchResults);
|
||||
|
||||
Reference in New Issue
Block a user