diff --git a/frontend/src/pages/CalendarPage.tsx b/frontend/src/pages/CalendarPage.tsx index a12c5e4..c7b5991 100644 --- a/frontend/src/pages/CalendarPage.tsx +++ b/frontend/src/pages/CalendarPage.tsx @@ -1,6 +1,6 @@ import { useState, useEffect, useCallback, useRef, KeyboardEvent, useId } from 'react' import clsx from 'clsx' -import { RefreshCw, ChevronDown, AlertTriangle, Check, Key, Upload } from 'lucide-react' +import { RefreshCw, ChevronDown, AlertTriangle, Check, Upload } from 'lucide-react' const API = '' @@ -38,7 +38,6 @@ interface ImportStatus { last_result: { inserted?: number; skipped?: number; total?: number; error?: string } | null } -interface TEKeyStatus { configured: boolean; preview: string } // ── Constants ───────────────────────────────────────────────────────────────── @@ -366,123 +365,6 @@ function ImpactFilter({ selected, onChange }: { selected: string[]; onChange: (v ) } -// ── FMP Panel — upcoming forecasts (free API) ───────────────────────────────── - -function FMPPanel({ onSynced }: { onSynced: () => void }) { - const [keyStatus, setKeyStatus] = useState(null) - const [keyInput, setKeyInput] = useState('') - const [saving, setSaving] = useState(false) - const [syncMsg, setSyncMsg] = useState(null) - const [syncing, setSyncing] = useState(false) - const pollRef = useRef | null>(null) - - useEffect(() => { - fetch(`${API}/api/eco/fmp-key`).then(r => r.json()).then(setKeyStatus).catch(() => {}) - return () => { if (pollRef.current) clearInterval(pollRef.current) } - }, []) - - const saveKey = async () => { - if (!keyInput.trim()) return - setSaving(true) - try { - const r = await fetch(`${API}/api/eco/fmp-key?key=${encodeURIComponent(keyInput.trim())}`, { method: 'POST' }).then(x => x.json()) - setKeyStatus({ configured: true, preview: r.preview }) - setKeyInput('') - } finally { setSaving(false) } - } - - const startSync = async () => { - setSyncing(true) - setSyncMsg('syncing…') - try { - await fetch(`${API}/api/eco/fmp-sync?weeks=6`, { method: 'POST' }) - pollRef.current = setInterval(async () => { - const s = await fetch(`${API}/api/eco/fmp-sync/status`).then(x => x.json()) - if (!s.running) { - clearInterval(pollRef.current!) - setSyncing(false) - const r = s.last_result || {} - if (r.error) { setSyncMsg(`Error: ${r.error}`); return } - setSyncMsg(`✓ ${r.total_upserted} events (${r.date_from} → ${r.date_to})`) - onSynced() - } - }, 2000) - } catch { setSyncing(false); setSyncMsg('sync error') } - } - - const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Enter') saveKey() } - - const configured = keyStatus?.configured - - return ( -
-
-
- - FMP Calendar - upcoming forecasts — free API (250 req/day) -
- - {configured ? ( - - key: {keyStatus?.preview} - - ) : ( -
- setKeyInput(e.target.value)} - onKeyDown={handleKeyDown} - placeholder="Paste FMP API key…" - className="bg-slate-700 border border-slate-600 rounded px-2 py-1 text-xs text-white w-52 focus:outline-none focus:border-indigo-500" - /> - - - Free key ↗ (financialmodelingprep.com) - -
- )} - - {configured && ( - - )} - - {configured && ( - - )} - - {syncMsg && ( - - {syncMsg} - - )} -
-
- ) -} // ── Main Page ───────────────────────────────────────────────────────────────── @@ -581,8 +463,6 @@ export default function CalendarPage() { {/* Import Panel */} { fetchStats(); fetchEvents() }} /> - {/* FMP Panel — upcoming forecasts */} - { fetchStats(); fetchEvents() }} /> {/* Period Tabs */}