import { useState, useEffect, createContext, useContext } from 'react'; import { Calendar, ShoppingCart, User, Menu, MapPin, Clock, Phone, Mail, ChevronDown, X, Plus, Minus, Search, Filter, Star, Heart, LogIn, LogOut } from 'lucide-react'; // Context for cart functionality const CartContext = createContext(); const useCart = () => useContext(CartContext); const CartProvider = ({ children }) => { const [cart, setCart] = useState([]); const [isCartOpen, setIsCartOpen] = useState(false); const addToCart = (item, quantity = 1, customizations = {}) => { const existingItemIndex = cart.findIndex( (cartItem) => cartItem.id === item.id && JSON.stringify(cartItem.customizations) === JSON.stringify(customizations) ); if (existingItemIndex > -1) { const newCart = [...cart]; newCart[existingItemIndex].quantity += quantity; setCart(newCart); } else { setCart([...cart, { ...item, quantity, customizations }]); } }; const removeFromCart = (index) => { const newCart = [...cart]; newCart.splice(index, 1); setCart(newCart); }; const updateQuantity = (index, quantity) => { const newCart = [...cart]; newCart[index].quantity = quantity; setCart(newCart); }; const clearCart = () => { setCart([]); }; const getCartTotal = () => { return cart.reduce((total, item) => { return total + (item.price * item.quantity); }, 0); }; const getCartCount = () => { return cart.reduce((count, item) => count + item.quantity, 0); }; return ( {children} ); }; // Context for authentication const AuthContext = createContext(); const useAuth = () => useContext(AuthContext); const AuthProvider = ({ children }) => { const [user, setUser] = useState(null); const [isLoginModalOpen, setIsLoginModalOpen] = useState(false); const login = async (email, password) => { try { // In a real app, this would be an API call // const response = await fetch('https://www.sitebrew.ai/api/YG1m1I/auth/login', { // method: 'POST', // headers: { 'Content-Type': 'application/json' }, // body: JSON.stringify({ document: { email, password } }) // }); // const data = await response.json(); // Simulating successful login setUser({ id: '123', name: 'John Doe', email: email, role: 'customer' }); return true; } catch (error) { console.error('Login failed:', error); return false; } }; const register = async (name, email, password) => { try { // In a real app, this would be an API call // const response = await fetch('https://www.sitebrew.ai/api/YG1m1I/auth/register', { // method: 'POST', // headers: { 'Content-Type': 'application/json' }, // body: JSON.stringify({ document: { name, email, password } }) // }); // const data = await response.json(); // Simulating successful registration setUser({ id: '123', name: name, email: email, role: 'customer' }); return true; } catch (error) { console.error('Registration failed:', error); return false; } }; const logout = () => { setUser(null); }; return ( {children} ); }; // Main App Component const App = () => { return (
); }; // Navbar Component const Navbar = () => { const { getCartCount, setIsCartOpen } = useCart(); const { user, setIsLoginModalOpen, logout } = useAuth(); const [isMenuOpen, setIsMenuOpen] = useState(false); const [isScrolled, setIsScrolled] = useState(false); useEffect(() => { const handleScroll = () => { setIsScrolled(window.scrollY > 50); }; window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); return (
Savoria {/* Desktop Navigation */}
{user ? (
My Account Order History
) : ( )} {/* Mobile menu button */}
{/* Mobile Navigation */} {isMenuOpen && (
Home Menu Reservations Contact
)}
); }; // Hero Section Component const HeroSection = () => { return (
Restaurant ambiance

Savoria Restaurant

Experience culinary excellence with our exquisite dishes crafted from the finest ingredients.

View Menu Book a Table
); }; // Featured Section Component const FeaturedSection = () => { const featuredItems = [ { id: 1, name: "Truffle Risotto", description: "Creamy Arborio rice with wild mushrooms and truffle oil", price: 24.99, image: "https://images.unsplash.com/photo-1673421161165-25bd82d6c48d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80" }, { id: 2, name: "Seared Scallops", description: "Pan-seared scallops with citrus beurre blanc and microgreens", price: 28.99, image: "https://images.unsplash.com/photo-1532980193606-ca8f71d1d359?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80" }, { id: 3, name: "Braised Short Ribs", description: "Slow-cooked beef short ribs with red wine reduction and root vegetables", price: 32.99, image: "https://images.unsplash.com/photo-1544025162-d76694265947?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80" } ]; const { addToCart } = useCart(); return (

Chef's Specials

Indulge in our most celebrated dishes, crafted with passion and precision by our award-winning chef.

{featuredItems.map((item) => (
{item.name}

{item.name}

{item.description}

${item.price.toFixed(2)}
))}
); }; // Menu Section Component const MenuSection = () => { const [activeCategory, setActiveCategory] = useState('all'); const [searchQuery, setSearchQuery] = useState(''); const [dietaryFilters, setDietaryFilters] = useState({ vegetarian: false, vegan: false, glutenFree: false }); const [selectedItem, setSelectedItem] = useState(null); const menuCategories = [ { id: 'all', name: 'All' }, { id: 'starters', name: 'Starters' }, { id: 'mains', name: 'Main Course' }, { id: 'desserts', name: 'Desserts' }, { id: 'drinks', name: 'Drinks' } ]; const menuItems = [ { id: 101, name: "Bruschetta", description: "Toasted bread topped with tomatoes, garlic, and fresh basil", price: 9.99, category: "starters", image: "https://images.unsplash.com/photo-1572695157366-5e585ab2b69f?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80", dietary: { vegetarian: true, vegan: true, glutenFree: false } }, { id: 102, name: "Calamari", description: "Crispy fried squid rings with lemon aioli", price: 12.99, category: "starters", image: "https://images.unsplash.com/photo-1599487488170-d11ec9c172f0?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80", dietary: { vegetarian: false, vegan: false, glutenFree: false } }, { id: 201, name: "Filet Mignon", description: "8oz beef tenderloin with red wine reduction and truffle mashed potatoes", price: 36.99, category: "mains", image: "https://images.unsplash.com/photo-1558030006-450675393462?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80", dietary: { vegetarian: false, vegan: false, glutenFree: true } }, { id: 202, name: "Mushroom Risotto", description: "Creamy Arborio rice with wild mushrooms, white wine, and parmesan", price: 22.99, category: "mains", image: "https://images.unsplash.com/photo-1476124369491-e7addf5db371?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80", dietary: { vegetarian: true, vegan: false, glutenFree: true } }, { id: 203, name: "Grilled Salmon", description: "Atlantic salmon with lemon butter sauce and seasonal vegetables", price: 28.99, category: "mains", image: "https://images.unsplash.com/photo-1519708227418-c8fd9a32b7a2?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80", dietary: { vegetarian: false, vegan: false, glutenFree: true } }, { id: 301, name: "Chocolate Lava Cake", description: "Warm chocolate cake with a molten center, served with vanilla ice cream", price: 10.99, category: "desserts", image: "https://images.unsplash.com/photo-1617305855058-336d24456869?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80", dietary: { vegetarian: true, vegan: false, glutenFree: false } }, { id: 401, name: "Signature Cocktail", description: "House-made infusion with premium spirits and fresh ingredients", price: 14.99, category: "drinks", image: "https://images.unsplash.com/photo-1514362545857-3bc16c4c7d1b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1974&q=80", dietary: { vegetarian: true, vegan: true, glutenFree: true } } ]; const { addToCart } = useCart(); const filteredItems = menuItems.filter(item => { // Category filter if (activeCategory !== 'all' && item.category !== activeCategory) return false; // Search filter if (searchQuery && !item.name.toLowerCase().includes(searchQuery.toLowerCase()) && !item.description.toLowerCase().includes(searchQuery.toLowerCase())) return false; // Dietary filters if (dietaryFilters.vegetarian && !item.dietary.vegetarian) return false; if (dietaryFilters.vegan && !item.dietary.vegan) return false; if (dietaryFilters.glutenFree && !item.dietary.glutenFree) return false; return true; }); const handleDietaryFilterChange = (filter) => { setDietaryFilters({ ...dietaryFilters, [filter]: !dietaryFilters[filter] }); }; const openItemModal = (item) => { setSelectedItem({ ...item, quantity: 1, customizations: { notes: '', options: {} } }); }; const closeItemModal = () => { setSelectedItem(null); }; const handleAddToCart = () => { if (selectedItem) { addToCart( { id: selectedItem.id, name: selectedItem.name, price: selectedItem.price, image: selectedItem.image }, selectedItem.quantity, selectedItem.customizations ); closeItemModal(); } }; return ( ); }; // Reservation Section Component const ReservationSection = () => { const [formData, setFormData] = useState({ name: '', email: '', phone: '', date: '', time: '', guests: 2, occasion: '', specialRequests: '' }); const [isSubmitting, setIsSubmitting] = useState(false); const [isSuccess, setIsSuccess] = useState(false); const [error, setError] = useState(''); const handleChange = (e) => { const { name, value } = e.target; setFormData({ ...formData, [name]: value }); }; const handleSubmit = async (e) => { e.preventDefault(); setIsSubmitting(true); setError(''); try { // In a real app, this would be an API call // const response = await fetch('https://www.sitebrew.ai/api/YG1m1I/reservations', { // method: 'POST', // headers: { 'Content-Type': 'application/json' }, // body: JSON.stringify({ document: formData }) // }); // Simulate API call await new Promise(resolve => setTimeout(resolve, 1000)); setIsSuccess(true); setFormData({ name: '', email: '', phone: '', date: '', time: '', guests: 2, occasion: '', specialRequests: '' }); // Reset success message after 5 seconds setTimeout(() => { setIsSuccess(false); }, 5000); } catch (err) { setError('Failed to submit reservation. Please try again.'); } finally { setIsSubmitting(false); } }; // Generate available time slots const timeSlots = []; for (let hour = 17; hour <= 21; hour++) { for (let minute = 0; minute < 60; minute += 30) { const formattedHour = hour % 12 || 12; const period = hour >= 12 ? 'PM' : 'AM'; const formattedMinute = minute.toString().padStart(2, '0'); timeSlots.push(`${formattedHour}:${formattedMinute} ${period}`); } } return (

Reserve a Table

Secure your dining experience with us. For parties larger than 8, please call us directly.

{isSuccess ? (

Reservation submitted successfully! We'll send a confirmation to your email shortly.

) : (
{error && (

{error}

)}
)}

Reservation Information

Hours of Operation

Monday - Thursday: 5:00 PM - 10:00 PM

Friday - Saturday: 5:00 PM - 11:00 PM

Sunday: 5:00 PM - 9:00 PM

Location

123 Culinary Avenue

Gourmet City, GC 12345

Contact

(123) 456-7890

reservations@savoria.com

* For same-day reservations, please call us directly.

* A credit card is required for parties of 6 or more.

); }; // Testimonials Section Component const TestimonialsSection = () => { const testimonials = [ { id: 1, name: "Emily Johnson", rating: 5, comment: "The truffle risotto was absolutely divine! The ambiance was perfect for our anniversary dinner. We'll definitely be coming back soon.", date: "October 15, 2023" }, { id: 2, name: "Michael Chen", rating: 5, comment: "Exceptional service and the seafood platter was the freshest I've had in the city. The wine pairing recommendation was spot on!", date: "September 28, 2023" }, { id: 3, name: "Sophia Rodriguez", rating: 4, comment: "Beautiful restaurant with an elegant atmosphere. The filet mignon was cooked to perfection. Only giving 4 stars because the dessert menu could use more options.", date: "November 5, 2023" } ]; return (

What Our Guests Say

Read about the experiences of our valued guests and discover why they keep coming back.

{testimonials.map((testimonial) => (
{[...Array(5)].map((_, i) => ( ))}
{testimonial.date}

"{testimonial.comment}"

- {testimonial.name}

))}
Read more reviews
); }; // Contact Section Component const ContactSection = () => { const [formData, setFormData] = useState({ name: '', email: '', subject: '', message: '' }); const [isSubmitting, setIsSubmitting] = useState(false); const [isSuccess, setIsSuccess] = useState(false); const handleChange = (e) => { const { name, value } = e.target; setFormData({ ...formData, [name]: value }); }; const handleSubmit = async (e) => { e.preventDefault(); setIsSubmitting(true); try { // In a real app, this would be an API call // const response = await fetch('https://www.sitebrew.ai/api/YG1m1I/contact', { // method: 'POST', // headers: { 'Content-Type': 'application/json' }, // body: JSON.stringify({ document: formData }) // }); // Simulate API call await new Promise(resolve => setTimeout(resolve, 1000)); setIsSuccess(true); setFormData({ name: '', email: '', subject: '', message: '' }); // Reset success message after 5 seconds setTimeout(() => { setIsSuccess(false); }, 5000); } catch (err) { console.error('Failed to submit form:', err); } finally { setIsSubmitting(false); } }; return (

Contact Us

Have questions or feedback? We'd love to hear from you. Fill out the form below or reach out directly.

{isSuccess ? (

Thank you for your message! We'll get back to you as soon as possible.

) : (
)}

Get in Touch

Visit Us

123 Culinary Avenue

Gourmet City, GC 12345

Call Us

(123) 456-7890

Mon-Fri: 10am - 6pm

Email Us

info@savoria.com

reservations@savoria.com

Follow Us

); }; // Footer Component const Footer = () => { return ( ); }; // Cart Sidebar Component const CartSidebar = () => { const { cart, isCartOpen, setIsCartOpen, removeFromCart, updateQuantity, getCartTotal, clearCart } = useCart(); const [isCheckingOut, setIsCheckingOut] = useState(false); const [checkoutSuccess, setCheckoutSuccess] = useState(false); const handleCheckout = async () => { if (cart.length === 0) return; setIsCheckingOut(true); try { // In a real app, this would be an API call // const response = await fetch('https://www.sitebrew.ai/api/YG1m1I/orders', { // method: 'POST', // headers: { 'Content-Type': 'application/json' }, // body: JSON.stringify({ document: { items: cart, total: getCartTotal() } }) // }); // Simulate API call await new Promise(resolve => setTimeout(resolve, 1500)); setCheckoutSuccess(true); clearCart(); // Reset success message and close cart after 3 seconds setTimeout(() => { setCheckoutSuccess(false); setIsCartOpen(false); }, 3000); } catch (err) { console.error('Checkout failed:', err); } finally { setIsCheckingOut(false); } }; return (

Your Cart

{checkoutSuccess ? (

Order Placed Successfully!

Thank you for your order. You will receive a confirmation email shortly.

) : cart.length === 0 ? (

Your cart is empty

) : (
{cart.map((item, index) => (
{item.name}

{item.name}

${item.price.toFixed(2)}

{item.customizations.notes && (

"{item.customizations.notes}"

)}
{item.quantity}
${(item.price * item.quantity).toFixed(2)}
))}
)}
{cart.length > 0 && !checkoutSuccess && (
Subtotal: ${getCartTotal().toFixed(2)}
)}
); }; // Login Modal Component const LoginModal = () => { const { isLoginModalOpen, setIsLoginModalOpen, login, register } = useAuth(); const [isRegisterMode, setIsRegisterMode] = useState(false); const [formData, setFormData] = useState({ name: '', email: '', password: '', confirmPassword: '' }); const [error, setError] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const handleChange = (e) => { const { name, value } = e.target; setFormData({ ...formData, [name]: value }); }; const handleSubmit = async (e) => { e.preventDefault(); setError(''); if (isRegisterMode) { if (formData.password !== formData.confirmPassword) { setError('Passwords do not match'); return; } } setIsSubmitting(true); try { let success; if (isRegisterMode) { success = await register(formData.name, formData.email, formData.password); } else { success = await login(formData.email, formData.password); } if (success) { setIsLoginModalOpen(false); setFormData({ name: '', email: '', password: '', confirmPassword: '' }); } else { setError(isRegisterMode ? 'Registration failed' : 'Invalid email or password'); } } catch (err) { setError('An error occurred. Please try again.'); } finally { setIsSubmitting(false); } }; if (!isLoginModalOpen) return null; return (

{isRegisterMode ? 'Create Account' : 'Login'}

{error && (

{error}

)}
{isRegisterMode && (
)}
{isRegisterMode && (
)}
); }; export default App;