diff --git a/src/App.css b/src/App.css
index 7f52f71..b5349df 100644
--- a/src/App.css
+++ b/src/App.css
@@ -162,7 +162,6 @@ a{
.primary-button{
background-color: #F4CE14;
- margin: 20px;
padding: 10px 20px;
border-radius: 16px;
border: none;
diff --git a/src/Components/ImageSlider.jsx b/src/Components/ImageSlider.jsx
index 3bb6cdb..699e01a 100644
--- a/src/Components/ImageSlider.jsx
+++ b/src/Components/ImageSlider.jsx
@@ -1,20 +1,31 @@
-import React from 'react'
-import GreekSalad from '../Assets/Food images/Greek Salad.jpeg'
-import Brushetta from '../Assets/Food images/Brushetta.jpg'
-import GrillFish from '../Assets/Food images/Grill Fish.jpg'
-import ModernHummusTrio from '../Assets/Food images/Modern Hummus Trio.jpeg'
-import BabaGanoush from '../Assets/Food images/Baba Ganoush.jpg'
+import React, { useEffect, useState } from 'react'
+import { getDownloadURL, ref } from 'firebase/storage';
+import { storage } from '../config/firebase'
+import { getDoc , collection, docs , getDocs, getAggregateFromServer, getCountFromServer, average} from 'firebase/firestore'
-function ImageSlider() {
+function ImageSlider({menuItems}) {
+ // const [itemImages, setItemImages] = useState(null)
+ // useEffect( ()=>{
+ // const loadMenuItems = async () =>{
+ // setItemImages(menuItem)
+ // const images = menuItem.docs.map(doc => doc.img)
+ // const imageRef = ref(storage, menuItem.img);
+ // const imageUrl = await getDownloadURL(imageRef);
+ // }
+ // loadMenuItems();
+ // }, [])
+ console.log({menuItems})
return (
-
-
-
-
-
-
-
+
+
{menuItems.img}
+ {/* {menuImages.map((image, index) => (
+
+
{image.img}
+
+ ))}
+
+
*/}
)
}
diff --git a/src/Components/RestaurantDetails.jsx b/src/Components/RestaurantDetails.jsx
index 8048e15..63804eb 100644
--- a/src/Components/RestaurantDetails.jsx
+++ b/src/Components/RestaurantDetails.jsx
@@ -6,7 +6,8 @@ import { Rating } from '@mui/material'
import ImageSlider from '../Components/ImageSlider'
import Reviews from '../Components/Reviews'
import RestaurantMap from '../Components/RestaurantMap'
-import { getDoc , collection, doc as firestoreDoc, getDocs} from 'firebase/firestore'
+import { getDoc , collection, doc as firestoreDoc, getDocs, getAggregateFromServer, getCountFromServer, average} from 'firebase/firestore'
+import { Link } from 'react-router-dom'
import { db } from '../config/firebase'
function RestaurantDetails() {
@@ -18,12 +19,27 @@ function RestaurantDetails() {
useEffect(() => {
const fetchRestaurant = async () => {
try {
- const restaurantRef = firestoreDoc(db, 'restaurants', restaurantID);
- const restaurantDoc = await getDoc(restaurantRef);
- const reviewsRef = collection(db, 'restaurants', restaurantID, 'reviews')
- const reviewDoc = await getDoc(restaurantRef);
- const menuItemRef = collection (db, 'restaurants', restaurantID, 'menu-items')
- setThisRestaurant(restaurantDoc.data(), );
+ const restaurantRef = firestoreDoc(db, 'restaurants', restaurantID);
+ const restaurantDoc = await getDoc(restaurantRef);
+ const restaurantData = restaurantDoc.exists() ? restaurantDoc.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 reviewsCount = await getCountFromServer(reviewsRef)
+ const reviewsAverage = await getAggregateFromServer(reviewsRef, {averageRating: average("rating")})
+
+
+ setThisRestaurant({... restaurantData,
+ reviews: reviewsData,
+ menuItems: menuItemData,
+ counts: reviewsCount.data().count,
+ ratings: reviewsAverage.data().averageRating});
} catch (err) {
console.error(err);
} finally {
@@ -31,6 +47,7 @@ function RestaurantDetails() {
}
};
fetchRestaurant();
+ console.log(thisRestaurant)
}, [restaurantID]);
if (loading) {
@@ -41,21 +58,22 @@ function RestaurantDetails() {
return
Restaurant not found
;
}
+ console.log(thisRestaurant)
return (
{thisRestaurant.name}
{thisRestaurant.cuisine}
-
- 48 reviews
+
+ {thisRestaurant.counts} Reviews
Featured Dishes
-
+
-
+
-
+
)
diff --git a/src/Components/Reviews.jsx b/src/Components/Reviews.jsx
index 7709039..6e334ae 100644
--- a/src/Components/Reviews.jsx
+++ b/src/Components/Reviews.jsx
@@ -1,25 +1,23 @@
import React from 'react'
import { Rating } from '@mui/material'
-function Reviews() {
- return (
+function Reviews({reviews}) {
+return (
-
-
-
Family friendly
-
-
-
This place is amazing. Their menu is children friendly as well. Have something for poeple of all ages!
-
-
-
-
Family friendly
-
-
-
This place is amazing. Their menu is children friendly as well. Have something for poeple of all ages!
+
+ {reviews.map((review, index)=>(
+
+
+
{review.title}
+
+
+
{review.description}
+
+
+ ))}
- )
+)
}
export default Reviews
\ No newline at end of file