diff --git a/frontend/src/components/Matches/MatchesWidget.tsx b/frontend/src/components/Matches/MatchesWidget.tsx new file mode 100644 index 0000000..db7db3c --- /dev/null +++ b/frontend/src/components/Matches/MatchesWidget.tsx @@ -0,0 +1,72 @@ + +import React, { useEffect, useState } from 'react'; +import axios from 'axios'; +import CardBox from '../CardBox'; +import BaseIcon from '../BaseIcon'; +import { mdiHandshake, mdiMagnify } from '@mdi/js'; +import Link from 'next/link'; + +const MatchesWidget = () => { + const [matches, setMatches] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const fetchMatches = async () => { + try { + // Fetch matches for the user + const response = await axios.get('/matches'); + // If no real matches, show some "Potential Partners" (Agribusinesses) + if (response.data.rows && response.data.rows.length > 0) { + setMatches(response.data.rows.slice(0, 3)); + } else { + const agriResponse = await axios.get('/agribusinesses'); + setMatches(agriResponse.data.rows.slice(0, 3).map(agri => ({ + id: agri.id, + summary: `Potential match with ${agri.name}`, + status: 'potential', + agribusiness: agri + }))); + } + } catch (error) { + console.error('Error fetching matches:', error); + } finally { + setLoading(false); + } + }; + + fetchMatches(); + }, []); + + if (loading) return
{match.summary || `Partner: ${match.agribusiness?.name}`}
+{match.status || 'Active'}
+No matches found yet. Post a listing to get started!
+ )} +Listings
+{listingsCount}
+Matches
+{matchesCount}
+Messages
+{messagesCount}
+Deals
+{dealsCount}
+- {`${widgetsRole?.role?.label || 'Users'}'s widgets`} -
- )} ++ Maize prices are up 12% in your region. Consider listing your harvest now to match with high-demand traders. +
+This is a React.js/Node.js app generated by the Flatlogic Web App Generator
-For guides and documentation please check - your local README.md and the Flatlogic documentation
-© 2026 {title}. All rights reserved
- - Privacy Policy - -+ The B2B marketplace for farmers, traders, and suppliers to matchmake and grow together. +
+500+
+Verified Partners
+1.2k
+Active Listings
+$2M+
+Deals Facilitated
+Discover current needs and offers from our network
+{listing.price}
+Tell us about your agribusiness and certifications.
+Post what you are selling or what you need to buy.
+Our algorithm connects you with compatible partners.
+Securely message and finalize terms in the app.
+