Add flock exports, sharing invitations, and improved flock switching
This commit is contained in:
1 parent
ff177dbaed
commit
55353e4d46
12 files changed
+557
-100
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import type { WorkspaceRow, WorkspaceType } from './types.js';
|
||||
|
||||
type WorkspaceAccess = Pick<WorkspaceRow, 'name' | 'workspace_type' | 'subscription_status' | 'rescue_verification_status'>;
|
||||
|
||||
export const subscriptionAllowsWrite = (workspace: WorkspaceAccess) => {
|
||||
if (workspace.workspace_type === 'rescue') {
|
||||
return workspace.rescue_verification_status === 'approved';
|
||||
}
|
||||
return workspace.subscription_status === 'active' || workspace.subscription_status === 'trialing';
|
||||
};
|
||||
|
||||
export const canUpdateWorkspaceSettings = (
|
||||
workspace: WorkspaceAccess,
|
||||
payload: { name: string; workspaceType: WorkspaceType },
|
||||
isAdmin: boolean,
|
||||
) => {
|
||||
// Requesting rescue verification must not require buying a household subscription.
|
||||
// The route still validates onboarding and the repository marks the rescue pending.
|
||||
const requestingRescue = workspace.workspace_type === 'standard' && payload.workspaceType === 'rescue';
|
||||
const billingOnly = workspace.workspace_type === 'standard' && payload.workspaceType === 'standard' && payload.name === workspace.name;
|
||||
return isAdmin || subscriptionAllowsWrite(workspace) || requestingRescue || billingOnly;
|
||||
};
|
||||
Reference in new issue
Block a user