Commit a7d7624a by Ravindra Kanojiya
2 parents 2e2316ed acd5d738
......@@ -24,7 +24,7 @@ const Detail = () => {
dispatch(getActivitiesByFilters({ category: activityById?.data.attributes.category?.data?.id }));
}, [activityById]);
console.log("faqs=>", faqs);
// console.log("faqs=>", faqs);
console.log("activityById", activityById);
console.log("loadedUser", loadedUser);
return (
......
......@@ -13,7 +13,7 @@ const SearchBar = () => {
const [options, setoptions] = useState([]);
const dispatch = useDispatch();
const router = useRouter();
console.log("options", options);
// console.log("options", options);
return (
<>
<section className="searchbar-session">
......@@ -67,7 +67,7 @@ const SearchBar = () => {
return { id: item.id, label: `${item.name} - experience` };
});
}
console.log("opts", opts);
// console.log("opts", opts);
setoptions(opts);
setopen(true);
}
......
......@@ -17,7 +17,7 @@ const Header = () => {
const { endUser } = useSelector(state => state.endUser);
const [open, setopen] = useState(false);
const [options, setoptions] = useState([]);
console.log("options", options);
// console.log("options", options);
const dispatch = useDispatch();
// console.log("user", loadedUser);
const [isSticky, setIsSticky] = useState(false);
......@@ -124,7 +124,7 @@ const Header = () => {
return { id: item.id, label: `${item.name} - experience` };
});
}
console.log("opts", opts);
// console.log("opts", opts);
setoptions(opts);
setopen(true);
}
......
......@@ -31,7 +31,6 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => {
setGridClass(className);
};
useEffect(() => {
const handleResize = () => {
// console.log("Window Width:");
......@@ -94,7 +93,7 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => {
if (activityFilters.priceUpperLimit) {
filters["priceUpperLimit"] = activityFilters.priceUpperLimit;
}
// console.log("subcategory >>", filters);
console.log("router >>", router.query.page);
dispatch(
getActivitiesByFilters({
subCategory: filters.subCategory,
......@@ -108,10 +107,18 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => {
maxGroupSize: filters.maxGroupSize,
ageLowerLimit: filters.ageLowerLimit,
sort: filters.sort,
priceUpperLimit: filters.priceUpperLimit
priceUpperLimit: filters.priceUpperLimit,
currentPage: router.query.page
})
);
}, [activityFilters]);
useEffect(() => {
dispatch(
getActivitiesByFilters({
currentPage: router.query.page
})
);
}, []);
return (
<>
......
import { Empty } from "antd";
import Image from "next/image";
import { useRouter } from "next/router";
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { Button } from "react-bootstrap";
import { Loader } from "react-bootstrap-typeahead";
import { useSelector } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { cleanImage } from "../../services/imageHandling";
import WishlistComponent from "../detail/WIshlistComponent";
import Pagination from "react-js-pagination";
import { getActivitiesByFilters } from "../../redux/actions/activityAction";
const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => {
// const [gridClass, setGridClass] = useState('col-md-3');
const { endUser } = useSelector(state => state.endUser);
console.log("endUser", endUser);
const router = useRouter();
const dispatch = useDispatch();
// useEffect(() => {
// dispatch(getActivitiesByFilters({ currentPage: router.query.page }));
// }, [router]);
console.log("endUser", endUser);
// console.log("router", router);
let { page = 1, location = "" } = router.query;
let { page, location = "" } = router.query;
page = Number(page);
let queryParams;
......@@ -34,10 +39,17 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
} else {
queryParams.append("page", pageNumber);
}
router.replace({
search: queryParams.toString()
// dispatch(getActivitiesByFilters({ currentPage: pageNumber }));
router.push({
query: queryParams.toString()
});
};
console.log("page", page);
// useEffect(() => {
// dispatch(getActivitiesByFilters({ currentPage: page }));
// }, [])
return (
<>
{allActivitiesData && !allActivitiesData.data.length == 0 ? (
......@@ -110,7 +122,10 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
activePage={page}
itemsCountPerPage={12}
totalItemsCount={totalCount}
onChange={handlePagination}
onChange={async (e) => {
console.log("log >",e);
await handlePagination(e);
}}
nextPageText={"›"}
prevPageText={"‹"}
firstPageText={"«"}
......
import { useRouter } from "next/router";
import { useEffect } from "react";
import { useDispatch } from "react-redux";
import Layout from "../components/layout/Layout";
import Listing from "../components/listing/Listing";
import { getActivitiesByFilters } from "../redux/actions/activityAction";
......@@ -6,13 +9,11 @@ import { wrapper } from "../redux/store";
export default function ListingPage() {
/** Client side rendering, traditional API call. */
// const dispatch = useDispatch();
const router = useRouter();
const dispatch = useDispatch();
// useEffect(() => {
// const fetchData = async () => {
// await dispatch(getProjects({ currentPage: 1, featuredOnHome: true }));
// };
// fetchData();
// });
// dispatch(getActivitiesByFilters({ currentPage: router.query.page }));
// }, []);
return (
<Layout>
......
......@@ -391,11 +391,12 @@ export const getActivitiesByFilters =
sort,
priceLowerLimit,
priceUpperLimit,
currentPage = 1
currentPage
}) =>
async dispatch => {
let sortFilter = [];
try {
console.log("page num", currentPage);
dispatch({
type: GET_ACTIVITIES_REQUEST,
loading: true
......@@ -413,8 +414,8 @@ export const getActivitiesByFilters =
}
let query = {
pagination: {
pageSize: 12,
page: currentPage
pageSize: 12
// page: Number(currentPage)
},
filters: {
approved: { $eq: "approved" }
......@@ -438,6 +439,12 @@ export const getActivitiesByFilters =
]
// sort: ["pricePerPerson:asc"]
};
if (currentPage) {
query.pagination["page"] = Number(currentPage);
} else {
query.pagination["page"] = 1;
}
console.log("page query", query);
if (category) {
query.filters["category"] = category;
}
......
......@@ -209,7 +209,8 @@ export const getAllVendors = () => async dispatch => {
// }
// }
// },
populate: ["user", "experiences"]
populate: ["user", "experiences"],
sort: ["createdAt:desc"]
};
// console.log("here 3", query);
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!