"use client"; import { useEffect, useRef, useState } from "react"; import { Badge } from "@/components/ui/badge"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Separator } from "@/components/ui/separator"; import { cn } from "@/lib/utils"; export type ChangelogEntry = { version: string; date: string; title: string; description: string; items?: string[]; image?: string; }; export interface Changelog8Props { className?: string; title?: string; description?: string; entries?: ChangelogEntry[]; } const Changelog8 = ({ title = "تاریخچه نسخه‌ها", description = "به‌روزرسانی‌های پلتفرم فروش و CRM را دنبال کنید.", entries = defaultChangelogData, className, }: Changelog8Props) => { const [activeId, setActiveId] = useState(null); const sectionRefs = useRef>([]); useEffect(() => { sectionRefs.current = sectionRefs.current.slice(0, entries.length); const handleScroll = () => { const scrollPosition = window.scrollY + 100; const currentSectionIndex = sectionRefs.current.findIndex( (ref, index) => { if (!ref) return false; const nextRef = sectionRefs.current[index + 1]; const refTop = ref.offsetTop; const refBottom = nextRef ? nextRef.offsetTop : document.body.scrollHeight; return scrollPosition >= refTop && scrollPosition < refBottom; }, ); if (currentSectionIndex !== -1) { setActiveId(currentSectionIndex); } else if (scrollPosition < (sectionRefs.current[0]?.offsetTop || 0)) { setActiveId(null); } }; window.addEventListener("scroll", handleScroll); handleScroll(); return () => { window.removeEventListener("scroll", handleScroll); }; }, [entries.length]); const scrollToSection = (index: number) => { const sectionRef = sectionRefs.current[index]; if (sectionRef) { window.scrollTo({ top: sectionRef.offsetTop - 80, behavior: "smooth", }); } }; const setRef = (index: number) => (el: HTMLDivElement | null) => { sectionRefs.current[index] = el; }; return (

{title}

{description}

{title}

{description}

در این صفحه

آخرین انتشارها

{entries.map((entry, index) => (
{entry.version} {entry.date}

{entry.title}

{entry.description}

{entry.items && entry.items.length > 0 && (

شامل موارد زیر:

    {entry.items.map((item, itemIndex) => (
  • {item}
  • ))}
)} {entry.image && (
{`تصویر
)}
))}
); }; export { Changelog8 }; export const defaultChangelogData: ChangelogEntry[] = [ { version: "نسخه ۱۳.۰", date: "۲۵ آبان ۱۴۰۳", title: "داشبورد فروش پیشرفته", description: "داشبورد فروش را از نو طراحی کردیم تا وضعیت قیف و عملکرد تیم شفاف‌تر دیده شود.", items: [ "نمودار تبدیل با به‌روزرسانی نزدیک به لحظه", "ویجت‌های قابل تنظیم برای داشبورد فروش", "خروجی گزارش فروش در قالب جدول، PDF و Excel", "قالب گزارش هفته‌ای و ماهانه برای مدیران فروش", "فیلتر بهتر بر اساس مرحله قیف، مالک و منبع", ], image: "/block-media/shadcnblocks/block/placeholder-aspect-video-1.svg", }, { version: "نسخه ۱۲۵", date: "۱۶ مهر ۱۴۰۳", title: "انتشار اپلیکیشن موبایل", description: "با افتخار انتشار اپلیکیشن موبایل خود را اعلام می‌کنیم؛ اکنون در موبایل اپل و موبایل اندروید در دسترس است.", items: [ "تجربه بومی موبایل برای بهره‌وری در هر مکان", "پشتیبانی از حالت آفلاین برای کار بدون اتصال اینترنت", "اعلان‌های فوری برای به‌روزرسانی‌های مهم", "احراز هویت بیومتریک برای امنیت بیشتر", ], image: "/block-media/shadcnblocks/block/placeholder-aspect-video-1.svg", }, ];