vega-frontend-monorepo/apps/trading/stores/global.ts
m.ray c221d0772c
fix: 1569 trading tab navigation update (#1573)
* fix: #1569 trading tab navigation update

* fix: #1569 get market id value from init
2022-09-30 16:50:48 +01:00

28 lines
732 B
TypeScript

import { LocalStorage } from '@vegaprotocol/react-helpers';
import create from 'zustand';
interface GlobalStore {
connectDialog: boolean;
networkSwitcherDialog: boolean;
landingDialog: boolean;
riskNoticeDialog: boolean;
marketId: string | null;
pageTitle: string | null;
update: (store: Partial<Omit<GlobalStore, 'update'>>) => void;
}
export const useGlobalStore = create<GlobalStore>((set) => ({
connectDialog: false,
networkSwitcherDialog: false,
landingDialog: false,
riskNoticeDialog: false,
marketId: LocalStorage.getItem('marketId') || null,
pageTitle: null,
update: (state) => {
set(state);
if (state.marketId) {
LocalStorage.setItem('marketId', state.marketId);
}
},
}));