Skip to content

Commit

Permalink
Merge pull request #50 from Saasfy/project-limits
Browse files Browse the repository at this point in the history
feat(web): add project limits
  • Loading branch information
IKatsuba authored May 8, 2024
2 parents d3203b0 + ffd522a commit 14c8b53
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/components/src/lib/create-project/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function createProject(formData: FormData) {

const { data: workspace } = await supabase
.from('workspaces')
.select('*, workspace_users!inner(*)')
.select('*, workspace_users!inner(*), projects(id), plans(max_projects)')
.eq('slug', workspaceSlug)
.eq('workspace_users.user_id', user.id)
.single();
Expand All @@ -57,6 +57,14 @@ export async function createProject(formData: FormData) {
};
}

const maxProjects = workspace?.plans?.max_projects || 1;

if (workspace?.projects?.length ?? 0 >= maxProjects) {
return {
errors: ['Workspace is full'],
};
}

const { data: createProject } = await supabase
.from('projects')
.insert({
Expand Down

0 comments on commit 14c8b53

Please sign in to comment.