feat: add workspace security setting definition

This commit is contained in:
johnnyjoy
2024-08-17 13:11:53 +08:00
parent faa6fcf31c
commit a5bc443db9
21 changed files with 488 additions and 650 deletions

View File

@ -1,6 +1,6 @@
import { PlanType } from "@/types/proto/api/v1/subscription_service";
export const stringifyPlanType = (planType: PlanType) => {
export const stringifyPlanType = (planType: PlanType = PlanType.FREE) => {
if (planType === PlanType.FREE) {
return "Free";
} else if (planType === PlanType.PRO) {

View File

@ -24,17 +24,17 @@ const useWorkspaceStore = create<WorkspaceState>()((set, get) => ({
profile: WorkspaceProfile.fromPartial({}),
setting: WorkspaceSetting.fromPartial({}),
fetchWorkspaceProfile: async () => {
const workspaceProfile = (await workspaceServiceClient.getWorkspaceProfile({})).profile as WorkspaceProfile;
const workspaceProfile = await workspaceServiceClient.getWorkspaceProfile({});
set({ ...get(), profile: workspaceProfile });
return workspaceProfile;
},
fetchWorkspaceSetting: async () => {
const workspaceSetting = (await workspaceServiceClient.getWorkspaceSetting({})).setting as WorkspaceSetting;
const workspaceSetting = await workspaceServiceClient.getWorkspaceSetting({});
set({ ...get(), setting: workspaceSetting });
return workspaceSetting;
},
checkFeatureAvailable: (feature: FeatureType): boolean => {
return get().profile.features.includes(feature);
return get().profile.subscription?.features.includes(feature) || false;
},
}));