Adds team upgrade banner (#5541)
* Adds team upgrade banner * Update TeamListItem.tsx * Update payments.ts * Copy updates and mobile style fixes * Update packages/trpc/server/routers/viewer/teams.tsx Co-authored-by: alannnc <[email protected]> Co-authored-by: alannnc <[email protected]>
This commit is contained in:
1 parent
112efbbda2
commit
ee620c7fff
9 files changed
+97
-16
No files matched your search
@@ -589,8 +589,7 @@ export const viewerTeamsRouter = router({
|
||||
|
||||
const metadata = teamMetadataSchema.safeParse(prevTeam.metadata);
|
||||
|
||||
if (!metadata.success || !metadata.data?.requestedSlug)
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: "Can't publish team without `requestedSlug`" });
|
||||
if (!metadata.success) throw new TRPCError({ code: "BAD_REQUEST", message: "Invalid team metadata" });
|
||||
|
||||
// if payment needed, respond with checkout url
|
||||
if (IS_TEAM_BILLING_ENABLED) {
|
||||
@@ -607,6 +606,10 @@ export const viewerTeamsRouter = router({
|
||||
return { url: checkoutSession.url };
|
||||
}
|
||||
|
||||
if (!metadata.data?.requestedSlug) {
|
||||
throw new TRPCError({ code: "BAD_REQUEST", message: "Can't publish team without `requestedSlug`" });
|
||||
}
|
||||
|
||||
const { requestedSlug, ...newMetadata } = metadata.data;
|
||||
let updatedTeam: Awaited<ReturnType<typeof ctx.prisma.team.update>>;
|
||||
|
||||
@@ -628,4 +631,19 @@ export const viewerTeamsRouter = router({
|
||||
|
||||
return { url: `${WEBAPP_URL}/settings/teams/${updatedTeam.id}/profile` };
|
||||
}),
|
||||
/** This is a temporal endpoint so we can progressively upgrade teams to the new billing system. */
|
||||
getUpgradeable: authedProcedure.query(async ({ ctx }) => {
|
||||
if (!IS_TEAM_BILLING_ENABLED) return [];
|
||||
let { teams } = await ctx.prisma.user.findUniqueOrThrow({
|
||||
where: { id: ctx.user.id },
|
||||
include: { teams: { where: { role: MembershipRole.OWNER }, include: { team: true } } },
|
||||
});
|
||||
/** We only need to return teams that don't have a `subscriptionId` on their metadata */
|
||||
teams = teams.filter((m) => {
|
||||
const metadata = teamMetadataSchema.safeParse(m.team.metadata);
|
||||
if (metadata.success && metadata.data?.subscriptionId) return false;
|
||||
return true;
|
||||
});
|
||||
return teams;
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user