c14e57cfd5
* 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
30 lines
781 B
TypeScript
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 }),
|
|
}));
|