feat: cockpit
This commit is contained in:
@@ -57,6 +57,17 @@ const IMPACT_DOT: Record<string, string> = {
|
||||
// and a major G7/FX market alongside US/EUR/China.
|
||||
const ECO_CURRENCY_FILTERS = ['USD', 'EUR', 'CNY', 'GBP'] as const
|
||||
|
||||
// Instrument Analysis's catalog keys FX pairs with yfinance's "=X" suffix (EURUSD=X),
|
||||
// while the Cockpit watchlist stores the plain ticker (EURUSD) — try both forms before
|
||||
// concluding an instrument isn't registered there.
|
||||
const resolveCatalogId = (ticker: string, catalogIds?: Set<string>): string | undefined => {
|
||||
if (!catalogIds) return undefined
|
||||
const upper = ticker.toUpperCase()
|
||||
if (catalogIds.has(upper)) return upper
|
||||
if (catalogIds.has(`${upper}=X`)) return `${upper}=X`
|
||||
return undefined
|
||||
}
|
||||
|
||||
const formatDateShort = (dateStr: string) => {
|
||||
const d = new Date(dateStr + 'T00:00:00Z')
|
||||
return d.toLocaleDateString('fr-FR', { weekday: 'short', day: 'numeric', month: 'short', timeZone: 'UTC' })
|
||||
@@ -418,17 +429,17 @@ export default function Dashboard() {
|
||||
)}
|
||||
<div className="mt-1.5 pt-1.5 border-t border-slate-700/30 space-y-0.5">
|
||||
{((watchlistQuotesData as any)?.items ?? []).map((it: any) => {
|
||||
const inCatalog = (instrumentCatalogIds as Set<string> | undefined)?.has(it.ticker.toUpperCase())
|
||||
const catalogId = resolveCatalogId(it.ticker, instrumentCatalogIds as Set<string> | undefined)
|
||||
return (
|
||||
<div
|
||||
key={it.ticker}
|
||||
onDoubleClick={() => { if (inCatalog) navigate(`/instruments/${encodeURIComponent(it.ticker)}`) }}
|
||||
onDoubleClick={() => { if (catalogId) navigate(`/instruments/${encodeURIComponent(catalogId)}`) }}
|
||||
className={clsx(
|
||||
'flex items-center justify-between gap-1.5 text-[10px] whitespace-nowrap rounded px-1 -mx-1 py-0.5 transition-colors',
|
||||
it.ticker === activeWatchlistTicker ? 'bg-blue-900/20' : 'hover:bg-dark-700/40',
|
||||
inCatalog && 'cursor-pointer'
|
||||
catalogId && 'cursor-pointer'
|
||||
)}
|
||||
title={inCatalog ? `Double-click to open ${it.name || it.ticker} in Instrument Analysis` : undefined}
|
||||
title={catalogId ? `Double-click to open ${it.name || it.ticker} in Instrument Analysis` : undefined}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
@@ -453,9 +464,9 @@ export default function Dashboard() {
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
{inCatalog && (
|
||||
{catalogId && (
|
||||
<Link
|
||||
to={`/instruments/${encodeURIComponent(it.ticker)}`}
|
||||
to={`/instruments/${encodeURIComponent(catalogId)}`}
|
||||
className="text-slate-600 hover:text-blue-400 shrink-0 transition-colors"
|
||||
title={`Open ${it.name || it.ticker} in Instrument Analysis`}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user