import { useCallback, useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { ArrowLeft, RefreshCw } from 'lucide-react'; import { toast } from 'sonner'; import { api } from '@/api'; import { cn } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import { MarkdownText } from '@/components/MarkdownText'; function formatDateTime(value) { if (!value) return null; const date = new Date(value); if (Number.isNaN(date.getTime())) return value; return date.toLocaleString(); } function HistoryLine({ line, index }) { const trimmed = line.trim(); if (!trimmed) return
; if (trimmed === '---') return
; if (trimmed.startsWith('# ')) { return (

); } if (trimmed.startsWith('## ')) { return (

); } if (trimmed.startsWith('### ')) { return (

); } if (trimmed.startsWith('- ')) { return (

); } return (

); } export default function ReleaseNotesPage() { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const load = useCallback(async () => { setLoading(true); setError(null); try { setData(await api.releaseHistory()); } catch (err) { setError(err.message || 'Failed to load release notes.'); toast.error(err.message || 'Failed to load release notes.'); } finally { setLoading(false); } }, []); useEffect(() => { load(); }, [load]); const history = data?.history || ''; return (

Release Notes

{data?.version ? `Current version v${data.version}` : 'Full project changelog'} {data?.updated_at ? ` ยท Updated ${formatDateTime(data.updated_at)}` : ''}

{loading ? (
) : error ? (

Unable to load release notes.

{error}

) : !history.trim() ? (

No release notes are available.

) : (
{history.split('\n').map((line, index) => ( ))}
)}
); }