feat: calendar eco

This commit is contained in:
OpenSquared
2026-07-21 14:08:56 +02:00
parent 0bdf3f382d
commit 59fbb9b023
5 changed files with 53 additions and 20 deletions

View File

@@ -218,6 +218,11 @@ function ImportPanel({ stats, onImported }: { stats: FFStats; onImported: () =>
const nw = nwStatus === 'ok' ? r.live.nextweek.events : (r.live?.nextweek?.error ? `err` : (nwStatus ?? '?'))
const sc = r.scrape?.total_upserted ?? 0
let msg = `✓ FF: ${tw}+${nw} live, ${sc} upcoming`
if (r.te_fallback) {
if (r.te_fallback.skipped === 'no_key') msg += ' · TE fallback skipped (no key)'
else if (r.te_fallback.error) msg += ` · TE error: ${r.te_fallback.error}`
else msg += ` · TE +${r.te_fallback.total_upserted ?? 0}`
}
if (r.fmp_fallback) {
if (r.fmp_fallback.skipped === 'no_key') msg += ' · FMP fallback skipped (no key)'
else if (r.fmp_fallback.error) msg += ` · FMP error: ${r.fmp_fallback.error}`
@@ -259,7 +264,10 @@ function ImportPanel({ stats, onImported }: { stats: FFStats; onImported: () =>
const hasData = stats.total > 0
const res = importStatus.last_result
const srcLabel = calStatus.source === 'ff' ? 'ForexFactory' : calStatus.source === 'ff+fmp' ? 'ForexFactory+FMP' : calStatus.source ?? null
const srcLabel = calStatus.source === 'ff' ? 'ForexFactory'
: calStatus.source === 'ff+te' ? 'ForexFactory+TradingEconomics'
: calStatus.source === 'ff+fmp' ? 'ForexFactory+FMP'
: calStatus.source ?? null
return (
<div className="bg-slate-800 border border-slate-700 rounded-lg p-4 mb-4 flex flex-wrap items-center gap-4 text-sm">

View File

@@ -799,6 +799,7 @@ export default function Config() {
const [eiaKey, setEiaKey] = useState('')
const [fredKey, setFredKey] = useState('')
const [fmpKey, setFmpKey] = useState('')
const [teKey, setTeKey] = useState('')
const [calendarRefreshH, setCalendarRefreshH] = useState(6)
const [showKeys, setShowKeys] = useState(false)
const [savedMsg, setSavedMsg] = useState('')
@@ -962,11 +963,12 @@ export default function Config() {
if (eiaKey) keys.eia_api_key = eiaKey
if (fredKey) keys.fred_api_key = fredKey
if (fmpKey) keys.fmp_api_key = fmpKey
if (teKey) keys.te_api_key = teKey
updateApiKeys(keys, {
onSuccess: () => {
setSavedMsg('API keys saved')
setTimeout(() => setSavedMsg(''), 2000)
setOpenaiKey(''); setNewsapiKey(''); setEiaKey(''); setFredKey(''); setFmpKey('')
setOpenaiKey(''); setNewsapiKey(''); setEiaKey(''); setFredKey(''); setFmpKey(''); setTeKey('')
}
})
}
@@ -1644,7 +1646,8 @@ export default function Config() {
{ label: 'NewsAPI Key', value: newsapiKey, setter: setNewsapiKey, placeholder: 'Get at newsapi.org', configKey: 'newsapi_key' },
{ label: 'EIA API Key', value: eiaKey, setter: setEiaKey, placeholder: 'Get at eia.gov', configKey: 'eia_api_key' },
{ label: 'FRED API Key', value: fredKey, setter: setFredKey, placeholder: 'Get at fred.stlouisfed.org', configKey: 'fred_api_key' },
{ label: 'FMP API Key', value: fmpKey, setter: setFmpKey, placeholder: 'Calendar fallback — financialmodelingprep.com', configKey: 'fmp_api_key' },
{ label: 'Trading Economics Key', value: teKey, setter: setTeKey, placeholder: 'Calendar fallback (free) — tradingeconomics.com/api/login', configKey: 'te_api_key' },
{ label: 'FMP API Key', value: fmpKey, setter: setFmpKey, placeholder: 'Calendar fallback (paid tier) — financialmodelingprep.com', configKey: 'fmp_api_key' },
].map(({ label, value, setter, placeholder, configKey }) => (
<div key={label}>
<label className="text-xs text-slate-500 mb-1 flex items-center justify-between">
@@ -1667,7 +1670,7 @@ export default function Config() {
</div>
<button
onClick={saveKeys}
disabled={savingKeys || (!newsapiKey && !eiaKey && !fredKey && !fmpKey)}
disabled={savingKeys || (!newsapiKey && !eiaKey && !fredKey && !fmpKey && !teKey)}
className="mt-3 flex items-center gap-1.5 bg-blue-600 hover:bg-blue-500 disabled:opacity-40 text-white px-4 py-2 rounded text-sm font-semibold">
<Save className="w-4 h-4" />
{savingKeys ? 'Saving...' : 'Save keys'}