vega-frontend-monorepo/apps/trading/stores/global.ts
Art 8e5012891c
feat: no markets (#2097)
* feat: no markets

* feat: no markets

* feat: no markets

* feat: no markets

* feat: no markets
2022-11-18 17:08:48 +00:00

36 lines
949 B
TypeScript

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