Files
trumpsignal-frontend/store/dashboard.ts
T
k 040e1df685 feat: revamp dashboard, trades, and add landing/legal pages
- Major UI updates across dashboard, analytics, posts, trades, settings
- New landing page, robots/sitemap, contact/privacy/terms pages
- Updated globals.css with extensive styling and new landing.css
- Refactor signedRequest, realtime data hook, and dashboard store

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-25 16:04:57 +08:00

49 lines
2.0 KiB
TypeScript

import { create } from 'zustand'
interface DashboardState {
selectedPostId: number | null
asset: 'BTC' | 'ETH'
timeframe: '5m' | '15m' | '1H' | '4H' | '1D' | '1W'
walletAddress: string | null
isSubscribed: boolean
botReadiness: 'unknown' | 'saved' | 'verified' | 'ready'
hlApiKeySet: boolean // true if user already has a key saved in backend
hlApiKeyMasked: string | null // e.g. "...a1b2c3" shown after successful save
livePrices: { BTC: number | null; ETH: number | null }
setSelectedPost: (id: number | null) => void
setAsset: (asset: 'BTC' | 'ETH') => void
setTimeframe: (tf: '5m' | '15m' | '1H' | '4H' | '1D' | '1W') => void
setWallet: (address: string | null) => void
setSubscribed: (subscribed: boolean) => void
setBotReadiness: (state: DashboardState['botReadiness']) => void
setHlApiKeySet: (set: boolean, masked?: string) => void
setLivePrice: (asset: 'BTC' | 'ETH', price: number) => void
}
export const useDashboardStore = create<DashboardState>((set) => ({
selectedPostId: null,
asset: 'BTC',
timeframe: '4H',
walletAddress: null,
isSubscribed: false,
botReadiness: 'unknown',
hlApiKeySet: false,
hlApiKeyMasked: null,
livePrices: { BTC: null, ETH: null },
setSelectedPost: (id) => set({ selectedPostId: id }),
setAsset: (asset) => set({ asset }),
setTimeframe: (timeframe) => set({ timeframe }),
setWallet: (walletAddress) => set({ walletAddress }),
setSubscribed: (isSubscribed) => set({ isSubscribed }),
setBotReadiness: (botReadiness) => set({ botReadiness }),
setHlApiKeySet: (keySet, masked) =>
set((s) => ({
hlApiKeySet: keySet,
// Preserve existing mask when called without one (e.g. the /public poll
// only returns a boolean). Only explicitly clear when keySet=false.
hlApiKeyMasked: !keySet ? null : (masked !== undefined ? masked : s.hlApiKeyMasked),
})),
setLivePrice: (asset, price) =>
set((s) => ({ livePrices: { ...s.livePrices, [asset]: price } })),
}))