-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Disable custom templates for trialing teams #18748
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ae12395
Create `checkIfTeamHasActivePlan` method on `stripe-billing-service`
joeauyeung 02dfe96
Add `checkIfTeamPlanIsActive` to `InternalTeamBilling`
joeauyeung 16e32ee
Create `hasActiveTeamPlan` trpc endpoint
joeauyeung 2107ad8
Check for active team plan when updating workflows
joeauyeung f7b76eb
Create `useHasActiveTeamPlan` hook
joeauyeung 04639bc
Use `useHasActiveTeamPlan` on workflow edit page
joeauyeung 4d86e2c
Type fixes
joeauyeung 556958e
Type fix
joeauyeung 3d80532
Add `accepted` to team query
joeauyeung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/trpc/server/routers/viewer/teams/hasActiveTeamPlan.handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { InternalTeamBilling } from "@calcom/ee/billing/teams/internal-team-billing"; | ||
import { IS_SELF_HOSTED } from "@calcom/lib/constants"; | ||
import { prisma } from "@calcom/prisma"; | ||
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc"; | ||
|
||
import type { THasActiveTeamPlanSchema } from "./hasActiveTeamPlan.schema"; | ||
|
||
type HasActiveTeamPlanOptions = { | ||
ctx: { | ||
user: NonNullable<TrpcSessionUser>; | ||
}; | ||
input: THasActiveTeamPlanSchema; | ||
}; | ||
|
||
export const hasActiveTeamPlanHandler = async ({ input, ctx }: HasActiveTeamPlanOptions) => { | ||
if (IS_SELF_HOSTED) return true; | ||
|
||
if (!input.teamId) return false; | ||
|
||
const userId = ctx.user.id; | ||
|
||
// Check if the user is a member of the requested team | ||
const team = await prisma.team.findFirst({ | ||
where: { | ||
id: input.teamId, | ||
members: { | ||
some: { | ||
userId: userId, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should also add |
||
accepted: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
if (!team) return false; | ||
|
||
// Get the current team's subscription | ||
const teamBillingService = new InternalTeamBilling(team); | ||
return await teamBillingService.checkIfTeamHasActivePlan(); | ||
}; | ||
|
||
export default hasActiveTeamPlanHandler; |
7 changes: 7 additions & 0 deletions
7
packages/trpc/server/routers/viewer/teams/hasActiveTeamPlan.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { z } from "zod"; | ||
|
||
export const ZHasActiveTeamPlanSchema = z.object({ | ||
teamId: z.number().optional(), | ||
}); | ||
|
||
export type THasActiveTeamPlanSchema = z.infer<typeof ZHasActiveTeamPlanSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joeauyeung Now we only allow custom templates on team workflows but not on User workflows for user's that are part of a team or org