Commit d4e8a550 by jaymehta

.

1 parent c310a5de
...@@ -21,7 +21,7 @@ const Detail = () => { ...@@ -21,7 +21,7 @@ const Detail = () => {
const { faqs } = useSelector(state => state.faqs); const { faqs } = useSelector(state => state.faqs);
useEffect(() => { useEffect(() => {
// console.log("router", activityById.data.attributes.category?.data?.attributes.name); // console.log("router", activityById.data.attributes.category?.data?.attributes.name);
dispatch(getActivitiesByFilters({ category: activityById?.data.attributes.category?.data?.id })); dispatch(getActivitiesByFilters({ category: activityById?.data.attributes.category?.data?.id, currentPage: router.query.page }));
}, [activityById]); }, [activityById]);
console.log("faqs=>", faqs); console.log("faqs=>", faqs);
......
...@@ -31,7 +31,6 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => { ...@@ -31,7 +31,6 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => {
setGridClass(className); setGridClass(className);
}; };
useEffect(() => { useEffect(() => {
const handleResize = () => { const handleResize = () => {
// console.log("Window Width:"); // console.log("Window Width:");
...@@ -108,7 +107,8 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => { ...@@ -108,7 +107,8 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => {
maxGroupSize: filters.maxGroupSize, maxGroupSize: filters.maxGroupSize,
ageLowerLimit: filters.ageLowerLimit, ageLowerLimit: filters.ageLowerLimit,
sort: filters.sort, sort: filters.sort,
priceUpperLimit: filters.priceUpperLimit priceUpperLimit: filters.priceUpperLimit,
currentPage: router.query.page
}) })
); );
}, [activityFilters]); }, [activityFilters]);
......
...@@ -38,6 +38,7 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => ...@@ -38,6 +38,7 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
search: queryParams.toString() search: queryParams.toString()
}); });
}; };
console.log("page", page);
return ( return (
<> <>
{allActivitiesData && !allActivitiesData.data.length == 0 ? ( {allActivitiesData && !allActivitiesData.data.length == 0 ? (
......
import { useRouter } from "next/router";
import { useEffect } from "react";
import { useDispatch } from "react-redux";
import Layout from "../components/layout/Layout"; import Layout from "../components/layout/Layout";
import Listing from "../components/listing/Listing"; import Listing from "../components/listing/Listing";
import { getActivitiesByFilters } from "../redux/actions/activityAction"; import { getActivitiesByFilters } from "../redux/actions/activityAction";
...@@ -6,13 +9,11 @@ import { wrapper } from "../redux/store"; ...@@ -6,13 +9,11 @@ import { wrapper } from "../redux/store";
export default function ListingPage() { export default function ListingPage() {
/** Client side rendering, traditional API call. */ /** Client side rendering, traditional API call. */
// const dispatch = useDispatch(); const router = useRouter();
// useEffect(() => { const dispatch = useDispatch();
// const fetchData = async () => { useEffect(() => {
// await dispatch(getProjects({ currentPage: 1, featuredOnHome: true })); dispatch(getActivitiesByFilters({ currentPage: router.query.page }));
// }; }, [router]);
// fetchData();
// });
return ( return (
<Layout> <Layout>
......
...@@ -391,11 +391,12 @@ export const getActivitiesByFilters = ...@@ -391,11 +391,12 @@ export const getActivitiesByFilters =
sort, sort,
priceLowerLimit, priceLowerLimit,
priceUpperLimit, priceUpperLimit,
currentPage = 1 currentPage
}) => }) =>
async dispatch => { async dispatch => {
let sortFilter = []; let sortFilter = [];
try { try {
console.log("page num", currentPage);
dispatch({ dispatch({
type: GET_ACTIVITIES_REQUEST, type: GET_ACTIVITIES_REQUEST,
loading: true loading: true
...@@ -413,8 +414,8 @@ export const getActivitiesByFilters = ...@@ -413,8 +414,8 @@ export const getActivitiesByFilters =
} }
let query = { let query = {
pagination: { pagination: {
pageSize: 12, pageSize: 12
page: currentPage // page: Number(currentPage)
}, },
filters: { filters: {
approved: { $eq: "approved" } approved: { $eq: "approved" }
...@@ -438,6 +439,10 @@ export const getActivitiesByFilters = ...@@ -438,6 +439,10 @@ export const getActivitiesByFilters =
] ]
// sort: ["pricePerPerson:asc"] // sort: ["pricePerPerson:asc"]
}; };
if (currentPage) {
query.pagination["page"] = Number(currentPage);
}
console.log("page query", query);
if (category) { if (category) {
query.filters["category"] = category; query.filters["category"] = category;
} }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!