"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 = "جدیدترین به‌روزرسانی‌ها و بهبودهای پلتفرم ما را دنبال کنید.", 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: [ "نمودارهای تعاملی با به‌روزرسانی لحظه‌ای", "ویجت‌های قابل سفارشی‌سازی برای داشبورد", "خروجی گرفتن از تحلیل‌ها در قالب‌های جدول، پی‌دی‌اف و 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", }, ];