vega-frontend-monorepo/apps/trading/stores/global.ts
macqbat c14e57cfd5
feat(2146): adjust and refactor welcome dialogs (#2384)
* feat: adjust and refactor welcome dialogs

* feat: adjust and refactor welcome dialogs - add int tests

* feat: adjust and refactor welcome dialogs - small fixes and imprvments

* feat: adjust and refactor welcome dialogs - fix a typo

* feat: adjust and refactor welcome dialogs - fix a property name

* feat: adjust and refactor welcome dialogs - fix an unit test
2022-12-13 14:31:28 +01:00

30 lines
781 B
TypeScript

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