import React, { useEffect, useState } from 'react'; import { FaCheckCircle, FaClock, FaHourglassHalf, FaTasks, FaChevronDown, FaPlus, FaUserPlus, FaFilter, FaCalendarAlt } from 'react-icons/fa'; // Define a type for card data interface CardData { title: string; count: number; icon: JSX.Element; gradient: string; shadowColor: string; iconBg: string; textColor: string; percentage?: number; trend?: 'up' | 'down' | 'stable'; } // interface CardData { // title: string; // count: number; // icon: React.ReactNode; // gradient: string; // shadowColor: string; // iconBg: string; // textColor: string; // trend: 'up' | 'down'; // } interface CardsProps { type?: 'dashboard' | 'account' | 'transactions'; onOpenModal?: () => void; dashboardData: any; fromDate: string; toDate: string; onDateRangeChange: (range: { from: string; to: string }) => void; cards: CardData[]; isLoading: boolean } const AccountData: CardData[] = [ { title: 'Active Accounts', count: 12, icon: , gradient: 'bg-gradient-to-br from-blue-50 to-blue-100', shadowColor: 'shadow-blue-200/50', iconBg: 'bg-blue-100 border-blue-200', textColor: 'text-blue-700', trend: 'up' }, { title: 'In-Progress', count: 8, icon: , gradient: 'bg-gradient-to-br from-purple-50 to-purple-100', shadowColor: 'shadow-purple-200/50', iconBg: 'bg-purple-100 border-purple-200', textColor: 'text-purple-700', trend: 'stable' }, { title: 'Completed', count: 27, icon: , gradient: 'bg-gradient-to-br from-green-50 to-green-100', shadowColor: 'shadow-green-200/50', iconBg: 'bg-green-100 border-green-200', textColor: 'text-green-700', trend: 'up' }, { title: 'Inactive', count: 5, icon: , gradient: 'bg-gradient-to-br from-gray-50 to-gray-100', shadowColor: 'shadow-gray-200/50', iconBg: 'bg-gray-100 border-gray-200', textColor: 'text-gray-700', trend: 'down' }, ]; const filters = ['Last 7 Days', 'Last 30 Days', 'Last 6 Months', 'This Year']; const accounts = ['All Accounts', 'Account 1', 'Account 2', 'Account 3']; const Cards: React.FC = ({ type = 'dashboard', onOpenModal, onDateRangeChange, cards, isLoading }) => { const [selectedFilter, setSelectedFilter] = useState('Last 7 Days'); const [selectedAccount, setSelectedAccount] = useState('All Accounts'); const [showCards, setShowCards] = useState([]); // const [isLoading, setIsLoading] = useState(true); // useEffect(() => { // setIsLoading(true); // setTimeout(() => { // if (type === 'account') { // setShowCards(AccountData); // } else { // setShowCards(cards); // } // setIsLoading(false); // }, 500); // }, [type]); useEffect(() => { if (type === 'dashboard') { const now = new Date(); let fromDate = new Date(); switch (selectedFilter) { case 'Last 7 Days': fromDate.setDate(now.getDate() - 7); break; case 'Last 30 Days': fromDate.setDate(now.getDate() - 30); break; case 'Last 6 Months': fromDate.setMonth(now.getMonth() - 6); break; case 'This Year': fromDate = new Date(now.getFullYear(), 0, 1); break; default: fromDate.setDate(now.getDate() - 7); } const from = fromDate.toISOString().split('T')[0]; const to = now.toISOString().split('T')[0]; onDateRangeChange({ from, to }); } }, [selectedFilter]); const getButtonConfig = () => { switch (type) { case 'account': return { text: 'Add Account', icon: , gradient: 'bg-gradient-to-r from-blue-600 to-blue-700 hover:from-blue-700 hover:to-blue-800' }; case 'transactions': return { text: 'Send Invite', icon: , gradient: 'bg-gradient-to-r from-emerald-600 to-emerald-700 hover:from-emerald-700 hover:to-emerald-800' }; default: return null; } }; const buttonConfig = getButtonConfig(); const renderTrendIndicator = (trend: string | undefined, percentage: number | undefined) => { if (!trend || !percentage) return null; const trendColors = { up: 'text-emerald-500', down: 'text-red-500', stable: 'text-gray-500' }; const trendSymbols = { up: '↗', down: '↘', stable: '→' }; return ( {trendSymbols[trend as keyof typeof trendSymbols]} {/* {percentage}% */} ); }; // if (isLoading) { // return ( // // // // // {[...Array(7)].map((_, i) => ( // // ))} // // // // ); // } return ( {/* Header */} {/* */} {/* Overview */} {/* Monitor performance metrics */} {/* Cards */} {isLoading ? {[...Array(7)].map((_, i) => ( ))} : {cards.map((card, index) => ( {/* Background Pattern */} {/* Content */} {card.icon} {card.title} {card.count} {/* Hover Effect */} ))} } ); }; export default Cards; {/* {type === 'dashboard' && <> Account Selector setSelectedAccount(e.target.value)} className="appearance-none text-sm text-gray-700 border border-gray-300 rounded-xl px-4 py-3 pr-10 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white shadow-sm hover:shadow-md transition-all cursor-pointer min-w-[140px]" > {accounts.map((account) => ( {account} ))} Date Filter setSelectedFilter(e.target.value)} className="appearance-none text-sm text-gray-700 border border-gray-300 rounded-xl px-4 py-3 pr-10 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent bg-white shadow-sm hover:shadow-md transition-all cursor-pointer min-w-[140px]" > {filters.map((filter) => ( {filter} ))} >} Action Button {buttonConfig && ( {buttonConfig.icon} {buttonConfig.text} )} */}
Monitor performance metrics
{card.count}