Skip to content

Commit

Permalink
temporarily disabled components to handle scraped data
Browse files Browse the repository at this point in the history
  • Loading branch information
mulundapm committed Aug 21, 2024
1 parent 8f87a0b commit 90aecc8
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions src/Components/RestaurantDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,27 @@ function RestaurantDetails() {
const restaurantRef = firestoreDoc(db, 'restaurants', restaurantID);
const restaurantDoc = await getDoc(restaurantRef);
const restaurantData = restaurantDoc.exists() ? restaurantDoc.data() : {};
const environmentImage = await getDownloadURL(ref(storage, restaurantData.interior))
// const environmentImage = await getDownloadURL(ref(storage, restaurantData.interior))

const reviewsRef = collection(db, 'restaurants', restaurantID, 'reviews');
const reviewSnap = await getDocs(reviewsRef);
const reviewsData = reviewSnap.docs.map(doc => doc.data());
// const reviewsRef = collection(db, 'restaurants', restaurantID, 'reviews');
// const reviewSnap = await getDocs(reviewsRef);
// const reviewsData = reviewSnap.docs.map(doc => doc.data());

const menuItemRef = collection(db, 'restaurants', restaurantID, 'menu-items')
const menuItemSnap = await getDocs(menuItemRef)
const menuItemData = menuItemSnap.docs.map(doc => doc.data())
// const menuItemRef = collection(db, 'restaurants', restaurantID, 'menu-items')
// const menuItemSnap = await getDocs(menuItemRef)
// const menuItemData = menuItemSnap.docs.map(doc => doc.data())

const reviewsCount = await getCountFromServer(reviewsRef)
const reviewsAverage = await getAggregateFromServer(reviewsRef, {averageRating: average("rating")})
// const reviewsCount = await getCountFromServer(reviewsRef)
// const reviewsAverage = await getAggregateFromServer(reviewsRef, {averageRating: average("rating")})


setThisRestaurant({...restaurantData,
interiorUrl: environmentImage,
reviews: reviewsData,
menuItems: menuItemData,
counts: reviewsCount.data().count,
ratings: reviewsAverage.data().averageRating});
setThisRestaurant({...restaurantData
// interiorUrl: environmentImage,
// reviews: reviewsData,
// menuItems: menuItemData,
// counts: reviewsCount.data().count,
// ratings: reviewsAverage.data().averageRating
});
} catch (err) {
console.error(err);
} finally {
Expand All @@ -66,21 +67,21 @@ function RestaurantDetails() {

return (
<div>
<img src={thisRestaurant.interiorUrl} alt="Restaurant" className='restaurant-image center'/>
<img src={thisRestaurant.interior} alt="Restaurant" className='restaurant-image center'/>
<h2>{thisRestaurant.name}</h2>
<p>{thisRestaurant.address}</p>
<h4>{thisRestaurant.cuisine}</h4>
<div className="inline">
{/* <div className="inline">
<Rating name="disabled" value={thisRestaurant.ratings}/>
<h6>{thisRestaurant.counts} Reviews</h6>
</div>
</div> */}
<h2>Featured Dishes</h2>
<ImageSlider menuItems={thisRestaurant.menuItems}/>
{/* <ImageSlider menuItems={thisRestaurant.menuItems}/> */}
<div className="container center">
<Link to={thisRestaurant.website}><button className='primary-button'>Reserve a table</button></Link>
</div>
<Reviews reviews={thisRestaurant.reviews}/>
<RestaurantMap address={thisRestaurant.address}/>
{/* <Reviews reviews={thisRestaurant.reviews}/> */}
{/* <RestaurantMap address={thisRestaurant.address}/> */}
</div>
)
}
Expand Down

0 comments on commit 90aecc8

Please sign in to comment.