🪢 Wired up the updated Elasticsearch call to the potential matches page

This commit is contained in:
2022-02-07 09:55:21 -08:00
parent cf1fe451c9
commit 8fdd8d0226
2 changed files with 20 additions and 9 deletions

View File

@@ -43,7 +43,7 @@
"ellipsize": "^0.1.0",
"express": "^4.17.1",
"fastest-validator": "^1.11.0",
"filename-parser": "^1.0.1",
"filename-parser": "^1.0.2",
"final-form": "^4.20.2",
"final-form-arrays": "^3.0.2",
"html-to-text": "^8.1.0",

View File

@@ -1,4 +1,4 @@
import { isEmpty, extend, each } from "lodash";
import { isEmpty, extend, each, matches } from "lodash";
import {
CV_API_CALL_IN_PROGRESS,
CV_SEARCH_SUCCESS,
@@ -71,19 +71,30 @@ function comicinfoReducer(state = initialState, action) {
};
case CV_ISSUES_FOR_VOLUME_IN_LIBRARY_SUCCESS:
// console.log("jagan", action);
return {
...state,
issuesForVolume: action.issues,
inProgress: false,
};
case CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED:
console.log(action);
const updatedState = [...state.issuesForVolume];
// updatedState[issueToUpdateIndex].matches = action.result.matches;
// console.log(issueToUpdateIndex);
// console.log(updatedState[issueToUpdateIndex]);
case CV_ISSUES_MATCHES_IN_LIBRARY_FETCHED:
const updatedState = [...state.issuesForVolume];
const matches = action.matches.filter(
(match) => !isEmpty(match.hits.hits),
);
matches.forEach((match) => {
state.issuesForVolume.forEach((issue, idx) => {
issue.matches = [];
match.hits.hits.forEach((hit) => {
if (
parseInt(issue.issue_number, 10) ===
hit._source.inferredMetadata.issue.number
) {
issue.matches.push(hit);
}
});
});
});
return {
...state,