diff --git a/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/[vendorId]/page.tsx b/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/[vendorId]/page.tsx new file mode 100644 index 0000000..43d00dd --- /dev/null +++ b/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/[vendorId]/page.tsx @@ -0,0 +1,120 @@ +'use client'; +import React, { useState, useEffect } from 'react'; +import { Card, CardContent } from '@/components/ui/card'; +import { Utensils } from 'lucide-react'; +import { Dish, Vendor } from '@prisma/client'; +import { Spinner } from '@/components/ui/spinner'; +import { useParams } from 'next/navigation'; +import Link from 'next/link'; +import Container from '@/components/ui/container'; + +interface Customer { + id: string; + name: string; + email: string; + vendorIds: string[]; +} + +interface VendorWithDish extends Vendor { + dishes: Dish[]; +} + +const DishesByVendor = () => { + const [customer, setCustomer] = useState(null); + const [vendor, setVendor] = useState(null); + const [searchQuery, setSearchQuery] = useState(''); + const [isMounted, setIsMounted] = useState(false); + + const params = useParams<{ userId: string; vendorId: string }>(); + const { userId, vendorId } = params; + + useEffect(() => { + const fetchData = async () => { + if (!vendorId) return; + + try { + const customerData = await fetch('/data/customers.json').then(res => res.json()); + setCustomer(customerData[0]); + + const response = await fetch('/data/vendors.json'); + const vendorData: VendorWithDish[] = await response.json(); + + const filteredVendor = vendorData.find(v => v.id === vendorId); + setVendor(filteredVendor || null); + } catch (error) { + console.error('Error fetching vendor data:', error); + } finally { + setIsMounted(true); + } + }; + + fetchData(); + }, [vendorId]); + + if (!vendor || !isMounted) { + return ; + } + + const filteredDishes = vendor.dishes.filter(dish => + dish.name.toLowerCase().includes(searchQuery.toLowerCase()) + ); + + return ( +
+ +
+
+

Alimento Chat

+

Discuss your queries directly with the owners!

+
+
+ {customer && ( + <> +
+
+ Select a dish by {vendor.name} to chat about +
+
+ {/* Search Bar */} +
+ setSearchQuery(e.target.value)} + /> +
+ +
+ {filteredDishes.length ? ( + filteredDishes.map(dish => ( + + + +
+
+ +
+
+
{dish.name}
+
+
+
+
+ + )) + ) : ( +

No dishes found

+ )} +
+ + )} +
+
+
+
+ ); +}; + +export default DishesByVendor; diff --git a/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/components/listSellers.tsx b/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/components/listSellers.tsx index 1a6db5d..69c39ef 100644 --- a/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/components/listSellers.tsx +++ b/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/components/listSellers.tsx @@ -77,7 +77,7 @@ const ListVendors = () => {
{filteredVendors.length > 0 ? ( filteredVendors.map(Vendor => ( - +