Files
auto-trade/features/layout/stores/market-indices-store.ts

40 lines
1.2 KiB
TypeScript
Raw Normal View History

2026-03-12 09:26:27 +09:00
/**
* @file features/layout/stores/market-indices-store.ts
* @description (KOSPI, KOSDAQ) Zustand
*
* @description [ ]
* - , , , fetch
* - (setIndices, setLoading, setError)
*/
import type { DomesticMarketIndexResult } from "@/lib/kis/dashboard";
import { create } from "zustand";
interface MarketIndicesState {
indices: DomesticMarketIndexResult[];
isLoading: boolean;
error: Error | null;
fetchedAt: string | null;
setIndices: (data: {
indices: DomesticMarketIndexResult[];
fetchedAt: string;
}) => void;
setLoading: (isLoading: boolean) => void;
setError: (error: Error | null) => void;
}
export const useMarketIndicesStore = create<MarketIndicesState>((set) => ({
indices: [],
isLoading: false,
error: null,
fetchedAt: null,
setIndices: (data) =>
set({
indices: data.indices,
fetchedAt: data.fetchedAt,
isLoading: false,
error: null,
}),
setLoading: (isLoading) => set({ isLoading }),
setError: (error) => set({ error, isLoading: false }),
}));