import React, { useState, useMemo, memo } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { Download, ChevronDown, ChevronUp, Phone, MapPin, Globe, Search } from 'lucide-react';
const Dashboard = memo(({ stats, groupedData, onExport }) => {
const [expandedNiche, setExpandedNiche] = useState(null);
const [searchTerm, setSearchTerm] = useState('');
const toggleNiche = (niche) => {
if (expandedNiche === niche) {
setExpandedNiche(null);
} else {
setExpandedNiche(niche);
}
};
const filteredNiches = useMemo(() => {
return Object.keys(groupedData).filter(niche =>
niche.toLowerCase().includes(searchTerm.toLowerCase())
).sort();
}, [groupedData, searchTerm]);
return (
{/* Header / Stats */}
{/* Actions */}
{/* Niches List */}
{filteredNiches.map((niche, index) => (
toggleNiche(niche)}
index={index}
/>
))}
);
});
Dashboard.displayName = 'Dashboard';
const StatCard = memo(({ title, value, delay, highlight }) => (
{title}
{value}
));
StatCard.displayName = 'StatCard';
const NicheGroup = memo(({ niche, businesses, isExpanded, onToggle, index }) => {
return (
{niche.charAt(0).toUpperCase()}
{niche}
{businesses.length} leads potenciais
{isExpanded ?
:
}
{isExpanded && (
{businesses.map((biz) => (
))}
)}
);
});
NicheGroup.displayName = 'NicheGroup';
const BusinessCard = memo(({ business }) => (
{business.title}
{business.phone && (
)}
{business.street || business.address || 'Endereço não disponível'}
{/* Debugging/Info: Show that it has no website explicitly if needed, but the list is filtered */}
Sem Website
));
BusinessCard.displayName = 'BusinessCard';
export default Dashboard;