'use client'; import { useState, useEffect, useCallback } from 'react'; import { useAuthStore } from '@/stores/auth-store'; import { useAccountStore } from '@/stores/account-store'; import { getPendingOperationsCount, onPendingCountChange, processQueue, } from '@/lib/offline-write-queue'; export function OfflineQueueIndicator() { const [count, setCount] = useState(0); const [processing, setProcessing] = useState(false); const client = useAuthStore((s) => s.client); const activeAccountId = useAccountStore((s) => s.activeAccountId); useEffect(() => { setCount(getPendingOperationsCount()); return onPendingCountChange(setCount); }, []); const handleRetry = useCallback(async () => { if (!client || !activeAccountId) return; setProcessing(true); try { await processQueue(client, activeAccountId); } finally { setProcessing(false); } }, [client, activeAccountId]); if (count === 0) return null; return (