Fixes SMS actions and cal.com branding for premium plan (#7306)

* enable sms actions with premium user name

* allow hide branding when user has premium user name

---------

Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
Carina WollendorferandCarinaWolli authored and GitHub committed 2023-02-23 15:01:51 -07:00
1 parent 3206e4ea12
commit ba86e7f540
3 files changed
+21 -9

No files matched your search

+2 -2
View File
@@ -1,3 +1,3 @@
export function isBrandingHidden(hideBrandingSetting: boolean, belongsToActiveTeam: boolean) {
return belongsToActiveTeam && hideBrandingSetting;
export function isBrandingHidden(hideBrandingSetting: boolean, hasPaidPlan: boolean) {
return hasPaidPlan && hideBrandingSetting;
}
+6 -2
View File
@@ -3,6 +3,7 @@ import { z } from "zod";
import type { LocationObject } from "@calcom/app-store/locations";
import { IS_TEAM_BILLING_ENABLED, WEBAPP_URL } from "@calcom/lib/constants";
import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { User } from "@calcom/prisma/client";
@@ -82,6 +83,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
weekStart: true,
brandColor: true,
darkBrandColor: true,
metadata: true,
eventTypes: {
where: {
// Many-to-many relationship causes inclusion of the team events - cool -
@@ -157,7 +159,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
locations: privacyFilteredLocations(locations),
descriptionAsSafeHTML: eventType.description ? md.render(eventType.description) : null,
});
// Check if the user you are logging into has any active teams
// Check if the user you are logging into has any active teams or premium user name
const hasActiveTeam =
user.teams.filter((m) => {
if (!IS_TEAM_BILLING_ENABLED) return true;
@@ -166,6 +168,8 @@ async function getUserPageProps(context: GetStaticPropsContext) {
return false;
}).length > 0;
const hasPremiumUserName = hasKeyInMetadata(user, "isPremium");
return {
props: {
eventType: eventTypeObject,
@@ -182,7 +186,7 @@ async function getUserPageProps(context: GetStaticPropsContext) {
away: user?.away,
isDynamic: false,
trpcState: ssg.dehydrate(),
isBrandingHidden: isBrandingHidden(user.hideBranding, hasActiveTeam),
isBrandingHidden: isBrandingHidden(user.hideBranding, hasActiveTeam || hasPremiumUserName),
},
revalidate: 10, // seconds
};