"use client"; import React, { useState, useEffect } from "react"; import { cls } from "@/lib/utils"; import type { LucideIcon } from "lucide-react"; import { ArrowUpRight, Bell, ChevronLeft, ChevronRight, Plus, Search, } from "lucide-react"; import AnimationContainer from "@/components/sections/AnimationContainer"; import Button from "@/components/button/Button"; import { getButtonProps } from "@/lib/buttonUtils"; import { useTheme } from "@/providers/themeProvider/ThemeProvider"; import MediaContent from "@/components/shared/MediaContent"; import BentoLineChart from "@/components/bento/BentoLineChart/BentoLineChart"; import type { ChartDataItem } from "@/components/bento/BentoLineChart/utils"; import type { ButtonConfig } from "@/types/button"; import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation"; import TextNumberCount from "@/components/text/TextNumberCount"; export interface DashboardSidebarItem { icon: LucideIcon; active?: boolean; } export interface DashboardStat { title: string; titleMobile?: string; values: [number, number, number]; valuePrefix?: string; valueSuffix?: string; valueFormat?: Omit & { notation?: Exclude; }; description: string; } export interface DashboardListItem { icon: LucideIcon; title: string; status: string; } interface DashboardProps { title: string; stats: [DashboardStat, DashboardStat, DashboardStat]; logoIcon: LucideIcon; sidebarItems: DashboardSidebarItem[]; searchPlaceholder?: string; buttons: ButtonConfig[]; chartTitle?: string; chartData?: ChartDataItem[]; listItems: DashboardListItem[]; listTitle?: string; imageSrc: string; videoSrc?: string; imageAlt?: string; videoAriaLabel?: string; className?: string; containerClassName?: string; sidebarClassName?: string; statClassName?: string; chartClassName?: string; listClassName?: string; } const Dashboard = ({ title, stats, logoIcon: LogoIcon, sidebarItems, searchPlaceholder = "Search", buttons, chartTitle = "Revenue Overview", chartData, listItems, listTitle = "Recent Transfers", imageSrc, videoSrc, imageAlt = "", videoAriaLabel = "Avatar video", className = "", containerClassName = "", sidebarClassName = "", statClassName = "", chartClassName = "", listClassName = "", }: DashboardProps) => { const theme = useTheme(); const [activeStatIndex, setActiveStatIndex] = useState(0); const [statValueIndex, setStatValueIndex] = useState(0); const { itemRefs: statRefs } = useCardAnimation({ animationType: "slide-up", itemCount: 3, }); useEffect(() => { const interval = setInterval(() => { setStatValueIndex((prev) => (prev + 1) % 3); }, 3000); return () => clearInterval(interval); }, []); const statCard = (stat: DashboardStat, index: number, withRef = false) => (
{ statRefs.current[index] = el; } : undefined} className={cls( "group rounded-theme-capped p-5 flex flex-col justify-between h-40 md:h-50 card shadow", statClassName )} >

{stat.title}

{stat.description}

); return (

{searchPlaceholder}

{title}

{buttons.slice(0, 2).map((button, index) => (
{stats.map((stat, index) => statCard(stat, index, true))}
{statCard(stats[activeStatIndex], activeStatIndex)}

{chartTitle}

{listTitle}

{[...listItems, ...listItems].map((item, index) => { const ItemIcon = item.icon; return (

{item.title}

{item.status}

); })}
); }; Dashboard.displayName = "Dashboard"; export default React.memo(Dashboard);