mirror of
https://github.com/aykhans/slash-e.git
synced 2025-12-14 20:59:19 +00:00
feat: implement subscription setting
This commit is contained in:
29
frontend/web/src/stores/v1/workspace.ts
Normal file
29
frontend/web/src/stores/v1/workspace.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { create } from "zustand";
|
||||
import { workspaceServiceClient } from "@/grpcweb";
|
||||
import { WorkspaceProfile, WorkspaceSetting } from "@/types/proto/api/v2/workspace_service";
|
||||
|
||||
interface WorkspaceState {
|
||||
profile: WorkspaceProfile;
|
||||
setting: WorkspaceSetting;
|
||||
|
||||
// Workspace related actions.
|
||||
fetchWorkspaceProfile: () => Promise<WorkspaceProfile>;
|
||||
fetchWorkspaceSetting: () => Promise<WorkspaceSetting>;
|
||||
}
|
||||
|
||||
const useWorkspaceStore = create<WorkspaceState>()((set) => ({
|
||||
profile: WorkspaceProfile.fromPartial({}),
|
||||
setting: WorkspaceSetting.fromPartial({}),
|
||||
fetchWorkspaceProfile: async () => {
|
||||
const workspaceProfile = (await workspaceServiceClient.getWorkspaceProfile({})).profile as WorkspaceProfile;
|
||||
set({ profile: workspaceProfile });
|
||||
return workspaceProfile;
|
||||
},
|
||||
fetchWorkspaceSetting: async () => {
|
||||
const workspaceSetting = (await workspaceServiceClient.getWorkspaceSetting({})).setting as WorkspaceSetting;
|
||||
set({ setting: workspaceSetting });
|
||||
return workspaceSetting;
|
||||
},
|
||||
}));
|
||||
|
||||
export default useWorkspaceStore;
|
||||
Reference in New Issue
Block a user