Calendar synchro

This commit is contained in:
OpenSquared
2026-06-28 12:15:25 +02:00
parent 98d6be8212
commit 79d4a9f741
6 changed files with 237 additions and 90 deletions

View File

@@ -351,6 +351,7 @@ export default function Config() {
const [newsapiKey, setNewsapiKey] = useState('')
const [eiaKey, setEiaKey] = useState('')
const [fredKey, setFredKey] = useState('')
const [calendarRefreshH, setCalendarRefreshH] = useState(6)
const [showKeys, setShowKeys] = useState(false)
const [savedMsg, setSavedMsg] = useState('')
const [configTab, setConfigTab] = useState<'ia' | 'cycle' | 'sources' | 'options' | 'profiles' | 'data'>('ia')
@@ -472,6 +473,13 @@ export default function Config() {
}
}, [optionsGateData])
useEffect(() => {
if (config?.calendar_refresh_h) {
const h = parseFloat(config.calendar_refresh_h)
if (!isNaN(h)) setCalendarRefreshH(h)
}
}, [config])
useEffect(() => {
if (techIndicatorsData) {
setTechEnabled(techIndicatorsData.tech_indicators_enabled ?? true)
@@ -1095,6 +1103,39 @@ export default function Config() {
</button>
</div>
</div>
{/* Calendar auto-sync frequency */}
<div className="card">
<h2 className="text-base font-bold text-white flex items-center gap-2 mb-3">
<RefreshCw className="w-4 h-4 text-indigo-400" /> Calendar Auto-Sync
</h2>
<div className="text-xs text-slate-400 mb-3">
Interval between automatic economic calendar syncs (FXStreet primary, Forex Factory fallback).
</div>
<div className="flex items-center gap-3">
<label className="text-xs text-slate-500 whitespace-nowrap">Refresh every</label>
<div className="flex gap-1">
{[2, 4, 6, 12, 24].map(h => (
<button key={h} onClick={() => setCalendarRefreshH(h)}
className={clsx('px-3 py-1.5 rounded text-xs transition-colors', {
'bg-indigo-700 text-white': calendarRefreshH === h,
'bg-dark-700 text-slate-400 hover:text-slate-200': calendarRefreshH !== h,
})}>
{h}h
</button>
))}
</div>
<button
onClick={() => updateApiKeys({ calendar_refresh_h: String(calendarRefreshH) }, {
onSuccess: () => { setSavedMsg('Calendar refresh saved'); setTimeout(() => setSavedMsg(''), 2000) }
})}
disabled={savingKeys}
className="flex items-center gap-1.5 bg-indigo-700 hover:bg-indigo-600 disabled:opacity-40 text-white px-3 py-1.5 rounded text-xs font-semibold">
<Save className="w-3.5 h-3.5" />
{savingKeys ? 'Saving…' : 'Save'}
</button>
</div>
</div>
</div>
)}