Skip to content

Commit

Permalink
Merge pull request #2492 from the-canonizer/ITR8-TICKET1627
Browse files Browse the repository at this point in the history
Ticket #1627
  • Loading branch information
ashish76 authored Jan 20, 2025
2 parents 3a61cb6 + e717c83 commit 0e3b596
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
44 changes: 21 additions & 23 deletions src/components/common/AdvanceSearchFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {
import { getCanonizedTopicsApi } from "src/network/api/homePageApi";
import moment from "moment";
import K from "../../../constants";
import { setSearchLoadingAction } from "src/store/slices/loading";

export default function AdvanceFilter() {
const [searchVal, setSearchVal] = useState("");
Expand Down Expand Up @@ -569,29 +570,26 @@ export default function AdvanceFilter() {
}, [filteredAsOfDate]);

useEffect(() => {
if (
(router?.pathname == "/search/topic" && asof == "review") ||
asof == "bydate" ||
filterByScore != 0 ||
algorithm !== "blind_popularity"
) {
getTopicsApiCallWithReqBody();
} else if (
(router?.pathname == "/search/camp" && asof == "review") ||
asof == "bydate" ||
filterByScore != 0 ||
algorithm !== "blind_popularity"
) {
getCampsApiCallWithReqBody();
} else if (
(router?.pathname == "/search/camp_statement" && asof == "review") ||
asof == "bydate" ||
filterByScore != 0 ||
algorithm !== "blind_popularity"
) {
getStatementApiCallWithReqBody();
}

const fetchData = async () => {
const isReviewOrByDate = asof === "review" || asof === "bydate";
const isFilterApplied = filterByScore !== 0 || algorithm !== "blind_popularity";

if (router?.pathname === "/search/topic" && (isReviewOrByDate || isFilterApplied)) {
dispatch(setSearchLoadingAction(true));
await getTopicsApiCallWithReqBody();
dispatch(setSearchLoadingAction(false));
} else if (router?.pathname === "/search/camp" && (isReviewOrByDate || isFilterApplied)) {
dispatch(setSearchLoadingAction(true));
await getCampsApiCallWithReqBody();
dispatch(setSearchLoadingAction(false));
} else if (router?.pathname === "/search/camp_statement" && (isReviewOrByDate || isFilterApplied)) {
dispatch(setSearchLoadingAction(true));
await getStatementApiCallWithReqBody();
dispatch(setSearchLoadingAction(false));
}
};

fetchData();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [asof, filterByScore, algorithm, asofdate, pageNumber]);

Expand Down
6 changes: 3 additions & 3 deletions src/components/common/SearchSideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function SearchSideBar() {
const isReviewOrByDate =
router.query.asof === "review" || router.query.asof === "bydate";

const isCampPage = router?.pathname?.includes("/camp");
const isCampPage = router?.pathname == "/search/camp";

const campTotal =
searchValue === ""
Expand Down Expand Up @@ -145,7 +145,7 @@ export default function SearchSideBar() {
? searchMetaData?.topic_total
: (router.query.asof == "review" ||
router.query.asof == "bydate") &&
router?.pathname?.includes("/topic")
router?.pathname == "/search/topic"
? selectedTopicFromAdvanceFilterAlgorithmRecords
: searchCountForMetaData?.topic_total}
)
Expand Down Expand Up @@ -231,7 +231,7 @@ export default function SearchSideBar() {
? searchMetaData?.statement_total
: (router.query.asof == "review" ||
router.query.asof == "bydate") &&
router?.pathname?.includes("/camp_statement")
router?.pathname == "/search/camp_statement"
? selectedCampStatementFromAdvanceFilterAlgorithmRecords
: searchCountForMetaData?.statement_total}
)
Expand Down

0 comments on commit 0e3b596

Please sign in to comment.