diff --git a/apps/web/components/getting-started/steps-views/UserSettings.tsx b/apps/web/components/getting-started/steps-views/UserSettings.tsx index ed47714ee0..04f0285844 100644 --- a/apps/web/components/getting-started/steps-views/UserSettings.tsx +++ b/apps/web/components/getting-started/steps-views/UserSettings.tsx @@ -42,12 +42,8 @@ const UserSettings = (props: IUserSettingsProps) => { const mutation = trpc.viewer.updateProfile.useMutation({ onSuccess: onSuccess, }); - const { data: stripeCustomer } = trpc.viewer.stripeCustomer.useQuery(); - const paymentRequired = stripeCustomer?.isPremium ? !stripeCustomer?.paidForPremium : false; + const onSubmit = handleSubmit((data) => { - if (paymentRequired) { - return; - } mutation.mutate({ name: data.name, timeZone: selectedTimeZone, diff --git a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx index 1389d64b02..c1945aec94 100644 --- a/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx +++ b/apps/web/components/ui/UsernameAvailability/PremiumTextfield.tsx @@ -3,7 +3,7 @@ import { debounce, noop } from "lodash"; import { useRouter } from "next/router"; import { RefCallback, useEffect, useMemo, useState } from "react"; -import { getPremiumPlanMode, getPremiumPlanPriceValue } from "@calcom/app-store/stripepayment/lib/utils"; +import { getPremiumPlanPriceValue } from "@calcom/app-store/stripepayment/lib/utils"; import { fetchUsername } from "@calcom/lib/fetchUsername"; import hasKeyInMetadata from "@calcom/lib/hasKeyInMetadata"; import { useLocale } from "@calcom/lib/hooks/useLocale"; @@ -24,9 +24,7 @@ import { } from "@calcom/ui"; export enum UsernameChangeStatusEnum { - NORMAL = "NORMAL", UPGRADE = "UPGRADE", - DOWNGRADE = "DOWNGRADE", } interface ICustomUsernameProps { @@ -60,20 +58,14 @@ interface ICustomUsernameProps { const obtainNewUsernameChangeCondition = ({ userIsPremium, isNewUsernamePremium, - stripeCustomer, }: { userIsPremium: boolean; isNewUsernamePremium: boolean; stripeCustomer: RouterOutputs["viewer"]["stripeCustomer"] | undefined; }) => { - if (!userIsPremium && isNewUsernamePremium && !stripeCustomer?.paidForPremium) { + if (!userIsPremium && isNewUsernamePremium) { return UsernameChangeStatusEnum.UPGRADE; } - - if (userIsPremium && !isNewUsernamePremium && getPremiumPlanMode() === "subscription") { - return UsernameChangeStatusEnum.DOWNGRADE; - } - return UsernameChangeStatusEnum.NORMAL; }; const PremiumTextfield = (props: ICustomUsernameProps) => { @@ -106,7 +98,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => { setIsInputUsernamePremium(data.premium); setUsernameIsAvailable(data.available); }, 150), - [] + [currentUsername] ); useEffect(() => { @@ -137,7 +129,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => { }); // when current username isn't set - Go to stripe to check what username he wanted to buy and was it a premium and was it paid for - const paymentRequired = !currentUsername && stripeCustomer?.isPremium && !stripeCustomer?.paidForPremium; + const paymentRequired = !currentUsername && stripeCustomer?.isPremium; const usernameChangeCondition = obtainNewUsernameChangeCondition({ userIsPremium: isCurrentUsernamePremium, @@ -194,7 +186,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => { }; const saveUsername = () => { - if (usernameChangeCondition === UsernameChangeStatusEnum.NORMAL) { + if (usernameChangeCondition !== UsernameChangeStatusEnum.UPGRADE) { updateUsername.mutate({ username: inputUsernameValue, }); @@ -279,14 +271,6 @@ const PremiumTextfield = (props: ICustomUsernameProps) => { {paymentMsg} {markAsError &&

Username is already taken

} - {usernameIsAvailable && ( -

- {usernameChangeCondition === UsernameChangeStatusEnum.DOWNGRADE && ( - <>{t("premium_to_standard_username_description")} - )} -

- )} -
@@ -295,13 +279,8 @@ const PremiumTextfield = (props: ICustomUsernameProps) => {
- {usernameChangeCondition && usernameChangeCondition !== UsernameChangeStatusEnum.NORMAL && ( -

- {usernameChangeCondition === UsernameChangeStatusEnum.UPGRADE && - t("change_username_standard_to_premium")} - {usernameChangeCondition === UsernameChangeStatusEnum.DOWNGRADE && - t("change_username_premium_to_standard")} -

+ {usernameChangeCondition && usernameChangeCondition === UsernameChangeStatusEnum.UPGRADE && ( +

{t("change_username_standard_to_premium")}

)}
@@ -323,8 +302,7 @@ const PremiumTextfield = (props: ICustomUsernameProps) => {
{/* redirect to checkout */} - {(usernameChangeCondition === UsernameChangeStatusEnum.UPGRADE || - usernameChangeCondition === UsernameChangeStatusEnum.DOWNGRADE) && ( + {usernameChangeCondition === UsernameChangeStatusEnum.UPGRADE && ( )} {/* Normal save */} - {usernameChangeCondition === UsernameChangeStatusEnum.NORMAL && ( + {usernameChangeCondition !== UsernameChangeStatusEnum.UPGRADE && (