Commit 281ae5a0 by jaymehta

.

1 parent 98208f30
...@@ -12,6 +12,8 @@ const format = "HH:mm"; ...@@ -12,6 +12,8 @@ const format = "HH:mm";
const suitableAgeGroups = [2, 5, 8, 10, 12, 14, 16]; const suitableAgeGroups = [2, 5, 8, 10, 12, 14, 16];
const ListingFilter = () => { const ListingFilter = () => {
const [showContent, setShowContent] = useState(false); const [showContent, setShowContent] = useState(false);
const [sliderLowerValue, setsliderLowerValue] = useState(0);
const [sliderUpperValue, setsliderUpperValue] = useState(5000);
const dispatch = useDispatch(); const dispatch = useDispatch();
const { activityFilters } = useSelector(sate => sate.activityFilters); const { activityFilters } = useSelector(sate => sate.activityFilters);
const { subCategories, loading } = useSelector(sate => sate.subCategories); const { subCategories, loading } = useSelector(sate => sate.subCategories);
...@@ -31,7 +33,9 @@ const ListingFilter = () => { ...@@ -31,7 +33,9 @@ const ListingFilter = () => {
<a <a
onClick={e => { onClick={e => {
e.preventDefault(); e.preventDefault();
dispatch(setActivityFilters({ filters: {} })); dispatch(setActivityFilters({ filters: { priceLowerLimit: 0, priceUpperLimit: 5000 } }));
setsliderLowerValue(0);
setsliderUpperValue(5000);
}} }}
> >
Reset Reset
...@@ -48,7 +52,8 @@ const ListingFilter = () => { ...@@ -48,7 +52,8 @@ const ListingFilter = () => {
</div> </div>
<div className="inner"> <div className="inner">
<div className="price"> <div className="price">
$0 - 1000 <span className="sub-text"></span> ${activityFilters.priceLowerLimit ? activityFilters.priceLowerLimit : 0} - ${activityFilters.priceUpperLimit ? activityFilters.priceUpperLimit : 5000}{" "}
<span className="sub-text"></span>
</div> </div>
<div className="graph"> <div className="graph">
<Slider <Slider
...@@ -57,22 +62,30 @@ const ListingFilter = () => { ...@@ -57,22 +62,30 @@ const ListingFilter = () => {
}} }}
step={10} step={10}
onChange={e => { onChange={e => {
// console.log(e); setsliderLowerValue(e[0]);
setsliderUpperValue(e[1]);
}}
onChangeComplete={e => {
console.log(e);
dispatch(setActivityFilters({ filters: { ...activityFilters, priceLowerLimit: e[0], priceUpperLimit: e[1] } })); dispatch(setActivityFilters({ filters: { ...activityFilters, priceLowerLimit: e[0], priceUpperLimit: e[1] } }));
// setTimeout(() => { // setTimeout(() => {
// }, 1000); // }, 1000);
}} }}
defaultValue={[0, 1000]} defaultValue={[
activityFilters.priceLowerLimit ? activityFilters.priceLowerLimit : 0,
activityFilters.priceUpperLimit ? activityFilters.priceUpperLimit : 5000
]}
value={[sliderLowerValue, sliderUpperValue]}
// min={0} // min={0}
max={1000} max={5000}
tooltip={{ tooltip={{
open: true open: true
}} }}
/> />
<div className="graph-price"> {/* <div className="graph-price">
<div className="min">$0</div> <div className="min"> ${activityFilters.priceLowerLimit ? activityFilters.priceLowerLimit : 0}</div>
<div className="min">$1000</div> <div className="min">${activityFilters.priceUpperLimit ? activityFilters.priceUpperLimit : 5000}</div>
</div> </div> */}
{/* <img className="img-fluid w-100" src="/images/buget.svg" /> */} {/* <img className="img-fluid w-100" src="/images/buget.svg" /> */}
</div> </div>
</div> </div>
......
...@@ -93,6 +93,9 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => { ...@@ -93,6 +93,9 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => {
if (activityFilters.priceUpperLimit) { if (activityFilters.priceUpperLimit) {
filters["priceUpperLimit"] = activityFilters.priceUpperLimit; filters["priceUpperLimit"] = activityFilters.priceUpperLimit;
} }
if (activityFilters.priceLowerLimit) {
filters["priceLowerLimit"] = activityFilters.priceLowerLimit;
}
console.log("router query", filters.category); console.log("router query", filters.category);
dispatch( dispatch(
getActivitiesByFilters({ getActivitiesByFilters({
...@@ -108,6 +111,7 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => { ...@@ -108,6 +111,7 @@ const ListingInner = ({ allActivitiesData, loading, totalCount }) => {
ageLowerLimit: filters.ageLowerLimit, ageLowerLimit: filters.ageLowerLimit,
sort: filters.sort, sort: filters.sort,
priceUpperLimit: filters.priceUpperLimit, priceUpperLimit: filters.priceUpperLimit,
priceLowerLimit: filters.priceLowerLimit,
currentPage: router.query.page currentPage: router.query.page
}) })
); );
......
...@@ -23,8 +23,9 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => ...@@ -23,8 +23,9 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
// }, [router]); // }, [router]);
console.log("endUser", endUser); console.log("endUser", endUser);
// console.log("router", router); // console.log("router", router);
let { page, location = "" } = router.query; const [page, setpage] = useState(1);
page = Number(page); // let { page, location = "" } = router.query;
// page = Number(page);
let queryParams; let queryParams;
...@@ -37,6 +38,7 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => ...@@ -37,6 +38,7 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
// We have done this to take care of keeping the search filters in the query params // We have done this to take care of keeping the search filters in the query params
// when we end up changing the page number. // when we end up changing the page number.
setpage(pageNumber);
if (queryParams.has("page")) { if (queryParams.has("page")) {
queryParams.set("page", pageNumber); queryParams.set("page", pageNumber);
} else { } else {
...@@ -55,7 +57,7 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => ...@@ -55,7 +57,7 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
}, []); }, []);
const calculateRating = data => { const calculateRating = data => {
let value = 0 let value = 0;
data.map(item => { data.map(item => {
// console.log("item", item); // console.log("item", item);
value = value + item.attributes.rating; value = value + item.attributes.rating;
...@@ -66,14 +68,16 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => ...@@ -66,14 +68,16 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
}; };
return ( return (
<> <>
{allActivitiesData && !allActivitiesData.data.length == 0 ? ( {
// allActivitiesData && !allActivitiesData.data.length == 0 ?
!loading ? (
<div className="listing-items"> <div className="listing-items">
{!loading ? ( {allActivitiesData && !allActivitiesData.data.length == 0 ? (
<div className="row"> <div className="row">
{allActivitiesData && {allActivitiesData &&
allActivitiesData.data.map(data => { allActivitiesData.data.map((data, i) => {
return ( return (
<div className={gridClass}> <div key={i} className={gridClass}>
<div className="item"> <div className="item">
<div className="browse-experiences-item"> <div className="browse-experiences-item">
<div className="img-wrapper"> <div className="img-wrapper">
...@@ -88,13 +92,15 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => ...@@ -88,13 +92,15 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
<div className="title">{data?.attributes?.name}</div> <div className="title">{data?.attributes?.name}</div>
</Link> </Link>
<div className="rating-wishlist"> <div className="rating-wishlist">
{data?.attributes?.reviews.data.length > 0 && <div className="rating"> {data?.attributes?.reviews.data.length > 0 && (
<div className="rating">
{/* {console.log(">>", calculateRating(data?.attributes?.reviews.data))} */} {/* {console.log(">>", calculateRating(data?.attributes?.reviews.data))} */}
{<span className="number">{calculateRating(data?.attributes?.reviews.data)}</span>} {<span className="number">{calculateRating(data?.attributes?.reviews.data)}</span>}
<span className="image-container"> <span className="image-container">
<Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" /> <Image layout="fill" alt="" className="image img-fluid" src="/images/icons/star.svg" />
</span> </span>
</div>} </div>
)}
{endUser && <WishlistComponent activityId={data.id} userId={endUser.id} />} {endUser && <WishlistComponent activityId={data.id} userId={endUser.id} />}
</div> </div>
</div> </div>
...@@ -139,27 +145,30 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => ...@@ -139,27 +145,30 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
</div> </div>
) : ( ) : (
<div className="container"> <div className="container">
<div className="py-5"> <Empty />
<div className="row"> </div>
{[1, 2, 3, 5, 5, 5, 5, 5, 5].map(() => ( // <div className="container">
<div className="col-lg-3 col-md-3 col-sm-12 my-3"> // <div className="py-5">
<div className="d-inline-flex flex-column"> // <div className="row">
<Skeleton.Button active style={{ height: 250, width: 270 }} /> // {[1, 2, 3, 5, 5, 5, 5, 5, 5].map((_, index) => (
<Skeleton.Button active style={{ marginTop: 10, width: 120 }} /> // <div key={index} className="col-lg-3 col-md-3 col-sm-12 my-3">
</div> // <div className="d-inline-flex flex-column">
</div> // <Skeleton.Button active style={{ height: 250, width: 270 }} />
))} // <Skeleton.Button active style={{ marginTop: 10, width: 120 }} />
</div> // </div>
</div> // </div>
</div> // ))}
// </div>
// </div>
// </div>
)} )}
</div> </div>
) : ( ) : (
<div className="container"> <div className="container">
<div className="py-5"> <div className="py-5">
<div className="row"> <div className="row">
{[1, 2, 3, 5, 5, 5, 5, 5, 5].map(() => ( {[1, 2, 3, 5, 5, 5, 5, 5, 5].map((_, index) => (
<div className="col-lg-3 col-md-3 col-sm-12 my-3"> <div key={index} className="col-lg-3 col-md-3 col-sm-12 my-3">
<div className="d-inline-flex flex-column"> <div className="d-inline-flex flex-column">
<Skeleton.Button active style={{ height: 250, width: 270 }} /> <Skeleton.Button active style={{ height: 250, width: 270 }} />
<Skeleton.Button active style={{ marginTop: 10, width: 120 }} /> <Skeleton.Button active style={{ marginTop: 10, width: 120 }} />
...@@ -169,29 +178,37 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) => ...@@ -169,29 +178,37 @@ const ListingItems = ({ allActivitiesData, loading, gridClass, totalCount }) =>
</div> </div>
</div> </div>
</div> </div>
)} // <div className="container">
// <Empty />
// </div>
)
}
{totalCount && (
<div className="row"> <div className="row">
<div className="col-12"> <div className="col-12">
<div className="load-more"> <div className="load-more">
{/* {console.log("totalCount", totalCount)} */}
<Pagination <Pagination
activePage={page} activePage={page}
hideNavigation={true} hideNavigation={true}
itemsCountPerPage={12} itemsCountPerPage={12}
totalItemsCount={totalCount} totalItemsCount={totalCount}
pageRangeDisplayed={5}
onChange={async e => { onChange={async e => {
console.log("log >", e); console.log("log >", e);
await handlePagination(e); await handlePagination(e);
}} }}
// nextPageText={"›"} nextPageText={"›"}
// prevPageText={"‹"} prevPageText={"‹"}
// firstPageText={"«"} firstPageText={"«"}
// lastPageText={"»"} lastPageText={"»"}
itemClass="page-item" itemClass="page-item"
linkClass="page-link" linkClass="page-link"
></Pagination> ></Pagination>
</div> </div>
</div> </div>
</div> </div>
)}
</> </>
); );
}; };
......
...@@ -498,6 +498,9 @@ export const getActivitiesByFilters = ...@@ -498,6 +498,9 @@ export const getActivitiesByFilters =
if (priceUpperLimit) { if (priceUpperLimit) {
query.filters["pricePerPerson"] = { $lte: priceUpperLimit }; query.filters["pricePerPerson"] = { $lte: priceUpperLimit };
} }
if (priceUpperLimit) {
query.filters["pricePerPerson"] = { $gte: priceLowerLimit };
}
// console.log("subcategoryquery:", query); // console.log("subcategoryquery:", query);
const queryString = qs.stringify(query, { const queryString = qs.stringify(query, {
......
...@@ -130,7 +130,7 @@ export const updateActivityByIdReducer = (state = {}, action) => { ...@@ -130,7 +130,7 @@ export const updateActivityByIdReducer = (state = {}, action) => {
} }
}; };
export const setActivityFilterReducer = (state = { activityFilters: {} }, action) => { export const setActivityFilterReducer = (state = { activityFilters: {priceLowerLimit: 0, priceUpperLimit: 5000} }, action) => {
switch (action.type) { switch (action.type) {
case ACTIVITY_FILTERS_CONSTANT: case ACTIVITY_FILTERS_CONSTANT:
return { return {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!