feat: /skip trial for teams (#20753)

* skip team trials

* add loading state

* update mocks

* cleanup

* add import oops

* fix tests files

---------

Co-authored-by: Sean Brydon <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-04-29 11:48:41 +00:00
1 parent 81b4651d6e
commit 3296255f80
9 files changed
+273

No files matched your search

@@ -1,7 +1,9 @@
import type { User as UserAuth } from "next-auth";
import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
import { useHasActiveTeamPlan } from "@calcom/lib/hooks/useHasPaidPlan";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { showToast } from "@calcom/ui/components/toast";
import { type NavigationItemType } from "./navigation/NavigationItem";
@@ -18,8 +20,33 @@ export function useBottomNavItems({
user,
}: BottomNavItemsProps): NavigationItemType[] {
const { t } = useLocale();
const { isTrial } = useHasActiveTeamPlan();
const utils = trpc.useUtils();
const skipTeamTrialsMutation = trpc.viewer.teams.skipTeamTrials.useMutation({
onSuccess: () => {
utils.viewer.teams.hasActiveTeamPlan.invalidate();
showToast(t("team_trials_skipped_successfully"), "success");
},
onError: () => {
showToast(t("something_went_wrong"), "error");
},
});
return [
// Render above to prevent layout shift as much as possible
isTrial
? {
name: "skip_trial",
href: "",
isLoading: skipTeamTrialsMutation.isPending,
icon: "clock",
onClick: (e: { preventDefault: () => void }) => {
e.preventDefault();
skipTeamTrialsMutation.mutate({});
},
}
: null,
{
name: "view_public_page",
href: publicPageUrl,
@@ -43,6 +70,7 @@ export function useBottomNavItems({
icon: "gift",
}
: null,
isAdmin
? {
name: "impersonation",