Skip to content

Commit

Permalink
feat: Redirect to particular restaurant onclick of search results
Browse files Browse the repository at this point in the history
  • Loading branch information
sanidhiya-khandelwal committed Dec 23, 2023
1 parent 1d24ff6 commit 48838ae
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cityFood.js
Original file line number Diff line number Diff line change
Expand Up @@ -6412,6 +6412,18 @@ function displayRestaurantOnSearch(item, idx) {
searchRestaurantContainerImgDetails.appendChild(searchRestaurantContainerDetails);

searchDishContainer.appendChild(searchRestaurantContainerImgDetails);

//detail of restraunt
searchRestaurantContainerImgDetails.addEventListener('click', () => {
localStorage.setItem('selectedRestauraunt', JSON.stringify(item))

setTimeout(() => {
let restaurantName = item.restaurantName;
let restaurantNameReplace = restaurantName.replace(' ', "-").toLowerCase();
window.location.href = `restrauntDetail.html?city=${encodeURIComponent(cityValue)}&restaurant=${encodeURIComponent(restaurantNameReplace)}`;
}, 100);
}
)
}


Expand Down Expand Up @@ -6454,6 +6466,7 @@ searchInputSM.addEventListener('input', function () {
// Freeze the body
body.style.overflow = 'hidden';
displayRestaurantOnSearchSM(item, idx);

});

if (searchInputSM.value.length === 0) {
Expand Down Expand Up @@ -6526,4 +6539,17 @@ function displayRestaurantOnSearchSM(item, idx) {
searchRestaurantContainerImgDetailsSM.appendChild(searchRestaurantContainerDetailsSM);

searchDishContainerSM.appendChild(searchRestaurantContainerImgDetailsSM);


//detail of restraunt
searchRestaurantContainerImgDetailsSM.addEventListener('click', () => {
localStorage.setItem('selectedRestauraunt', JSON.stringify(item))

setTimeout(() => {
let restaurantName = item.restaurantName;
let restaurantNameReplace = restaurantName.replace(' ', "-").toLowerCase();
window.location.href = `restrauntDetail.html?city=${encodeURIComponent(cityValue)}&restaurant=${encodeURIComponent(restaurantNameReplace)}`;
}, 100);
}
)
}

0 comments on commit 48838ae

Please sign in to comment.