diff --git a/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/components/listSellers.tsx b/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/components/listSellers.tsx new file mode 100644 index 0000000..1a6db5d --- /dev/null +++ b/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/components/listSellers.tsx @@ -0,0 +1,106 @@ +'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 Link from 'next/link'; +import { useSession } from 'next-auth/react'; +import { useRouter } from 'next/router'; + +interface Customer { + id: string; + name: string; + email: string; + vendors: string[]; +} + +interface VendorWithDish extends Vendor { + dishes: Dish[]; +} + +const ListVendors = () => { + const [customer, setCustomer] = useState(null); + const [Vendors, setVendors] = useState([]); + const [selectedVendorId, setSelectedVendorId] = useState(null); + const [searchQuery, setSearchQuery] = useState(''); + const [isMounted, setIsMounted] = useState(false); + + const session = useSession(); + const userId= session.data?.user.id + + useEffect(() => { + const fetchData = async () => { + const customerData = await fetch('/data/customers.json').then(res => + res.json() + ); + setCustomer(customerData[0]); + + const VendorData = await fetch('/data/vendors.json').then(res => + res.json() + ); + console.log(VendorData) + setVendors(VendorData); + }; + fetchData(); + setIsMounted(true); + }, [session.status]); + + // Filter Vendors based on search query + const filteredVendors = Vendors.filter(Vendor => + Vendor.name.toLowerCase().includes(searchQuery.toLowerCase()) + ); + + if (!isMounted || !Vendors.length || !userId) { + return ; + } + + + return ( +
+ {customer && ( + <> +
+
Chat With Vendors
+
+ {/* Search Bar */} +
+ setSearchQuery(e.target.value)} + /> +
+ +
+ {filteredVendors.length > 0 ? ( + filteredVendors.map(Vendor => ( + + + +
+
+ +
+
+
{Vendor.name}
+

{Vendor.dishes.length} Dishs

+
+
+
+
+ + )) + ) : ( +

No Vendors found

+ )} +
+ + )} +
+ ); +}; + +export default ListVendors; diff --git a/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/page.tsx b/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/page.tsx new file mode 100644 index 0000000..e667e7b --- /dev/null +++ b/alimento-nextjs/app/(PublicRoutes)/customer/[customerId]/dashboard/page.tsx @@ -0,0 +1,23 @@ +import Container from '@/components/ui/container'; +import ListSellers from './components/listSellers'; + +const CustomerDashboard = () => { + return ( +
+ +
+
+

+ User Dashboard +

+

Ready to explore Alimento?

+
+ + +
+
+
+ ); +}; + +export default CustomerDashboard; diff --git a/alimento-nextjs/public/data/vendors.json b/alimento-nextjs/public/data/vendors.json index afb65a8..7bf7dfb 100644 --- a/alimento-nextjs/public/data/vendors.json +++ b/alimento-nextjs/public/data/vendors.json @@ -1,13 +1,120 @@ [ - { - "id": "101", - "name": "Spicy Villa", - "orders": ["1001", "1002"] - }, - { - "id": "102", - "name": "Sweet Treats", - "orders": ["1003"] - } - ] - \ No newline at end of file + { + "id": "f42a9a12-3c63-4f75-9b8e-d92896b4c5d1", + "name": "Alice's Bakery", + "email": "alice@example.com", + "otp": "123456", + "role": "vendor", + "dishes": [ + { + "id": "a1", + "name": "Chocolate Cake", + "description": "Delicious chocolate cake", + "price": 15.0, + "category": "FOODING", + "tags": ["VEGETARIAN"], + "images": [ + { "url": "https://example.com/images/chocolate-cake.jpg" } + ], + "vendorId": "f42a9a12-3c63-4f75-9b8e-d92896b4c5d1", + "createdAt": "2024-11-09T10:00:00.000Z", + "updatedAt": "2024-11-09T10:00:00.000Z" + } + ], + "chats": [], + "createdAt": "2024-11-08T10:00:00.000Z", + "updatedAt": "2024-11-08T10:00:00.000Z" + }, + { + "id": "b93f1b23-4d5e-4d29-b9c9-fd3e7a9132d4", + "name": "Bob's Burgers", + "email": "bob@example.com", + "otp": "654321", + "role": "vendor", + "dishes": [ + { + "id": "b1", + "name": "Classic Burger", + "description": "Juicy burger with lettuce, tomato, and cheese", + "price": 10.0, + "category": "FOODING", + "tags": ["SPICY"], + "images": [ + { "url": "https://example.com/images/classic-burger.jpg" } + ], + "vendorId": "b93f1b23-4d5e-4d29-b9c9-fd3e7a9132d4", + "createdAt": "2024-11-09T10:00:00.000Z", + "updatedAt": "2024-11-09T10:00:00.000Z" + }, + { + "id": "c1", + "name": "Margherita Pizza", + "description": "Classic Margherita with fresh tomatoes and basil", + "price": 12.0, + "category": "FOODING", + "tags": ["VEGETARIAN"], + "images": [ + { "url": "https://example.com/images/margherita-pizza.jpg" } + ], + "vendorId": "b93f1b23-4d5e-4d29-b9c9-fd3e7a9132d4", + "createdAt": "2024-11-09T10:00:00.000Z", + "updatedAt": "2024-11-09T10:00:00.000Z" + } + ], + "chats": [], + "createdAt": "2024-11-08T10:00:00.000Z", + "updatedAt": "2024-11-08T10:00:00.000Z" + }, + { + "id": "c84g1h56-5e78-6i31-a4f5-ld2k6l8m8z9n", + "name": "Charlie's Pizza", + "email": "charlie@example.com", + "otp": "789456", + "role": "vendor", + "dishes": [ + { + "id": "c1", + "name": "Margherita Pizza", + "description": "Classic Margherita with fresh tomatoes and basil", + "price": 12.0, + "category": "FOODING", + "tags": ["VEGETARIAN"], + "images": [ + { "url": "https://example.com/images/margherita-pizza.jpg" } + ], + "vendorId": "c84g1h56-5e78-6i31-a4f5-ld2k6l8m8z9n", + "createdAt": "2024-11-09T10:00:00.000Z", + "updatedAt": "2024-11-09T10:00:00.000Z" + } + ], + "chats": [], + "createdAt": "2024-11-08T10:00:00.000Z", + "updatedAt": "2024-11-08T10:00:00.000Z" + }, + { + "id": "d74g9i22-8k53-5r31-c4j9-xd4p5k2m3z1p", + "name": "Debbie's Desserts", + "email": "debbie@example.com", + "otp": "234567", + "role": "vendor", + "dishes": [ + { + "id": "d1", + "name": "Strawberry Cheesecake", + "description": "Creamy cheesecake with fresh strawberries", + "price": 18.0, + "category": "FOODING", + "tags": ["VEGETARIAN"], + "images": [ + { "url": "https://example.com/images/strawberry-cheesecake.jpg" } + ], + "vendorId": "d74g9i22-8k53-5r31-c4j9-xd4p5k2m3z1p", + "createdAt": "2024-11-09T10:00:00.000Z", + "updatedAt": "2024-11-09T10:00:00.000Z" + } + ], + "chats": [], + "createdAt": "2024-11-08T10:00:00.000Z", + "updatedAt": "2024-11-08T10:00:00.000Z" + } +] diff --git a/alimento-nextjs/public/userdashboard.jpg b/alimento-nextjs/public/userdashboard.jpg new file mode 100644 index 0000000..6980387 Binary files /dev/null and b/alimento-nextjs/public/userdashboard.jpg differ