refactor(store): port to useGlobalState with zustand (#1012)

This commit is contained in:
Himself65
2023-02-14 23:38:21 -06:00
committed by GitHub
parent 2b3ec1240a
commit 6a8aff9e56
29 changed files with 304 additions and 207 deletions
+3 -1
View File
@@ -1,11 +1,13 @@
import { useAppState } from '@/providers/app-state-provider';
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import { useGlobalState } from '@/store/app';
// It is a fully effective hook
// Cause it not just ensure workspace loaded, but also have router change.
export const useEnsureWorkspace = () => {
const [workspaceLoaded, setWorkspaceLoaded] = useState(false);
const { dataCenter, loadWorkspace } = useAppState();
const dataCenter = useGlobalState(store => store.dataCenter);
const { loadWorkspace } = useAppState();
const router = useRouter();
const [activeWorkspaceId, setActiveWorkspaceId] = useState(
router.query.workspaceId as string