import React, { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; const DatasetsSection = () => { const [datasets, setDatasets] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { // In a real app, this would fetch from an API // For demo purposes, we'll use mock data const mockDatasets = [ { id: 1, title: 'Cold Chain Infrastructure Map', description: 'Geospatial data on refrigeration facilities across Sub-Saharan Africa', category: 'Infrastructure', size: '2.4 GB', downloads: 1240 }, { id: 2, title: 'Post-Harvest Loss Hotspots', description: 'Identified areas with highest food loss rates in South Asia', category: 'Analytics', size: '890 MB', downloads: 890 }, { id: 3, title: 'Processing Capacity Database', description: 'List of food processing facilities with available capacity', category: 'Industry', size: '1.1 GB', downloads: 1560 } ]; setTimeout(() => { setDatasets(mockDatasets); setLoading(false); }, 500); }, []); if (loading) { return ( Open Datasets ); } if (error) { return ( Open Datasets Error loading datasets: {error} ); } return ( Open Datasets Browse All Datasets → {datasets.map((dataset) => ( {dataset.title} {dataset.category} {dataset.description} Size: {dataset.size} {dataset.downloads} downloads Download ))} ); }; export default DatasetsSection;
Error loading datasets: {error}
{dataset.description}